-
-
Notifications
You must be signed in to change notification settings - Fork 282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bluelight widget #463
Open
VMatt013
wants to merge
4
commits into
streetturtle:master
Choose a base branch
from
VMatt013:bluelight-widget
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Bluelight widget #463
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
# Blue Light Filter Widget | ||
|
||
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. | ||
|
||
| Day Mode | Night Mode | | ||
|----------|------------| | ||
|![Day Mode](day.png) | ![Night Mode](night.png) | | ||
|
||
(I couldn't capture the effect itself) | ||
|
||
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. | ||
|
||
|
||
**With wrapper** | ||
|
||
![With wrapper](with_wrapper.png) | ||
|
||
|
||
## Installation | ||
|
||
Clone this repository then add the widget to your wibar: | ||
|
||
```lua | ||
local bluelight_widget = require("awesome-wm-widgets.bluelight-widget") | ||
local margin = require("awesome-wm-widgets.margin") -- In case you use my wrapper | ||
|
||
s.mytasklist, -- Middle widget | ||
{ -- Right widgets | ||
layout = wibox.layout.fixed.horizontal, | ||
... | ||
bluelight_widget, -- Add the widget here | ||
margin(bluelight, true), -- Add the widget with my wrapper | ||
... | ||
} | ||
``` | ||
|
||
## Usage | ||
|
||
- Click the widget to toggle between **Day Mode** and **Night Mode**. | ||
- **Day Mode:** Disables the blue light filter. | ||
- **Night Mode:** Activates the blue light filter with a warm color temperature. | ||
|
||
## Customization | ||
|
||
You can customize the widget by modifying the following parameters in the widget's source file: | ||
|
||
| Name | Default | Description | | ||
|------------|----------------------------------------|------------------------------------------------------------| | ||
| `ICON_DIR` | ```awesome-wm-widgets/bluelight-widget/``` | Directory where the widget icons (sun.svg and moon.svg) are stored. | | ||
| `CMD` | ```redshift``` | Command to run Redshift. | | ||
| `NIGHT_CMD`| ```-O 2500 -g 0.75``` | Command options for activating Night Mode. | | ||
| `DAY_CMD` | ```-x``` | Command options for activating Day Mode. | | ||
|
||
## Dependencies | ||
|
||
- [Redshift](https://github.com/jonls/redshift): Make sure Redshift is installed on your system. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
------------------------------------------------- | ||
-- Blue Light Filter Widget for Awesome Window Manager | ||
-- More details could be found here: | ||
-- https://github.com/streetturtle/awesome-wm-widgets/tree/master/bluelight-widget | ||
|
||
-- @author VMatt | ||
-- @copyright 2025 VMatt | ||
------------------------------------------------- | ||
|
||
local awful = require("awful") | ||
local wibox = require("wibox") | ||
local gfs = require("gears.filesystem") | ||
|
||
local ICON_DIR = gfs.get_configuration_dir() .. "awesome-wm-widgets/bluelight-widget/" | ||
local DAY_ICON = ICON_DIR .. "sun.svg" | ||
local NIGHT_ICON = ICON_DIR .. "moon.svg" | ||
|
||
local CMD = "redshift" | ||
local NIGHT_CMD = "-O 2500 -g 0.75" | ||
local DAY_CMD = "-x" | ||
local day = true | ||
|
||
local widget = wibox.widget({ | ||
{ | ||
|
||
{ | ||
id = "icon", | ||
image = DAY_ICON, | ||
resize = true, | ||
widget = wibox.widget.imagebox, | ||
}, | ||
layout = wibox.layout.fixed.horizontal, | ||
widget = wibox.container.margin, | ||
}, | ||
border_width = 5, | ||
widget = wibox.container.background, | ||
layout = wibox.layout.fixed.horizontal, | ||
}) | ||
|
||
function widget:update() | ||
local icon = self:get_children_by_id("icon")[1] | ||
if day then | ||
icon:set_image(DAY_ICON) | ||
else | ||
icon:set_image(NIGHT_ICON) | ||
end | ||
end | ||
|
||
local function on_day() | ||
awful.spawn(CMD .. " " .. DAY_CMD) | ||
widget:update() | ||
end | ||
|
||
local function on_night() | ||
awful.spawn(CMD .. " " .. NIGHT_CMD) | ||
widget:update() | ||
end | ||
|
||
local function toggle() | ||
day = not day | ||
if day then | ||
on_day() | ||
else | ||
on_night() | ||
end | ||
end | ||
|
||
widget:buttons(awful.util.table.join(awful.button({}, 1, function() | ||
toggle() | ||
end))) | ||
|
||
return widget |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, given that these are white, I wonder how they work on a light theme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I just recolored them to white for myself, but not sure what is the usual approach, I found the gears.recolor_image which I never saw or used, or I could just include a "dark" and "light" version of the icons and have a config variable for it