Skip to content

Commit 41880bc

Browse files
committed
feat(waybar): unify wlsunset and wluma into nightlight toggle
Move the waybar toggle script from wlsunset module to waybar module, rename it to nightlight-toggle, and add wluma service start/stop.
1 parent 77c955c commit 41880bc

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

parts/features/desktop/wlsunset/_scripts/wlsunset-waybar.sh renamed to parts/features/desktop/waybar/_scripts/nightlight-toggle.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
# Toggles wlsunset (gamma) and wluma (brightness) together.
12
# Originally looted from https://github.com/CyrilSLi/linux-scripts
23
if pgrep -x wlsunset; then
34
killall -9 wlsunset
5+
systemctl --user stop wluma.service
46
else
57
RETRIES=30
68
counter=0
@@ -18,5 +20,6 @@ else
1820
longitude=$(echo "$CONTENT" | jq .lon)
1921
latitude=$(echo "$CONTENT" | jq .lat)
2022
wlsunset -l "$latitude" -L "$longitude" &
23+
systemctl --user start wluma.service
2124
fi
2225
pkill -35 waybar

parts/features/desktop/waybar/default.nix

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
runtimeInputs = [pkgs.dunst pkgs.gnugrep];
1717
text = builtins.readFile ./_scripts/dunst-dnd-toggle.sh;
1818
};
19+
nightlight-toggle = pkgs.writeShellApplication {
20+
name = "nightlight-toggle";
21+
runtimeInputs = with pkgs; [wlsunset procps killall systemd curl jq libnotify];
22+
text = builtins.readFile ./_scripts/nightlight-toggle.sh;
23+
};
1924
isNvidia = osConfig.dendrix.hasNvidia;
2025
isNumenor = osConfig.dendrix.hostname == "numenor";
2126
isFlexbox = osConfig.dendrix.hostname == "flexbox";
@@ -231,8 +236,8 @@
231236
"group/screens" = {
232237
modules =
233238
if isFlexbox
234-
then ["backlight" "custom/wlsunset"]
235-
else ["custom/ddc-backlight-left" "custom/ddc-backlight-middle" "custom/ddc-backlight-right" "custom/wlsunset"];
239+
then ["backlight" "custom/nightlight"]
240+
else ["custom/ddc-backlight-left" "custom/ddc-backlight-middle" "custom/ddc-backlight-right" "custom/nightlight"];
236241
orientation = "inherit";
237242
};
238243

@@ -289,13 +294,13 @@
289294
interval = 60;
290295
};
291296

292-
"custom/wlsunset" = {
297+
"custom/nightlight" = {
293298
interval = 1;
294299
exec = "if pgrep wlsunset >/dev/null 2>&1; then stdbuf -oL printf '{\"alt\": \"on\",\"class\": \"on\"}'; else stdbuf -oL printf '{\"alt\": \"off\",\"class\": \"off\"}'; fi";
295-
on-click = "wlsunset-waybar";
300+
on-click = "${nightlight-toggle}/bin/nightlight-toggle";
296301
return-type = "json";
297302
format = " {icon}";
298-
tooltip-format = "wlsunset: {alt}";
303+
tooltip-format = "wlsunset + wluma: {alt}";
299304
signal = 1; # SIGRTMIN+1 or 35 for updating immediately from script
300305
format-icons = {
301306
on = "";
@@ -570,7 +575,7 @@
570575
color: @base0B;
571576
}
572577
573-
#custom-wlsunset.off {
578+
#custom-nightlight.off {
574579
color: @base0A;
575580
}
576581
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
# Day/night gamma adjustments for Wayland
22
{...}: {
3-
flake.modules.homeManager.wlsunset = {pkgs, ...}: let
4-
# https://github.com/CyrilSLi/linux-scripts/blob/main/waybar/wlsunset.sh
5-
wlsunset-waybar = pkgs.writeShellApplication {
6-
name = "wlsunset-waybar";
7-
runtimeInputs = with pkgs; [wlsunset procps killall];
8-
text = builtins.readFile ./_scripts/wlsunset-waybar.sh;
9-
};
10-
in {
3+
flake.modules.homeManager.wlsunset = {pkgs, ...}: {
114
home.packages = [
125
pkgs.wlsunset
13-
wlsunset-waybar
146
];
157
};
168
}

0 commit comments

Comments
 (0)