commit 7643b11a6548cd50a13eb5ead3f237f3c2b94972 Spenser Truex <truex@equwal.com> 2025-09-05 16:24:57 -0700 Add new X11 utils
README.md | 4 ++++ dintel-backlight | 8 +++++--- dkeymap | 5 +++++ intel-backlight | 41 +++++++++++++++++++++++++++++++++++++++++ prompt-mail | 2 +- 5 files changed, 56 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md index f8a2794..d87c389 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ with that. - `dbc`: do `bc -l` on the input so you can do math - `dbrowsel`: select a browser for the link in the clipboard to open - `dcpupower`: select CPU throttling settings +- `dkeymap`: select a keymap +- `dintelbacklight`: select backlight with dmenu or wjt (a scroll wheel) - `ddmenu`: use dmenu to select a dmenu script -- dception - `dmenu_run/dsudo`: run programs, maybe from a keybind set with xbindkeys or a wm - `dmenupass`: ask for the sudo password as SUDO_ASKPASS @@ -45,3 +47,5 @@ but it won't come up in dmenu_run. So move `program` to `program-aux` and make a SUDO_ASKPASS=dgivepass sudo -A program ``` +## Utilities +- ``intel-backlight``: uninformativ.de's intel-backlight script diff --git a/dintel-backlight b/dintel-backlight index 644181a..bf8ee64 100755 --- a/dintel-backlight +++ b/dintel-backlight @@ -1,5 +1,7 @@ #!/bin/sh -# uses uninformativ.de's intel-backlight script - -intel-backlight $(echo "up\ndown\nmin\nmax\noff" | dmenu -p 'intel-backlight command:') +SELECTOR="$(which wjt)" # a sliding bar that resembles dmenu, 0-100 +SELECTOR=${SELECTOR:- $(which dmenu)} +OUT="$(echo "up\ndown\nmin\nmax\noff" | "$SELECTOR" -p 'intel-backlight command:')" +[ -z "$OUT" ] && OUT=0 # hack for wjt no output if not touched +"$HOME"/src/sh/intel-backlight "$OUT" diff --git a/dkeymap b/dkeymap new file mode 100755 index 0000000..6cd8230 --- /dev/null +++ b/dkeymap @@ -0,0 +1,5 @@ +#!/bin/sh + +KEYMAPS="/usr/share/keymaps/" +setxkbmap "$(find "$KEYMAPS" -name '*.map.gz' | sed 's/.*\///' | sed 's/.map.gz$//' | sed 's/-.*//' | sort | uniq | dmenu -p "keymap")" \ + "$@" diff --git a/intel-backlight b/intel-backlight new file mode 100755 index 0000000..118ea5a --- /dev/null +++ b/intel-backlight @@ -0,0 +1,41 @@ +#!/bin/bash + +if [[ "$EUID" != 0 ]] +then + echo "$0 must be run as root" >&2 + exit 1 +fi + +[ -z "$1" ] && echo "No argument." && exit 1 + +[[ ! -d /sys/class/backlight/intel_backlight ]] && exit + +current=$(< /sys/class/backlight/intel_backlight/brightness) +max=$(< /sys/class/backlight/intel_backlight/max_brightness) +min=$((max / 50)) +step=$((max / 10)) + +if expr "$1" + 0 >/dev/null 2>&1; then #hack! Is a number? + current=$(( ( ($1 * max) / 100 ) < min ? min : ( ($1 * max) / 100 ) )) + #echo $max $current $min +else + case $1 in + up) ((current+=step)) ;; + down) ((current-=step)) ;; + min) current=$min ;; + max) current=$max ;; + off) current=0 ;; + ?) exit ;; + esac +fi + + +if (( current < min )) && [[ $1 != off ]] +then + current=$min +elif (( current > max )) +then + current=$max +fi + +echo $current >/sys/class/backlight/intel_backlight/brightness diff --git a/prompt-mail b/prompt-mail index 9d7bccc..4474668 160000 --- a/prompt-mail +++ b/prompt-mail @@ -1 +1 @@ -Subproject commit 9d7bccc6b373f94ebfd6f758a628bf233e57e8d9 +Subproject commit 44746683ca69f7db560caac38ca7ff5270bc5275