From 4773bdae8719b2d126680711d3bdbca80c79182c Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 29 Aug 2023 16:14:11 -0400 Subject: [PATCH] Screen brightness script added. --- README.md | 1 + i38.sh | 4 ++++ scripts/screen_controller.sh | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100755 scripts/screen_controller.sh diff --git a/README.md b/README.md index ac9a59f..443e26f 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ An uppercase I looks like a 1, 3 from i3, and 8 because the song [We Are 138](ht - transfersh: [optional] for file sharing GUI - udiskie: [optional] for automatically mounting removable storage - xclip: Clipboard support +- xbacklight: [optional] for screen brightness adjustment - yad: For screen reader accessible dialogs I38 will try to detect your browser, file manager, and web browser and present you with a list of options to bind to their launch keys. It will also create bindings for pidgin and mumble if they are installed. To use the bindings, press your ratpoison mode key which is set when you run the i38.sh script. next, press the binding for the application you want, w for web browser, e for text editor, f for file manager, m for mumble, etc. To learn all the bindings, find and read the mode ratpoison section of ~/.config/i3/config. diff --git a/i38.sh b/i38.sh index 1cf81e5..d1cb0fb 100755 --- a/i38.sh +++ b/i38.sh @@ -415,6 +415,10 @@ $(if command -v pidgin &> /dev/null ; then echo "# p bound to pidgin" echo "bindsym p exec $(command -v pidgin), mode \"default\"" fi) +$(if command -v xrandr &> /dev/null ; then + echo "# alt+s bound to brightness control" + echo "bindsym \$mod+s exec --no-startup-id ${i3Path}/scripts/screen_controller.sh" +fi) $(if command -v transfersh &> /dev/null ; then echo "# t bound to share file with transfer.sh" echo 'bindsym t exec bash -c '"'"'fileName="$(yad --title "I38 Upload File" --file)" && url="$(transfersh "${fileName}" | tee >(yad --title "I38 - Uploading ${fileName##*/} ..." --progress --pulsate --auto-close))" && echo "${url#*saved at: }" | tee >(yad --title "I38 - Upload URL" --show-cursor --show-uri --button yad-close --sticky --text-info) >(xclip -selection clipboard)'"', mode \"default\"" diff --git a/scripts/screen_controller.sh b/scripts/screen_controller.sh new file mode 100755 index 0000000..9b09196 --- /dev/null +++ b/scripts/screen_controller.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Not for multiple screens. +# Get the name of the screen. +screenName="$(xrandr --query | grep "connected" | cut -d ' ' -f1 | head -n 1)" + +menuOptions=( + "1.0" "Maximum Brightness" + "0.75" "75 percent" + "0.5" "50 percent" + "0.25" "25 percent" + "0" "Screen Curtain" +) + +brightness="$(yad --list --title "I38" --text "Set Screen Brightness" --columns 2 --hide-column 1 --column "" --column "Select" "${menuOptions[@]}")" + +if [[ ${#brightness} -lt 1 ]]; then + exit 0 +fi + +xrandr --output ${screenName} --brightness ${brightness%%|*} && + spd-say -P important -Cw "Screen set to ${brightness##*|}." + +exit 0