51 lines
1.1 KiB
PHP
Executable file
51 lines
1.1 KiB
PHP
Executable file
#!/usr/bin/env php
|
|
<?php
|
|
|
|
require __DIR__.'/base/block.php';
|
|
|
|
$pidFile = '/tmp/remote_i3wm_ws.pid';
|
|
$isAlive = false;
|
|
|
|
if (file_exists($pidFile)) {
|
|
$pid = (int) file_get_contents($pidFile);
|
|
|
|
if (is_dir('/proc/'.$pid)) {
|
|
$isAlive = true;
|
|
}
|
|
}
|
|
|
|
putenv('DISPLAY=:0');
|
|
putenv('SERVER_OPTIONS=-v -m');
|
|
|
|
$commandSuffix = ' >> /home/simon/remote_i3.log 2>>/home/simon/remote_i3.log';
|
|
|
|
$commandStart = "/home/simon/bin/remote_i3_server start".$commandSuffix;
|
|
$commandStop = "/home/simon/bin/remote_i3_server stop".$commandSuffix;
|
|
|
|
if (!$isAlive) {
|
|
echo block(
|
|
'i3remote',
|
|
[
|
|
'full_text' => rpspan(emoji(0xf245), '#cccccc', '#000'),
|
|
'color' => '#cccccc',
|
|
]
|
|
);
|
|
|
|
if (getenv('BLOCK_BUTTON') === '1') {
|
|
pclose(popen($commandStart, 'r'));
|
|
}
|
|
} else {
|
|
echo block(
|
|
'i3remote',
|
|
[
|
|
'full_text' => rpspan(emoji(0xf245), color('warning'), '#000'),
|
|
'color' => color('warning'),
|
|
]
|
|
);
|
|
|
|
if (getenv('BLOCK_BUTTON') === '1') {
|
|
pclose(popen($commandStop, 'r'));
|
|
}
|
|
}
|
|
|