From cb78290f31886fb1f9a5e7c2a764dda55a459e50 Mon Sep 17 00:00:00 2001 From: Suleyman Farajli Date: Sun, 26 Oct 2025 22:23:31 +0400 Subject: chore: split script installation into CLI and GUI sections --- scripts/br | 42 ---------------------------- scripts/cli/noc | 7 +++++ scripts/cli/nospac | 23 ++++++++++++++++ scripts/cli/sdev | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/cli/slight | 48 ++++++++++++++++++++++++++++++++ scripts/cli/sroll | 5 ++++ scripts/cli/svol | 50 ++++++++++++++++++++++++++++++++++ scripts/gui/br | 42 ++++++++++++++++++++++++++++ scripts/gui/nsend | 32 ++++++++++++++++++++++ scripts/gui/qw | 41 ++++++++++++++++++++++++++++ scripts/gui/shot | 56 ++++++++++++++++++++++++++++++++++++++ scripts/gui/swall | 68 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/mus | 7 ----- scripts/noc | 7 ----- scripts/nospac | 23 ---------------- scripts/nsend | 32 ---------------------- scripts/qw | 41 ---------------------------- scripts/sask | 15 ---------- scripts/sdev | 80 ------------------------------------------------------ scripts/shot | 56 -------------------------------------- scripts/slight | 48 -------------------------------- scripts/sroll | 5 ---- scripts/svol | 50 ---------------------------------- scripts/swall | 68 ---------------------------------------------- 24 files changed, 452 insertions(+), 474 deletions(-) delete mode 100755 scripts/br create mode 100755 scripts/cli/noc create mode 100755 scripts/cli/nospac create mode 100755 scripts/cli/sdev create mode 100755 scripts/cli/slight create mode 100755 scripts/cli/sroll create mode 100755 scripts/cli/svol create mode 100755 scripts/gui/br create mode 100755 scripts/gui/nsend create mode 100755 scripts/gui/qw create mode 100755 scripts/gui/shot create mode 100755 scripts/gui/swall delete mode 100755 scripts/mus delete mode 100755 scripts/noc delete mode 100755 scripts/nospac delete mode 100755 scripts/nsend delete mode 100755 scripts/qw delete mode 100755 scripts/sask delete mode 100755 scripts/sdev delete mode 100755 scripts/shot delete mode 100755 scripts/slight delete mode 100755 scripts/sroll delete mode 100755 scripts/svol delete mode 100755 scripts/swall (limited to 'scripts') diff --git a/scripts/br b/scripts/br deleted file mode 100755 index 0fd6dc5..0000000 --- a/scripts/br +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh - -. slib - -help() { -cat << EOF -${0}: Open links from bookmarks through dmenu -options: -[link] Open link - -h Print this message and exit - -NOTE: bookmarks file is located at ~/.config/sites/bookmarks -EOF - -exit 0 -} - -alias dmenucmd="dmenu -bw 1 -c -g 1 -l 25" - -[ -z "${BROWSER}" ] && browser="qutebrowser" || browser="${BROWSER}" - -if [ "${#}" -eq 0 ]; then - - # FIXME: Use XDG_CONFIG - link_file="${HOME}/.config"/sites/bookmarks.txt - - check_program "dmenu" - - [ -z "${XDG_HOME_CONFIG}" ] || link_file="${XDG_HOME_CONFIG}"/sites/bookmarks.txt - [ -e "${link_file}" ] || err "Couldn't find bookmarks file" - - link=$(< "${link_file}" dmenucmd) - - [ -z "${link}" ] || "${browser}" "${link}" - -elif [ "${#}" -eq 1 ]; then - [ "${1}" = "-h" ] && help - - "${browser}" "${1}" -else - invalid_use -fi 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 diff --git a/scripts/gui/br b/scripts/gui/br new file mode 100755 index 0000000..0fd6dc5 --- /dev/null +++ b/scripts/gui/br @@ -0,0 +1,42 @@ +#!/bin/sh + +. slib + +help() { +cat << EOF +${0}: Open links from bookmarks through dmenu +options: +[link] Open link + -h Print this message and exit + +NOTE: bookmarks file is located at ~/.config/sites/bookmarks +EOF + +exit 0 +} + +alias dmenucmd="dmenu -bw 1 -c -g 1 -l 25" + +[ -z "${BROWSER}" ] && browser="qutebrowser" || browser="${BROWSER}" + +if [ "${#}" -eq 0 ]; then + + # FIXME: Use XDG_CONFIG + link_file="${HOME}/.config"/sites/bookmarks.txt + + check_program "dmenu" + + [ -z "${XDG_HOME_CONFIG}" ] || link_file="${XDG_HOME_CONFIG}"/sites/bookmarks.txt + [ -e "${link_file}" ] || err "Couldn't find bookmarks file" + + link=$(< "${link_file}" dmenucmd) + + [ -z "${link}" ] || "${browser}" "${link}" + +elif [ "${#}" -eq 1 ]; then + [ "${1}" = "-h" ] && help + + "${browser}" "${1}" +else + invalid_use +fi diff --git a/scripts/gui/nsend b/scripts/gui/nsend new file mode 100755 index 0000000..80e1764 --- /dev/null +++ b/scripts/gui/nsend @@ -0,0 +1,32 @@ +#!/bin/sh + +. slib + +help() { +cat << EOF +${0}: Wrapper script to send notifications +options: + -s [Name] [Msg] Send Msg with Name + -s [Msg] Send Msg Without Name + -h Print this message and exit +EOF + +exit 0 +} + +check_program "notify-send" "libnotify must be installed" + +case "${1}" in +"-s") + [ "${#}" -gt 3 ] && invalid_use + + shift + eval $(printf 'notify-send "%s" "%s"' "${1}" "${2}") + + exit 0 +;; +"-h") help ;; + +*) invalid_use ;; + +esac diff --git a/scripts/gui/qw b/scripts/gui/qw new file mode 100755 index 0000000..1199227 --- /dev/null +++ b/scripts/gui/qw @@ -0,0 +1,41 @@ +#!/bin/sh + +. slib + +help() { +cat << EOF +${0}: Qemu Wrapper, very simple script for abriviating \ +verbose qemu commands and options +options: + -c create an Image.img with 10G space + -r [input.iso] run input.iso + -x [input.qcow2] run input.qcow2 +EOF + +exit 0 +} + +check_program "qemu-img" +check_program "qemu-system-x86_64" + +[ $# != 2 ] && [ $# != 1 ] && invalid_use + +while getopts "cr:x:h" option ;do + case "${option}" in + c) run "qemu-img create -f qcow2 Image.img 10G" ;; + + x) run "qemu-system-x86_64 -drive file=${OPTARG},format=qcow2 -enable-kvm -cpu host -smp 2 -m 2048 -net nic -net user -display sdl" ;; + + r) + run "qemu-system-x86_64 -enable-kvm -cdrom ${OPTARG} \ + -boot menu=on -drive file=Image.img -m 4G" + ;; + h) help ;; + + *) invalid_use -h ;; + + esac +done + +# Unreachable +invalid_use diff --git a/scripts/gui/shot b/scripts/gui/shot new file mode 100755 index 0000000..7404943 --- /dev/null +++ b/scripts/gui/shot @@ -0,0 +1,56 @@ +#!/bin/sh + +. slib + +help() { +cat << EOF +${0}: Wrapper script to take screenshots +options: + -d [File] Write to File + -s Select the area with the cursor + -h Print this message and exit + +NOTE: save directory is ~/pics/screenshot +EOF + +exit 0 +} + +check_program "scrot" + +default_dir="${HOME}"/pics/screenshot + +s_flg="" +while getopts "d:sh" option; do + case "${option}" in + d) input="${OPTARG}" ;; + + s) s_flg="1" ;; + + h) help ;; + + *) invalid_use -h ;; + + esac +done + +shift $((OPTIND - 1)) + +[ ${#} != 0 ] && invalid_use + +[ -z "${input}" ] && input="${default_dir}" + +outfile="${input}" + +[ -d "${input}" ] && outfile="${input}/$(date '+%b%d::%H%M%S').png" + +if [ ! -e "$(dirname "${outfile}")" ]; then + mkdir -p "$(dirname "${outfile}")" > /dev/null 2>&1 \ + || err "Failed to create directory" +fi + +if [ "${s_flg}" = "1" ]; then + run "scrot -zs ${outfile}" "${outfile}" +else + run "scrot -z ${outfile}" "${outfile}" +fi diff --git a/scripts/gui/swall b/scripts/gui/swall new file mode 100755 index 0000000..8e5ffb6 --- /dev/null +++ b/scripts/gui/swall @@ -0,0 +1,68 @@ +#!/bin/sh + +. slib + +help() { +cat << EOF +${0}: Wrapper script to set wallpapers +options: + -d [File] Select a wallpaper or a directory + -c Remove the current wallpaper + -h Print this message and exit + +NOTE: default directory is ~/.config/wallpapers +EOF + +exit 0 +} + +check_program "xwallpaper" + +if [ "${#}" = 0 ]; then + #FIXME: use XDG_CONFIG + input="${HOME}/.config/wallpapers" +elif [ "${#}" != 1 ] && [ "${#}" != 2 ]; then + invalid_use +fi + +while getopts "hcd:" option; do + case "${option}" in + c) + #FIXME: use `run` function + killall picom + xwallpaper --clear + picom & + exit 0 + ;; + + d) input="${OPTARG}" ;; + + h) help ;; + + *) invalid_use -h ;; + + esac +done + +shift $((OPTIND - 1)) + +[ "${#}" != 0 ] && invalid_use + +if [ -n "${input}" ]; then + case $(file -L -b --mime-type "${input}") in + image/*) image="${input}" ;; + + inode/directory) waldir="${input}" ;; + + *) err "Couldn't read given file" ;; + esac +fi + +if [ -n "${waldir}" ]; then + image=$(find "${waldir}" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' 2>/dev/null \ + | shuf -n 1 ) +fi + +[ -z "${image}" ] && err "No image file found" + +run "xwallpaper --zoom ${image}" "${image}" diff --git a/scripts/mus b/scripts/mus deleted file mode 100755 index 7015616..0000000 --- a/scripts/mus +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -# Play a file in $HOME/music directory using mpv - -music_name=$(find "${HOME}"/media/music | fzf) - -mpv "${music_name}" diff --git a/scripts/noc b/scripts/noc deleted file mode 100755 index 575566c..0000000 --- a/scripts/noc +++ /dev/null @@ -1,7 +0,0 @@ -#!/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/nospac b/scripts/nospac deleted file mode 100755 index 6ba466a..0000000 --- a/scripts/nospac +++ /dev/null @@ -1,23 +0,0 @@ -#!/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/nsend b/scripts/nsend deleted file mode 100755 index 80e1764..0000000 --- a/scripts/nsend +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -. slib - -help() { -cat << EOF -${0}: Wrapper script to send notifications -options: - -s [Name] [Msg] Send Msg with Name - -s [Msg] Send Msg Without Name - -h Print this message and exit -EOF - -exit 0 -} - -check_program "notify-send" "libnotify must be installed" - -case "${1}" in -"-s") - [ "${#}" -gt 3 ] && invalid_use - - shift - eval $(printf 'notify-send "%s" "%s"' "${1}" "${2}") - - exit 0 -;; -"-h") help ;; - -*) invalid_use ;; - -esac diff --git a/scripts/qw b/scripts/qw deleted file mode 100755 index 1199227..0000000 --- a/scripts/qw +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh - -. slib - -help() { -cat << EOF -${0}: Qemu Wrapper, very simple script for abriviating \ -verbose qemu commands and options -options: - -c create an Image.img with 10G space - -r [input.iso] run input.iso - -x [input.qcow2] run input.qcow2 -EOF - -exit 0 -} - -check_program "qemu-img" -check_program "qemu-system-x86_64" - -[ $# != 2 ] && [ $# != 1 ] && invalid_use - -while getopts "cr:x:h" option ;do - case "${option}" in - c) run "qemu-img create -f qcow2 Image.img 10G" ;; - - x) run "qemu-system-x86_64 -drive file=${OPTARG},format=qcow2 -enable-kvm -cpu host -smp 2 -m 2048 -net nic -net user -display sdl" ;; - - r) - run "qemu-system-x86_64 -enable-kvm -cdrom ${OPTARG} \ - -boot menu=on -drive file=Image.img -m 4G" - ;; - h) help ;; - - *) invalid_use -h ;; - - esac -done - -# Unreachable -invalid_use diff --git a/scripts/sask b/scripts/sask deleted file mode 100755 index 1ea0f3f..0000000 --- a/scripts/sask +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -. slib - -check_program "ollama" - -if [ "${1}" = "-s" ]; then - addition="answer in a short way:" - shift -fi - -question="${addition} ${@}" -model="codellama" - -echo "${question}" | ollama run "${model}" diff --git a/scripts/sdev b/scripts/sdev deleted file mode 100755 index c227771..0000000 --- a/scripts/sdev +++ /dev/null @@ -1,80 +0,0 @@ -#!/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/shot b/scripts/shot deleted file mode 100755 index 7404943..0000000 --- a/scripts/shot +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh - -. slib - -help() { -cat << EOF -${0}: Wrapper script to take screenshots -options: - -d [File] Write to File - -s Select the area with the cursor - -h Print this message and exit - -NOTE: save directory is ~/pics/screenshot -EOF - -exit 0 -} - -check_program "scrot" - -default_dir="${HOME}"/pics/screenshot - -s_flg="" -while getopts "d:sh" option; do - case "${option}" in - d) input="${OPTARG}" ;; - - s) s_flg="1" ;; - - h) help ;; - - *) invalid_use -h ;; - - esac -done - -shift $((OPTIND - 1)) - -[ ${#} != 0 ] && invalid_use - -[ -z "${input}" ] && input="${default_dir}" - -outfile="${input}" - -[ -d "${input}" ] && outfile="${input}/$(date '+%b%d::%H%M%S').png" - -if [ ! -e "$(dirname "${outfile}")" ]; then - mkdir -p "$(dirname "${outfile}")" > /dev/null 2>&1 \ - || err "Failed to create directory" -fi - -if [ "${s_flg}" = "1" ]; then - run "scrot -zs ${outfile}" "${outfile}" -else - run "scrot -z ${outfile}" "${outfile}" -fi diff --git a/scripts/slight b/scripts/slight deleted file mode 100755 index 0289ff4..0000000 --- a/scripts/slight +++ /dev/null @@ -1,48 +0,0 @@ -#!/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/sroll b/scripts/sroll deleted file mode 100755 index e0c8b70..0000000 --- a/scripts/sroll +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -# Rickroll on terminal - -curl -s -L https://raw.githubusercontent.com/keroserene/rickrollrc/master/roll.sh | bash diff --git a/scripts/svol b/scripts/svol deleted file mode 100755 index ec60450..0000000 --- a/scripts/svol +++ /dev/null @@ -1,50 +0,0 @@ -#!/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 diff --git a/scripts/swall b/scripts/swall deleted file mode 100755 index 8e5ffb6..0000000 --- a/scripts/swall +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh - -. slib - -help() { -cat << EOF -${0}: Wrapper script to set wallpapers -options: - -d [File] Select a wallpaper or a directory - -c Remove the current wallpaper - -h Print this message and exit - -NOTE: default directory is ~/.config/wallpapers -EOF - -exit 0 -} - -check_program "xwallpaper" - -if [ "${#}" = 0 ]; then - #FIXME: use XDG_CONFIG - input="${HOME}/.config/wallpapers" -elif [ "${#}" != 1 ] && [ "${#}" != 2 ]; then - invalid_use -fi - -while getopts "hcd:" option; do - case "${option}" in - c) - #FIXME: use `run` function - killall picom - xwallpaper --clear - picom & - exit 0 - ;; - - d) input="${OPTARG}" ;; - - h) help ;; - - *) invalid_use -h ;; - - esac -done - -shift $((OPTIND - 1)) - -[ "${#}" != 0 ] && invalid_use - -if [ -n "${input}" ]; then - case $(file -L -b --mime-type "${input}") in - image/*) image="${input}" ;; - - inode/directory) waldir="${input}" ;; - - *) err "Couldn't read given file" ;; - esac -fi - -if [ -n "${waldir}" ]; then - image=$(find "${waldir}" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' 2>/dev/null \ - | shuf -n 1 ) -fi - -[ -z "${image}" ] && err "No image file found" - -run "xwallpaper --zoom ${image}" "${image}" -- cgit v1.2.3