diff options
Diffstat (limited to 'scripts/cli')
| -rwxr-xr-x | scripts/cli/noc | 7 | ||||
| -rwxr-xr-x | scripts/cli/nospac | 23 | ||||
| -rwxr-xr-x | scripts/cli/sdev | 80 | ||||
| -rwxr-xr-x | scripts/cli/slight | 48 | ||||
| -rwxr-xr-x | scripts/cli/sroll | 5 | ||||
| -rwxr-xr-x | scripts/cli/svol | 50 |
6 files changed, 213 insertions, 0 deletions
diff --git a/scripts/cli/noc b/scripts/cli/noc new file mode 100755 index 0000000..575566c --- /dev/null +++ b/scripts/cli/noc @@ -0,0 +1,7 @@ +#!/bin/sh + +# Remove empty lines and all the comments starting with "#" + +for file in "${@}"; do + sed -i "s/\s*#.*//g; /^$/ d" "${file}" +done diff --git a/scripts/cli/nospac b/scripts/cli/nospac new file mode 100755 index 0000000..6ba466a --- /dev/null +++ b/scripts/cli/nospac @@ -0,0 +1,23 @@ +#!/bin/sh + +help() { +cat << EOF +${0}: Replace all the spaces in file and directory +names with "_" in in the current directory. +options: + -h Print this message and exit +EOF +} + +if [ ${#} -gt 0 ]; then + [ ${#} = 1 ] && [ "${1}" = "-h" ] && help && exit 0 + printf "%s: Invalid usage\nTry '%s -h' for help.\n" "${0}" "${0}" + exit 1 +fi + +for file in ./*; do + newfile=$(echo "${file}" | tr ' ' '_') + [ "${newfile}" != "${file}" ] && mv -v "${file}" "${newfile}" +done + +exit 0 diff --git a/scripts/cli/sdev b/scripts/cli/sdev new file mode 100755 index 0000000..c227771 --- /dev/null +++ b/scripts/cli/sdev @@ -0,0 +1,80 @@ +#!/bin/sh + +. slib + +help() { +cat << EOF +${0}: Disable and Enable devices +options: + -e [dev] Enable dev + -d [dev] Disable dev + -t [dev] Toggle dev + -l List devices + -h Print this message and exit + +Note: Nondescriptive inputs may disable/enable unwanted devices. +EOF + +exit 0 +} + +get_id() { + if ! dev=$(xinput list --name-only | grep -i -m1 "${1}" ); then + err "Couldn't get device" + fi + id="${dev#∼ }" +} + +xenable() { + echo "${id}" + + if ! xinput enable "${1}" > /dev/null 2>&1; then + err "Failed to enable dev." + else + exit 0 + fi +} + +xdisable() { + echo "${id}" + + if ! xinput disable "${1}" > /dev/null 2>&1; then + err "Failed to disable dev." + else + exit 0 + fi +} + +check_program "xinput" + +while getopts "e:d:t:lh" option; do + case "${option}" in + e) + get_id "${OPTARG}" + xenable "${id}" + ;; + d) + get_id "${OPTARG}" + xdisable "${id}" + ;; + t) + get_id "${OPTARG}" + + [ "${id}" = "${dev}" ] && xdisable "${id}" + xenable "${id}" + ;; + l) + if ! xinput list 2>/dev/null; then + err "Listing Failed" + else + exit 0 + fi + ;; + h) help ;; + + *) invalid_use -h ;; + + esac +done + +invalid_use diff --git a/scripts/cli/slight b/scripts/cli/slight new file mode 100755 index 0000000..0289ff4 --- /dev/null +++ b/scripts/cli/slight @@ -0,0 +1,48 @@ +#!/bin/sh + +. slib + +help() { +cat << EOF +${0}: Wrapper script to change backlight +options: + -i [Brg] Increase backlight by Brg + -d [Brg] Decrease backlight by Brg + -s [Brg] Set backlight to Brg + -p Show the current backlight + -h Print this message and exit + +NOTE: Script interprets values as percentages +EOF + +exit 0 +} + +check_program "brightnessctl" + +[ ${#} != 1 ] && [ ${#} != 2 ] && invalid_use + +while getopts "i:d:s:ph" option; do + case "${option}" in + i) run --reload-status "brightnessctl set +${OPTARG}%" ;; + + d) run --reload-status "brightnessctl set ${OPTARG}-%" ;; + + s) run --reload-status "brightnessctl set ${OPTARG}%" ;; + + p) + if ! echo $(( ($(brightnessctl g) * 100) / $(brightnessctl m) )); then + err "Failed to get current brightness" + else + exit 0 + fi + ;; + h) help ;; + + *) invalid_use -h ;; + + esac +done + +# Unreachable +invalid_use diff --git a/scripts/cli/sroll b/scripts/cli/sroll new file mode 100755 index 0000000..e0c8b70 --- /dev/null +++ b/scripts/cli/sroll @@ -0,0 +1,5 @@ +#!/bin/sh + +# Rickroll on terminal + +curl -s -L https://raw.githubusercontent.com/keroserene/rickrollrc/master/roll.sh | bash diff --git a/scripts/cli/svol b/scripts/cli/svol new file mode 100755 index 0000000..ec60450 --- /dev/null +++ b/scripts/cli/svol @@ -0,0 +1,50 @@ +#!/bin/sh + +. slib + +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 + +exit 0 +} + +check_program "pactl" "pulseaudio must be installed" + +[ $# != 1 ] && [ $# != 2 ] && invalid_use + +while getopts "i:d:s:pth" option; do + case "${option}" in + i) run --reload-status "pactl set-sink-volume @DEFAULT_SINK@ +${OPTARG}%" ;; + + d) run --reload-status "pactl set-sink-volume @DEFAULT_SINK@ -${OPTARG}%" ;; + + s) run --reload-status "pactl set-sink-volume @DEFAULT_SINK@ ${OPTARG}%" ;; + + t) run --reload-status "pactl set-sink-mute @DEFAULT_SINK@ toggle" ;; + + p) + if ! pactl get-sink-volume @DEFAULT_SINK@ \ + | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' | head -n1 2>/dev/null; then + err "Failed to get current volume" + else + exit 0 + fi + ;; + h) help ;; + + *) invalid_use -h ;; + + esac +done + +# Unreachable +invalid_use |
