From 5f19f3f2040c5df46e4ca9e8985e77fe5f4a5ed6 Mon Sep 17 00:00:00 2001 From: Penelope Gwen Date: Sat, 10 Aug 2024 01:15:01 -0700 Subject: [PATCH] New backup 2024-08-10 01:15:01 --- .../sway/scripts/kb_brightness.d/328p1aa | 21 ++++++++++++ 328p1aa/include | 1 + de/exclude | 1 + de/home/.config/sway/config.d/keys_special | 10 ++++++ de/home/.config/sway/scripts/kb_brightness | 32 +++++++++++++++++++ 5 files changed, 65 insertions(+) create mode 100755 328p1aa/home/.config/sway/scripts/kb_brightness.d/328p1aa create mode 100755 de/home/.config/sway/scripts/kb_brightness diff --git a/328p1aa/home/.config/sway/scripts/kb_brightness.d/328p1aa b/328p1aa/home/.config/sway/scripts/kb_brightness.d/328p1aa new file mode 100755 index 0000000..511a827 --- /dev/null +++ b/328p1aa/home/.config/sway/scripts/kb_brightness.d/328p1aa @@ -0,0 +1,21 @@ +#!/bin/bash + +calc_newval(){ + printf "%02x\n" $( echo "${1}*${2}*0.01" | bc | sed s/\\.[0-9]*// ) +} + +brightness="$1" + +max_r=$(printf "%d\n" 0xff) +max_g=$(printf "%d\n" 0x00) +max_b=$(printf "%d\n" 0xee) + +#calc_newval ${max_r} ${brightness} + +#exit + +calc_r=$( calc_newval ${max_r} ${brightness} ) +calc_g=$( calc_newval ${max_g} ${brightness} ) +calc_b=$( calc_newval ${max_b} ${brightness} ) + +g213-led -a "${calc_r}${calc_g}${calc_b}" diff --git a/328p1aa/include b/328p1aa/include index 5d8f6c6..cfba655 100644 --- a/328p1aa/include +++ b/328p1aa/include @@ -9,3 +9,4 @@ .config/sway-profiles/unlockscript.d/328p1aa .config/sway-profiles/lockscript.d/328p1aa .config/sway/config.d/autostart.d/328p1aa +.config/sway/scripts/kb_brightness.d/328p1aa diff --git a/de/exclude b/de/exclude index c9f91e9..c12ee2a 100644 --- a/de/exclude +++ b/de/exclude @@ -13,3 +13,4 @@ .config/sway/config.d/autostart.d .config/sway/workspace_test .config/sway/workspace_test_tree.json +.config/sway/scripts/kb_brightness.d diff --git a/de/home/.config/sway/config.d/keys_special b/de/home/.config/sway/config.d/keys_special index 48b6065..f25d4c0 100644 --- a/de/home/.config/sway/config.d/keys_special +++ b/de/home/.config/sway/config.d/keys_special @@ -35,5 +35,15 @@ # Brightness Down bindsym XF86MonBrightnessDown exec "$HOME/.config/sway/scripts/brightness.sh down" +# +# Keyboard Brightness +# + +# Brightness Up + bindsym shift+XF86AudioRaiseVolume exec "$HOME/.config/sway/scripts/kb_brightness up" +# Brightness Down + bindsym shift+XF86AudioLowerVolume exec "$HOME/.config/sway/scripts/kb_brightness down" + + # Numlock input * xkb_numlock enabled diff --git a/de/home/.config/sway/scripts/kb_brightness b/de/home/.config/sway/scripts/kb_brightness new file mode 100755 index 0000000..b0cbb8e --- /dev/null +++ b/de/home/.config/sway/scripts/kb_brightness @@ -0,0 +1,32 @@ +#!/bin/bash + +operation="${1}" +cache_dir="${HOME}/.cache/sway-profiles" +cache_file="${cache_dir}/kb_brightness" +mkdir -p "${cache_dir}" + +if [[ ! -f "${cache_file}" ]];then + echo "100" > "${cache_file}" +fi + +kb_brightness=$( cat "${cache_file}" ) + +case "$operation" in + up) + kb_brightness="$((${kb_brightness}+5))" + [[ ${kb_brightness} -gt 100 ]] && kb_brightness="100" + ;;& + down) + kb_brightness="$((${kb_brightness}-5))" + [[ ${kb_brightness} -lt 0 ]] && kb_brightness="0" + ;;& + up|down) + echo "${kb_brightness}" > "${cache_file}" +# light_lvl="$(brightnessctl set ${brighness_change} | sed -En 's/.*\(([0-9]+)%\).*/\1/p')" +# echo "${light_lvl}" "${de_color_0}${opacity}" "${de_color_1}${opacity}" "${de_color_3}${opacity}" > "$WOBSOCK" + echo "${kb_brightness}" + for s in ~/.config/sway/scripts/kb_brightness.d/*;do + bash -c "${s} ${kb_brightness}" + done +# ;; +esac