diff options
author | Matt Singleton <matt@xcolour.net> | 2023-02-03 14:39:07 -0600 |
---|---|---|
committer | Matt Singleton <matt@xcolour.net> | 2023-02-03 14:39:07 -0600 |
commit | e9dc4c1090abb01317847c417b75d3960f3da34d (patch) | |
tree | 2fb84cf24675f1294f9f7a33ea949d514844c6f1 /bin/linux | |
parent | 969f76a8238e2d43a25740c8272bf635d436f0d3 (diff) |
only install platform-appropriate configs based on uname
Diffstat (limited to 'bin/linux')
-rwxr-xr-x | bin/linux/backup | 27 | ||||
-rwxr-xr-x | bin/linux/dmenu-wl | 5 | ||||
-rwxr-xr-x | bin/linux/dnf-needs-restarting | 26 | ||||
-rwxr-xr-x | bin/linux/setbright | 23 | ||||
-rwxr-xr-x | bin/linux/setvol | 23 |
5 files changed, 104 insertions, 0 deletions
diff --git a/bin/linux/backup b/bin/linux/backup new file mode 100755 index 0000000..75aded9 --- /dev/null +++ b/bin/linux/backup @@ -0,0 +1,27 @@ +#!/bin/bash + +set -euo pipefail + +set -o allexport +# shellcheck source=../local/duplicity-config +source ~/.config/duplicity/config +set +o allexport + +source_directory=~ +excludes=~/.config/duplicity/excludes +target_url=b2://"$B2_KEY_ID"@"$B2_BUCKET" + +# take a new full backup every month, incremental otherwise +duplicity --full-if-older-than 1M --exclude-filelist "$excludes" "$source_directory" "$target_url" + +# keep 12 months of full backups +duplicity remove-all-but-n-full 12 --force "$target_url" + +# keep 3 months of incremental backups +duplicity remove-all-inc-of-but-n-full 3 --force "$target_url" + +# cleanup +duplicity cleanup --force "$target_url" + +# show collection status +duplicity collection-status "$target_url" diff --git a/bin/linux/dmenu-wl b/bin/linux/dmenu-wl new file mode 100755 index 0000000..7ac2273 --- /dev/null +++ b/bin/linux/dmenu-wl @@ -0,0 +1,5 @@ +#!/bin/bash + +set -euo pipefail + +wofi -d "$@" diff --git a/bin/linux/dnf-needs-restarting b/bin/linux/dnf-needs-restarting new file mode 100755 index 0000000..60f7f7c --- /dev/null +++ b/bin/linux/dnf-needs-restarting @@ -0,0 +1,26 @@ +#!/bin/bash + +set -eo pipefail + +if command -v dnf > /dev/null; then + DNFCMD="dnf" +fi +if command -v jq > /dev/null; then + JQCMD="jq" +fi +if [ -z "$DNFCMD" ] || [ -z "$JQCMD" ]; then + echo "{\"tooltip\": \"requires 'jq' and 'dnf'\", \"text\": \"\"}" + exit 1 +fi + +set -u + +if ! output="$($DNFCMD needs-restarting -r)"; then + icon="勒" +else + icon="" +fi + +# this is a literal expression for `jq` +# shellcheck disable=SC2016 +$JQCMD --unbuffered -n -c '{tooltip: $ARGS.positional[0], text: $ARGS.positional[1]}' --args "$output" "$icon" diff --git a/bin/linux/setbright b/bin/linux/setbright new file mode 100755 index 0000000..42cd48f --- /dev/null +++ b/bin/linux/setbright @@ -0,0 +1,23 @@ +#!/bin/bash + +set -euo pipefail + +current=$(brightnessctl -m info | cut -d, -f4 | tr --delete '%') +case $1 in + up) + increment=$(( 5 - ( current % 5 ) )) + new=$(( current + increment )) + if [ $new -gt 100 ]; then + new=100 + fi + brightnessctl set $new% > /dev/null 2>&1 + echo $new;; + down) + increment=$(( ( ( current - 1 ) % 5 ) + 1 )) + new=$(( current - increment )) + if [ $new -lt 0 ]; then + new=0 + fi + brightnessctl set $new% > /dev/null 2>&1 + echo $new;; +esac diff --git a/bin/linux/setvol b/bin/linux/setvol new file mode 100755 index 0000000..bf9cbed --- /dev/null +++ b/bin/linux/setvol @@ -0,0 +1,23 @@ +#!/bin/bash + +set -euo pipefail + +current_volume=$(pactl get-sink-volume @DEFAULT_SINK@ | grep Volume | sed -e 's/.* \([0-9][0-9]*\)%.*/\1/') +case $1 in + up) + increment=$(( 5 - ( current_volume % 5 ) )) + newvol=$(( current_volume + increment )) + if [ $newvol -gt 100 ]; then + newvol=100 + fi + pactl set-sink-volume @DEFAULT_SINK@ $newvol% + echo $newvol;; + down) + increment=$(( ( ( current_volume - 1 ) % 5 ) + 1 )) + newvol=$(( current_volume - increment )) + if [ $newvol -lt 0 ]; then + newvol=0 + fi + pactl set-sink-volume @DEFAULT_SINK@ $newvol% + echo $newvol;; +esac |