i3remote block
This commit is contained in:
parent
ae1c793a90
commit
2cb77ae8c0
1 changed files with 50 additions and 0 deletions
50
bar/src/i3remote.php
Executable file
50
bar/src/i3remote.php
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
#!/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('REMOTE_I3WM_WS_OPTIONS=-v -vvv');
|
||||
|
||||
$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' => lpspan(emoji(0xf245), '#cccccc', '#000'),
|
||||
'color' => '#cccccc',
|
||||
]
|
||||
);
|
||||
|
||||
if (getenv('BLOCK_BUTTON') === '1') {
|
||||
pclose(popen($commandStart, 'r'));
|
||||
}
|
||||
} else {
|
||||
echo block(
|
||||
'i3remote',
|
||||
[
|
||||
'full_text' => lpspan(emoji(0xf245), color('warning'), '#000'),
|
||||
'color' => color('warning'),
|
||||
]
|
||||
);
|
||||
|
||||
if (getenv('BLOCK_BUTTON') === '1') {
|
||||
pclose(popen($commandStop, 'r'));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue