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>
9 local awful = require("awful")
12 local setmetatable = setmetatable
15 -- lain.widgets.contrib.redshift
18 local attached = false -- true if attached to a widget
19 local active = false -- true if redshift is active
20 local running = false -- true if redshift was initialized
21 local update_fnct = function() end -- Function that is run each time redshift is toggled. See redshift:attach().
24 -- As there is no way to determine if redshift was previously
25 -- toggled off (i.e Awesome on-the-fly restart), kill redshift to make sure
26 os.execute("pkill redshift")
27 -- Remove existing color adjustment
28 awful.spawn.with_shell("redshift -x")
30 awful.spawn.with_shell("redshift")
35 function redshift:toggle()
37 -- Sending -USR1 toggles redshift (See project website)
38 os.execute("pkill -USR1 redshift")
46 function redshift:off()
47 if running and active then
52 function redshift:on()
58 function redshift:is_active()
63 -- Provides a button which toggles redshift on/off on click
64 -- @param widget: Widget to attach to.
65 -- @param fnct: Function to be run each time redshift is toggled (optional).
66 -- Use it to update widget text or icons on status change.
67 function redshift:attach(widget, fnct)
68 update_fnct = fnct or function() end
74 widget:buttons(awful.util.table.join( awful.button({}, 1, function () redshift:toggle() end) ))
77 return setmetatable(redshift, { _call = function(_, ...) return create(...) end })