Skip to content

Commit edfd901

Browse files
committed
Add Blue Light Filter Widget
1 parent d6733cf commit edfd901

File tree

4 files changed

+122
-0
lines changed

4 files changed

+122
-0
lines changed

bluelight-widget/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
# Blue Light Filter Widget
3+
4+
This widget provides a simple way to toggle a blue light filter using [Redshift](https://github.com/jonls/redshift). It offers an easy mechanism to switch between day and night modes, reducing eye strain during late-night computer use.
5+
6+
7+
## Installation
8+
9+
Clone this repository then add the widget to your wibar:
10+
11+
```lua
12+
local bluelight_widget = require("awesome-wm-widgets.bluelight-widget")
13+
14+
s.mytasklist, -- Middle widget
15+
{ -- Right widgets
16+
layout = wibox.layout.fixed.horizontal,
17+
...
18+
bluelight_widget, -- Add the widget here
19+
...
20+
}
21+
```
22+
23+
## Usage
24+
25+
- Click the widget to toggle between **Day Mode** and **Night Mode**.
26+
- **Day Mode:** Disables the blue light filter.
27+
- **Night Mode:** Activates the blue light filter with a warm color temperature.
28+
29+
## Customization
30+
31+
You can customize the widget by modifying the following parameters in the widget's source file:
32+
33+
| Name | Default | Description |
34+
|------------|----------------------------------------|------------------------------------------------------------|
35+
| `ICON_DIR` | ```awesome-wm-widgets/bluelight-widget/``` | Directory where the widget icons (sun.svg and moon.svg) are stored. |
36+
| `CMD` | ```redshift``` | Command to run Redshift. |
37+
| `NIGHT_CMD`| ```-O 2500 -g 0.75``` | Command options for activating Night Mode. |
38+
| `DAY_CMD` | ```-x``` | Command options for activating Day Mode. |
39+
40+
## Dependencies
41+
42+
- [Redshift](https://github.com/jonls/redshift): Make sure Redshift is installed on your system.

bluelight-widget/init.lua

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
-------------------------------------------------
2+
-- Blue Light Filter Widget for Awesome Window Manager
3+
-- More details could be found here:
4+
-- https://github.com/streetturtle/awesome-wm-widgets/tree/master/bluelight-widget
5+
6+
-- @author VMatt
7+
-- @copyright 2025 VMatt
8+
-------------------------------------------------
9+
10+
local awful = require("awful")
11+
local wibox = require("wibox")
12+
local gfs = require("gears.filesystem")
13+
14+
local ICON_DIR = gfs.get_configuration_dir() .. "awesome-wm-widgets/bluelight-widget/"
15+
local DAY_ICON = ICON_DIR .. "sun.svg"
16+
local NIGHT_ICON = ICON_DIR .. "moon.svg"
17+
18+
local CMD = "redshift"
19+
local NIGHT_CMD = "-O 2500 -g 0.75"
20+
local DAY_CMD = "-x"
21+
local day = true
22+
23+
local widget = wibox.widget({
24+
{
25+
26+
{
27+
id = "icon",
28+
image = DAY_ICON,
29+
resize = true,
30+
widget = wibox.widget.imagebox,
31+
},
32+
layout = wibox.layout.fixed.horizontal,
33+
widget = wibox.container.margin,
34+
},
35+
border_width = 5,
36+
widget = wibox.container.background,
37+
layout = wibox.layout.fixed.horizontal,
38+
})
39+
40+
function widget:update()
41+
local icon = self:get_children_by_id("icon")[1]
42+
if day then
43+
icon:set_image(DAY_ICON)
44+
else
45+
icon:set_image(NIGHT_ICON)
46+
end
47+
end
48+
49+
local function on_day()
50+
awful.spawn(CMD .. " " .. DAY_CMD)
51+
widget:update()
52+
end
53+
54+
local function on_night()
55+
awful.spawn(CMD .. " " .. NIGHT_CMD)
56+
widget:update()
57+
end
58+
59+
local function toggle()
60+
day = not day
61+
if day then
62+
on_day()
63+
else
64+
on_night()
65+
end
66+
end
67+
68+
widget:buttons(awful.util.table.join(awful.button({}, 1, function()
69+
toggle()
70+
end)))
71+
72+
return widget

bluelight-widget/moon.svg

Lines changed: 4 additions & 0 deletions
Loading

bluelight-widget/sun.svg

Lines changed: 4 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)