diff options
| author | ivan-boikov <ik.boikov.public@protonmail.com> | 2023-12-16 15:46:32 +0100 |
|---|---|---|
| committer | ivan-boikov <ik.boikov.public@protonmail.com> | 2023-12-16 15:46:32 +0100 |
| commit | 5704b58fa885e9b3bdb3dc306e584d84d534d720 (patch) | |
| tree | 8f9333a5cea5bdd72c6a111e78392cc7092b41d2 /scripts/.local/bin | |
| parent | d9ec3ac7aa8450fe38f287fdf8781a99538a9f92 (diff) | |
1
Diffstat (limited to 'scripts/.local/bin')
| -rwxr-xr-x | scripts/.local/bin/dcpug | 17 | ||||
| -rwxr-xr-x | scripts/.local/bin/notify | 7 | ||||
| -rwxr-xr-x | scripts/.local/bin/selector | 20 |
3 files changed, 30 insertions, 14 deletions
diff --git a/scripts/.local/bin/dcpug b/scripts/.local/bin/dcpug index 2392676..9da9e4a 100755 --- a/scripts/.local/bin/dcpug +++ b/scripts/.local/bin/dcpug @@ -1,16 +1,5 @@ #!/bin/sh -dmenu="$(command -v cdmenu)" -if [ -z "$dmenu" ]; then - dmenu="dmenu" -fi - -profiles="$(sed 's/ /\\n/g' /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)" - -profile=$(echo "$profiles" | $dmenu) - -sudo -A cpupower frequency-set --governor "$profile" -# repeat, for good measure -sudo -A cpupower frequency-set --governor "$profile" - -notify-send "Set CPU profile: $profile" +profile="$(sed 's/ /\n/g' /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors | sed '/^$/d' | selector "Select a CPU governor")" +sudo cpupower frequency-set --governor "$profile" +notify "Set CPU profile: $profile" diff --git a/scripts/.local/bin/notify b/scripts/.local/bin/notify new file mode 100755 index 0000000..8807098 --- /dev/null +++ b/scripts/.local/bin/notify @@ -0,0 +1,7 @@ +#!/bin/bash + +if ! xset q &>/dev/null; then + echo "$1" +else + notify-send "$1" +fi diff --git a/scripts/.local/bin/selector b/scripts/.local/bin/selector new file mode 100755 index 0000000..cccd0a1 --- /dev/null +++ b/scripts/.local/bin/selector @@ -0,0 +1,20 @@ +#!/bin/bash + +if [ -z "$DISPLAY" ]; then + # if not running X11 -- bash prompt + readarray -t items + # display prompt text in stderr to not mix with selection output + >&2 echo "$1" + select item in "${items[@]}"; do + echo ${item}; + break + done < /dev/tty +else + # X11 prompt with (possibly colored) dmenu + dmenu="$(command -v cdmenu)" + if [ -z "$dmenu" ]; then + dmenu="dmenu" + fi + + cat | $dmenu -p "$1" +fi |
