[awesome] add redshift widget
This commit is contained in:
parent
d3d7da3456
commit
91dfcb40be
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 131 B |
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 131 B |
|
@ -203,6 +203,7 @@ awful.screen.connect_for_each_screen(function(s)
|
|||
{ -- Right widgets
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
wibox.widget.systray(),
|
||||
widgets.redshift,
|
||||
widgets.bluetooth,
|
||||
widgets.netdown_icon,
|
||||
widgets.netdown.widget,
|
||||
|
@ -518,4 +519,3 @@ awful.util.spawn({"nm-applet"})
|
|||
awful.util.spawn({"ibus-daemon", "-r", "--xim"})
|
||||
awful.util.spawn({"/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1"})
|
||||
awful.util.spawn_with_shell("~/bin/spawn-once pasystray")
|
||||
awful.util.spawn_with_shell("~/bin/spawn-once redshift-gtk")
|
||||
|
|
|
@ -110,4 +110,32 @@ widgets.bluetooth:buttons(
|
|||
|
||||
helpers.newtimer("bluetooth", 10, widgets.bluetooth.update)
|
||||
|
||||
widgets.redshift = wibox.widget.imagebox(iconsdir .. "redshift-on.png")
|
||||
widgets.redshift.pid = nil
|
||||
helpers.async_with_shell("ps x -o pid=,command=|grep -E 'redshift$' |cut -d' ' -f 1", function(pid)
|
||||
if pid and #pid > 0 then
|
||||
widgets.redshift.pid = tonumber(pid)
|
||||
else
|
||||
widgets.redshift.pid = awful.spawn.spawn({ "redshift" })
|
||||
end
|
||||
end)
|
||||
widgets.redshift.active = true
|
||||
|
||||
widgets.redshift.toggle = function()
|
||||
awful.spawn.spawn({ "kill", "-SIGUSR1", tostring(widgets.redshift.pid) })
|
||||
widgets.redshift.active = not widgets.redshift.active
|
||||
|
||||
if widgets.redshift.active == true then
|
||||
widgets.redshift:set_image(iconsdir .. "redshift-on.png")
|
||||
else
|
||||
widgets.redshift:set_image(iconsdir .. "redshift-off.png")
|
||||
end
|
||||
end
|
||||
|
||||
widgets.redshift:buttons(
|
||||
table.join(
|
||||
awful.button({ }, 1, widgets.redshift.toggle)
|
||||
)
|
||||
)
|
||||
|
||||
return widgets
|
||||
|
|
Reference in a new issue