Skip to content

Commit efc19b1

Browse files
authored
Merge pull request #463 from VMatt013/bluelight-widget
Bluelight widget
2 parents ce42deb + e635dc1 commit efc19b1

File tree

7 files changed

+137
-0
lines changed

7 files changed

+137
-0
lines changed

bluelight-widget/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
| Day Mode | Night Mode |
7+
|----------|------------|
8+
|![Day Mode](day.png) | ![Night Mode](night.png) |
9+
10+
(I couldn't capture the effect itself)
11+
12+
I usually use every widget with my custom (kinda janky) [wrapper widget](https://github.com/VMatt013/MySetup/blob/Debian/.config/awesome/widgets/margin.lua) to make them look cleaner and more unified.
13+
14+
15+
**With wrapper**
16+
17+
![With wrapper](with_wrapper.png)
18+
19+
20+
## Installation
21+
22+
Clone this repository then add the widget to your wibar:
23+
24+
```lua
25+
local bluelight_widget = require("awesome-wm-widgets.bluelight-widget")
26+
local margin = require("awesome-wm-widgets.margin") -- In case you use my wrapper
27+
28+
s.mytasklist, -- Middle widget
29+
{ -- Right widgets
30+
layout = wibox.layout.fixed.horizontal,
31+
...
32+
bluelight_widget, -- Add the widget here
33+
margin(bluelight, true), -- Add the widget with my wrapper
34+
...
35+
}
36+
```
37+
38+
## Usage
39+
40+
- Click the widget to toggle between **Day Mode** and **Night Mode**.
41+
- **Day Mode:** Disables the blue light filter.
42+
- **Night Mode:** Activates the blue light filter with a warm color temperature.
43+
44+
## Customization
45+
46+
You can customize the widget by modifying the following parameters in the widget's source file:
47+
48+
| Name | Default | Description |
49+
|------------|----------------------------------------|------------------------------------------------------------|
50+
| `ICON_DIR` | ```awesome-wm-widgets/bluelight-widget/``` | Directory where the widget icons (sun.svg and moon.svg) are stored. |
51+
| `CMD` | ```redshift``` | Command to run Redshift. |
52+
| `NIGHT_CMD`| ```-O 2500 -g 0.75``` | Command options for activating Night Mode. |
53+
| `DAY_CMD` | ```-x``` | Command options for activating Day Mode. |
54+
55+
## Dependencies
56+
57+
- [Redshift](https://github.com/jonls/redshift): Make sure Redshift is installed on your system.

bluelight-widget/day.png

128 KB
Loading

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/night.png

128 KB
Loading

bluelight-widget/sun.svg

Lines changed: 4 additions & 0 deletions
Loading

bluelight-widget/with_wrapper.png

103 KB
Loading

0 commit comments

Comments
 (0)