All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
4 Licensed under GNU General Public License v2
5 * (c) 2014, blueluke <http://github.com/blueluke>
10 local awful = require("awful")
11 local spawn = awful.util.spawn_with_shell
13 local setmetatable = setmetatable
16 -- lain.widgets.contrib.redshift
19 local attached = false -- true if attached to a widget
20 local active = false -- true if redshift is active
21 local running = false -- true if redshift was initialized
22 local update_fnct = function() end -- function that is run each time redshift is toggled. See redshift:attach().
26 -- As there is no way to determine if redshift was previously
27 -- toggled off (i.e Awesome on-the-fly restart), kill redshift to make sure
28 os.execute("pkill redshift")
29 -- Remove existing color adjustment
37 function redshift:toggle()
39 -- Sending -USR1 toggles redshift (See project website)
40 os.execute("pkill -USR1 redshift")
48 function redshift:off()
49 if running and active then
54 function redshift:on()
60 function redshift:is_active()
65 -- Provides a button which toggles redshift on/off on click
66 -- @ param widget: widget to attach to
67 -- @ param fnct: function to be run each time redshift is toggled (optional).
68 -- Use it to update widget text or icons on status change.
69 function redshift:attach(widget, fnct)
70 update_fnct = fnct or function() end
76 widget:buttons(awful.util.table.join( awful.button({}, 1, function () redshift:toggle() end) ))
79 return setmetatable(redshift, { _call = function(_, ...) return create(...) end })