From 91dfcb40be918349215b7ccb65e0e6d1e40c9aa7 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Fri, 7 Jun 2019 14:55:07 +0000 Subject: [PATCH] [awesome] add redshift widget --- .../awesome/icons/redshift-off.png} | Bin .../awesome/icons/redshift-on.png} | Bin home/.config/awesome/rc.lua | 2 +- home/.config/awesome/widgets.lua | 28 ++++++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) rename home/{.local/share/icons/hicolor/16x16/apps/redshift-status-off.png => .config/awesome/icons/redshift-off.png} (100%) rename home/{.local/share/icons/hicolor/16x16/apps/redshift-status-on.png => .config/awesome/icons/redshift-on.png} (100%) diff --git a/home/.local/share/icons/hicolor/16x16/apps/redshift-status-off.png b/home/.config/awesome/icons/redshift-off.png similarity index 100% rename from home/.local/share/icons/hicolor/16x16/apps/redshift-status-off.png rename to home/.config/awesome/icons/redshift-off.png diff --git a/home/.local/share/icons/hicolor/16x16/apps/redshift-status-on.png b/home/.config/awesome/icons/redshift-on.png similarity index 100% rename from home/.local/share/icons/hicolor/16x16/apps/redshift-status-on.png rename to home/.config/awesome/icons/redshift-on.png diff --git a/home/.config/awesome/rc.lua b/home/.config/awesome/rc.lua index 8115dc4..85da418 100644 --- a/home/.config/awesome/rc.lua +++ b/home/.config/awesome/rc.lua @@ -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") diff --git a/home/.config/awesome/widgets.lua b/home/.config/awesome/widgets.lua index 3214402..5b02716 100644 --- a/home/.config/awesome/widgets.lua +++ b/home/.config/awesome/widgets.lua @@ -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