From 9f60a2b5ec9ae08d846bc7d3b61612aacadf82c8 Mon Sep 17 00:00:00 2001 From: Suleyman Farajli Date: Wed, 24 Jul 2024 21:12:09 +0400 Subject: Wallpaper and volume scrips were renamed --- scripts/setvol | 62 ---------------------------------------------------------- scripts/setwp | 56 ---------------------------------------------------- scripts/svol | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/swall | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 119 insertions(+), 118 deletions(-) delete mode 100755 scripts/setvol delete mode 100755 scripts/setwp create mode 100755 scripts/svol create mode 100755 scripts/swall (limited to 'scripts') diff --git a/scripts/setvol b/scripts/setvol deleted file mode 100755 index 4bbc1ec..0000000 --- a/scripts/setvol +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh - -err() { - printf "${1} \n" - exit 1 -} - -help() { -cat << EOF -$0: Wrapper script to change volume - -options: - -i [Vol] Increase volume by Vol - -d [Vol] Decrease volume by Vol - -s [Vol] Set volume to Vol - -p Show the current volume - -t Toggle between mute and unmute - -h Print this message and exit -EOF -} - -if [ $# != 1 ] && [ $# != 2 ]; then - err "${0}: Invalid usage\nTry \'$0 -h\' for help." -fi - -while getopts "i:d:s:pth" option; do - case "${option}" in - i) - pactl set-sink-volume @DEFAULT_SINK@ +"${OPTARG}"% \ - > /dev/null 2>&1 && exit 0 \ - || err "${0}: Failed to increase" - ;; - d) - pactl set-sink-volume @DEFAULT_SINK@ -"${OPTARG}"% \ - > /dev/null 2>&1 && exit 0 \ - || err "${0}: Failed to decrease" - ;; - s) - pactl set-sink-volume @DEFAULT_SINK@ "${OPTARG}"% \ - > /dev/null 2>&1 && exit 0 \ - || err "${0}: Failed to set" - ;; - p) - pactl get-sink-volume @DEFAULT_SINK@ 2>/dev/null\ - || err "${0}: Failed" - ;; - t) - pactl set-sink-volume @DEFAULT_SINK@ toggle \ - > /dev/null 2>&1 && exit 0 \ - || err "${0}: Failed to toggle" - ;; - h) - help - exit 0 - ;; - *) - err "Try \'${0} -h\' for help" - - ;; - - esac -done diff --git a/scripts/setwp b/scripts/setwp deleted file mode 100755 index 24994d8..0000000 --- a/scripts/setwp +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh - -err() { - echo "${0}": "${1}" - exit 1 -} - - -help() { -cat << EOF -$0: Wrapper script to set wallpapers - -options: - -d [File] Select a wallpaper or a directory - -h Print this message and exit - -c Remove the current wallpaper - -NOTE: default wallpaper directory is ~/.config/wallpapers -EOF -} - -waldir="${XDG_CONFIG_HOME:-$HOME}/.config/wallpapers" - -while getopts "hcd:" option; do - case "${option}" in - h) - help - exit 0 - ;; - c) - xwallpaper --clear > /dev/null 2>&1 \ - || err "Couldn't clear wallpaper" - exit 0 - ;; - d) buf="${OPTARG}" ;; - *) err 'add -h for help' ;; - esac -done - - -if [ -n "${buf}" ]; then - case $(file -b --mime-type "${buf}") in - image/*) image="${buf}" ;; - inode/directory) waldir="${buf}" ;; - *) err "Couldn't read given file" ;; - esac -fi - -if [ -z "${image}" ]; then - image=$(find "${waldir}" -iregex '.*\.jpeg\|.*\.jpng\|.*\.png' 2>/dev/null \ - | shuf -n 1 2>/dev/null) -fi - -xwallpaper --zoom "${image}" > /dev/null 2>&1 || err "Couldn't set wallpaper" - -echo "${image}" diff --git a/scripts/svol b/scripts/svol new file mode 100755 index 0000000..f973773 --- /dev/null +++ b/scripts/svol @@ -0,0 +1,61 @@ +#!/bin/sh + +err() { + printf "${1} \n" + exit 1 +} + +help() { +cat << EOF +$0: Wrapper script to change volume + +options: + -i [Vol] Increase volume by Vol + -d [Vol] Decrease volume by Vol + -s [Vol] Set volume to Vol + -p Show the current volume + -t Toggle between mute and unmute + -h Print this message and exit +EOF +} + +if [ $# != 1 ] && [ $# != 2 ]; then + err "${0}: Invalid usage\nTry \'$0 -h\' for help." +fi + +while getopts "i:d:s:pth" option; do + case "${option}" in + i) + pactl set-sink-volume @DEFAULT_SINK@ +"${OPTARG}"% \ + > /dev/null 2>&1 && exit 0 \ + || err "${0}: Failed to increase" + ;; + d) + pactl set-sink-volume @DEFAULT_SINK@ -"${OPTARG}"% \ + > /dev/null 2>&1 && exit 0 \ + || err "${0}: Failed to decrease" + ;; + s) + pactl set-sink-volume @DEFAULT_SINK@ "${OPTARG}"% \ + > /dev/null 2>&1 && exit 0 \ + || err "${0}: Failed to set" + ;; + p) + pactl get-sink-volume @DEFAULT_SINK@ 2>/dev/null\ + || err "${0}: Failed" + ;; + t) + pactl set-sink-volume @DEFAULT_SINK@ toggle \ + > /dev/null 2>&1 && exit 0 \ + || err "${0}: Failed to toggle" + ;; + h) + help + exit 0 + ;; + *) + err "Try \'${0} -h\' for help" + ;; + + esac +done diff --git a/scripts/swall b/scripts/swall new file mode 100755 index 0000000..6d3b854 --- /dev/null +++ b/scripts/swall @@ -0,0 +1,58 @@ +#!/bin/sh + +# TODO add the option error checking with optind + +err() { + echo "${0}": "${1}" + exit 1 +} + + +help() { +cat << EOF +$0: Wrapper script to set wallpapers + +options: + -d [File] Select a wallpaper or a directory + -h Print this message and exit + -c Remove the current wallpaper + +NOTE: default wallpaper directory is ~/.config/wallpapers +EOF +} + +waldir="${XDG_CONFIG_HOME:-$HOME}/.config/wallpapers" + +while getopts "hcd:" option; do + case "${option}" in + h) + help + exit 0 + ;; + c) + xwallpaper --clear > /dev/null 2>&1 \ + || err "Couldn't clear wallpaper" + exit 0 + ;; + d) buf="${OPTARG}" ;; + *) err 'add -h for help' ;; + esac +done + + +if [ -n "${buf}" ]; then + case $(file -b --mime-type "${buf}") in + image/*) image="${buf}" ;; + inode/directory) waldir="${buf}" ;; + *) err "Couldn't read given file" ;; + esac +fi + +if [ -z "${image}" ]; then + image=$(find "${waldir}" -iregex '.*\.jpeg\|.*\.jpng\|.*\.png' 2>/dev/null \ + | shuf -n 1 2>/dev/null) +fi + +xwallpaper --zoom "${image}" > /dev/null 2>&1 || err "Couldn't set wallpaper" + +echo "${image}" -- cgit v1.2.3