From 4dbcc84076a815c2517afecbf739827458a5257d Mon Sep 17 00:00:00 2001 From: Kelly Roberts Date: Wed, 31 Aug 2022 09:30:15 -0700 Subject: [PATCH 01/10] add nightlight script and dmenublocks action --- .local/bin/nightlight | 12 ++++++++++++ .local/bin/statusbar/sb-battery | 1 + 2 files changed, 13 insertions(+) create mode 100755 .local/bin/nightlight diff --git a/.local/bin/nightlight b/.local/bin/nightlight new file mode 100755 index 00000000..0c48c561 --- /dev/null +++ b/.local/bin/nightlight @@ -0,0 +1,12 @@ +#!/bin/sh + +# toggle for a "nightlight" color temperature +# requires xsct + +colortemp="$(xsct | cut -d' ' -f5)" + +if [ "$colortemp" -ge "6500" ]; then + xsct 2700 && notify-send "🌙 Night Light On" +else + xsct 0 && notify-send "☀️ Night Light Off" +fi diff --git a/.local/bin/statusbar/sb-battery b/.local/bin/statusbar/sb-battery index 93cbe088..69b2f41c 100755 --- a/.local/bin/statusbar/sb-battery +++ b/.local/bin/statusbar/sb-battery @@ -4,6 +4,7 @@ # to charge status (🔌 for plugged up, 🔋 for discharging on battery, etc.). case $BLOCK_BUTTON in + 1) nightlight ;; 3) notify-send "🔋 Battery module" "🔋: discharging 🛑: not charging ♻: stagnant charge From c330624decd8a097b204e9da76529350d57f3ae5 Mon Sep 17 00:00:00 2001 From: Kelly Roberts <105584129+bubstance@users.noreply.github.com> Date: Thu, 1 Sep 2022 05:06:40 +0000 Subject: [PATCH 02/10] Update nightlight use `ifinstalled` to check for `xsct` --- .local/bin/nightlight | 1 + 1 file changed, 1 insertion(+) diff --git a/.local/bin/nightlight b/.local/bin/nightlight index 0c48c561..8684a7f5 100755 --- a/.local/bin/nightlight +++ b/.local/bin/nightlight @@ -3,6 +3,7 @@ # toggle for a "nightlight" color temperature # requires xsct +ifinstalled "xsct" || exit colortemp="$(xsct | cut -d' ' -f5)" if [ "$colortemp" -ge "6500" ]; then From c5bfdcba4ce1ee5f325baa8c1655833402aedc54 Mon Sep 17 00:00:00 2001 From: Kelly Roberts <105584129+bubstance@users.noreply.github.com> Date: Thu, 1 Sep 2022 07:55:22 +0000 Subject: [PATCH 03/10] added nightlight status indicator Based on feedback from @pineapples5972 in this comment: https://github.com/LukeSmithxyz/voidrice/pull/1181#issuecomment-1233816668 --- .local/bin/statusbar/sb-battery | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.local/bin/statusbar/sb-battery b/.local/bin/statusbar/sb-battery index 69b2f41c..89d5846f 100755 --- a/.local/bin/statusbar/sb-battery +++ b/.local/bin/statusbar/sb-battery @@ -33,6 +33,9 @@ for battery in /sys/class/power_supply/BAT?*; do capacity="$(cat "$battery/capacity" 2>&1)" # Will make a warn variable if discharging and low [ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗" + # Show nightlight status + colortemp="$(xsct | cut -d' ' -f5)" + [ "$colortemp" -lt 6500 ] && night=" 🌙" # Prints the info - printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn + printf "%s%s%d%%%s" "$status" "$warn" "$capacity" "$night"; unset warn done && printf "\\n" From cee6be015203f7fd42078f48c3f1dc4a6ddc902a Mon Sep 17 00:00:00 2001 From: Kelly Roberts Date: Thu, 1 Sep 2022 09:00:23 -0700 Subject: [PATCH 04/10] better version with transition --- .local/bin/nightlight | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.local/bin/nightlight b/.local/bin/nightlight index 8684a7f5..a324d07a 100755 --- a/.local/bin/nightlight +++ b/.local/bin/nightlight @@ -1,13 +1,18 @@ #!/bin/sh -# toggle for a "nightlight" color temperature # requires xsct +# toggle for a "nightlight" color temperature +# edit value of settemp to your desired color temperature (minimum is 700) ifinstalled "xsct" || exit + +settemp="2700" colortemp="$(xsct | cut -d' ' -f5)" if [ "$colortemp" -ge "6500" ]; then - xsct 2700 && notify-send "🌙 Night Light On" + notify-send "🌙 Night Light Enabled (${settemp}K)" + for i in $(seq 6500 -100 ${settemp}); do xsct $i; sleep 0.1; done else - xsct 0 && notify-send "☀️ Night Light Off" + notify-send "☀️ Night Light Disabled" + for i in $(seq ${settemp} 100 6500); do xsct $i; sleep 0.1; done fi From 3cb3edf5e9bad0e77c0f0fee88d752b2366a925b Mon Sep 17 00:00:00 2001 From: Kelly Roberts Date: Thu, 1 Sep 2022 09:24:37 -0700 Subject: [PATCH 05/10] speed up transition --- .local/bin/nightlight | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.local/bin/nightlight b/.local/bin/nightlight index a324d07a..8b4a65c4 100755 --- a/.local/bin/nightlight +++ b/.local/bin/nightlight @@ -11,8 +11,8 @@ colortemp="$(xsct | cut -d' ' -f5)" if [ "$colortemp" -ge "6500" ]; then notify-send "🌙 Night Light Enabled (${settemp}K)" - for i in $(seq 6500 -100 ${settemp}); do xsct $i; sleep 0.1; done + for i in $(seq 6500 -100 ${settemp}); do xsct $i; sleep 0.05; done else notify-send "☀️ Night Light Disabled" - for i in $(seq ${settemp} 100 6500); do xsct $i; sleep 0.1; done + for i in $(seq ${settemp} 100 6500); do xsct $i; sleep 0.05; done fi From da0d2e38530141869585e5e061597f0e9bd551c7 Mon Sep 17 00:00:00 2001 From: Kelly Roberts <105584129+bubstance@users.noreply.github.com> Date: Fri, 2 Sep 2022 04:23:35 +0000 Subject: [PATCH 06/10] remove ifinstalled Allows for use with cron for timed nightlight --- .local/bin/nightlight | 2 -- 1 file changed, 2 deletions(-) diff --git a/.local/bin/nightlight b/.local/bin/nightlight index 8b4a65c4..6d4907fb 100755 --- a/.local/bin/nightlight +++ b/.local/bin/nightlight @@ -4,8 +4,6 @@ # toggle for a "nightlight" color temperature # edit value of settemp to your desired color temperature (minimum is 700) -ifinstalled "xsct" || exit - settemp="2700" colortemp="$(xsct | cut -d' ' -f5)" From 106b5c345cd5b74d394c10cf1c520e67caeec6c7 Mon Sep 17 00:00:00 2001 From: Kelly Roberts Date: Sat, 3 Sep 2022 11:15:47 -0700 Subject: [PATCH 07/10] fixed issue with multiple moons (me dumb) --- .local/bin/statusbar/sb-battery | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.local/bin/statusbar/sb-battery b/.local/bin/statusbar/sb-battery index 89d5846f..d9be3a98 100755 --- a/.local/bin/statusbar/sb-battery +++ b/.local/bin/statusbar/sb-battery @@ -38,4 +38,4 @@ for battery in /sys/class/power_supply/BAT?*; do [ "$colortemp" -lt 6500 ] && night=" 🌙" # Prints the info printf "%s%s%d%%%s" "$status" "$warn" "$capacity" "$night"; unset warn -done && printf "\\n" +done && printf "$night" "\\n" From 46ae4084c5d4eb133ee1014cccd92ad0a3031751 Mon Sep 17 00:00:00 2001 From: Kelly Roberts <105584129+bubstance@users.noreply.github.com> Date: Sat, 3 Sep 2022 18:21:29 +0000 Subject: [PATCH 08/10] didn't actually remove problem whoops --- .local/bin/statusbar/sb-battery | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.local/bin/statusbar/sb-battery b/.local/bin/statusbar/sb-battery index d9be3a98..8f06af7a 100755 --- a/.local/bin/statusbar/sb-battery +++ b/.local/bin/statusbar/sb-battery @@ -37,5 +37,5 @@ for battery in /sys/class/power_supply/BAT?*; do colortemp="$(xsct | cut -d' ' -f5)" [ "$colortemp" -lt 6500 ] && night=" 🌙" # Prints the info - printf "%s%s%d%%%s" "$status" "$warn" "$capacity" "$night"; unset warn + printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn done && printf "$night" "\\n" From 8b882b679b44dd2e73888b7056cf253cb5289557 Mon Sep 17 00:00:00 2001 From: Kelly Roberts <105584129+bubstance@users.noreply.github.com> Date: Thu, 29 Sep 2022 04:04:52 +0000 Subject: [PATCH 09/10] Added Night Light description to notification --- .local/bin/statusbar/sb-battery | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.local/bin/statusbar/sb-battery b/.local/bin/statusbar/sb-battery index 8f06af7a..44355f43 100755 --- a/.local/bin/statusbar/sb-battery +++ b/.local/bin/statusbar/sb-battery @@ -11,7 +11,9 @@ case $BLOCK_BUTTON in 🔌: charging ⚡: charged ❗: battery very low! -- Scroll to change adjust xbacklight." ;; +🌙: Night Light enabled +- Scroll to change adjust xbacklight. +- Left click to activate Night Light." ;; 4) xbacklight -inc 10 ;; 5) xbacklight -dec 10 ;; 6) "$TERMINAL" -e "$EDITOR" "$0" ;; From e0c472932f3173f0cd02750c80f26463f8191ddd Mon Sep 17 00:00:00 2001 From: Kelly Roberts <105584129+bubstance@users.noreply.github.com> Date: Thu, 29 Sep 2022 04:12:06 +0000 Subject: [PATCH 10/10] Changed wording to just "click" --- .local/bin/statusbar/sb-battery | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.local/bin/statusbar/sb-battery b/.local/bin/statusbar/sb-battery index 44355f43..ffb9a894 100755 --- a/.local/bin/statusbar/sb-battery +++ b/.local/bin/statusbar/sb-battery @@ -13,7 +13,7 @@ case $BLOCK_BUTTON in ❗: battery very low! 🌙: Night Light enabled - Scroll to change adjust xbacklight. -- Left click to activate Night Light." ;; +- Click to activate Night Light." ;; 4) xbacklight -inc 10 ;; 5) xbacklight -dec 10 ;; 6) "$TERMINAL" -e "$EDITOR" "$0" ;;