Created
October 24, 2017 06:34
-
-
Save leafo/d701477c97bfae385fbfcf4597d8ae86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
textbox = require "wibox.widget.textbox" | |
awful = require "awful" | |
naughty = require "naughty" | |
local selfwatch_text | |
make_selfwatch_textbox = (timeout=60) -> | |
return selfwatch_text if selfwatch_text | |
w = textbox! | |
check_running = (fn) -> | |
awful.spawn.easy_async "pidof selfwatch", (stdout, stderr, reason, code) -> | |
fn code == 0 | |
get_status = (fn) -> | |
awful.spawn.easy_async "selfwatch -config /home/leafo/.selfwatch/selfwatch.json status", (stdout, stderr, reason, code) -> | |
fn stdout | |
t = with timer(:timeout) | |
\connect_signal "timeout", -> | |
check_running (running) -> | |
if running | |
get_status (status) -> | |
w\set_markup '<span color="#B7CE42">✓ ' .. status .. '</span> ' | |
else | |
w\set_markup '<span color="#F00060">✕ SW</span> ' | |
\start! | |
\emit_signal "timeout" | |
w\connect_signal "button::press", -> | |
t\emit_signal "timeout" | |
selfwatch_text = w | |
w | |
{ :make_selfwatch_textbox, } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment