diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/br | 8 | ||||
-rwxr-xr-x | scripts/nospac | 3 | ||||
-rwxr-xr-x | scripts/nsend | 12 | ||||
-rwxr-xr-x | scripts/qw | 9 | ||||
-rwxr-xr-x | scripts/sdev | 21 | ||||
-rwxr-xr-x | scripts/shot | 7 | ||||
-rwxr-xr-x | scripts/slib | 9 | ||||
-rwxr-xr-x | scripts/slight | 11 | ||||
-rwxr-xr-x | scripts/svol | 13 | ||||
-rwxr-xr-x | scripts/swall | 7 |
10 files changed, 48 insertions, 52 deletions
@@ -6,8 +6,8 @@ help() { cat << EOF ${0}: Open links from bookmarks through dmenu options: -[link] Open link - -h Print this message and exit +[link] Open link + -h Print this message and exit NOTE: bookmarks file is located at ~/.config/sites/bookmarks EOF @@ -33,8 +33,8 @@ if [ "${#}" -eq 0 ]; then [ -z "${link}" ] || "${browser}" "${link}" -elif [ "${#}" -eq 1 ]; then - [ "${1}" = "-h" ] && help +elif [ "${#}" -eq 1 ]; then + [ "${1}" = "-h" ] && help "${browser}" "${1}" else diff --git a/scripts/nospac b/scripts/nospac index 650c216..6ba466a 100755 --- a/scripts/nospac +++ b/scripts/nospac @@ -4,9 +4,8 @@ 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 + -h Print this message and exit EOF } diff --git a/scripts/nsend b/scripts/nsend index 7337b4d..80e1764 100755 --- a/scripts/nsend +++ b/scripts/nsend @@ -5,23 +5,23 @@ 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 + -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" "dunst must be installed" +check_program "notify-send" "libnotify must be installed" case "${1}" in "-s") [ "${#}" -gt 3 ] && invalid_use - run "notify-send ${2} ${3}" + shift + eval $(printf 'notify-send "%s" "%s"' "${1}" "${2}") exit 0 ;; @@ -6,11 +6,10 @@ 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 + -c create an Image.img with 10G space + -r [input.iso] run input.iso + -x [input.qcow2] run input.qcow2 EOF exit 0 @@ -25,7 +24,7 @@ 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" ;; + 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} \ diff --git a/scripts/sdev b/scripts/sdev index 22c1af5..c227771 100755 --- a/scripts/sdev +++ b/scripts/sdev @@ -5,15 +5,14 @@ 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 + -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 (or enable) unwanted devices. +Note: Nondescriptive inputs may disable/enable unwanted devices. EOF exit 0 @@ -50,13 +49,13 @@ check_program "xinput" while getopts "e:d:t:lh" option; do case "${option}" in - e) + e) get_id "${OPTARG}" xenable "${id}" ;; - d) + d) get_id "${OPTARG}" - xdisable "${id}" + xdisable "${id}" ;; t) get_id "${OPTARG}" @@ -67,7 +66,7 @@ while getopts "e:d:t:lh" option; do l) if ! xinput list 2>/dev/null; then err "Listing Failed" - else + else exit 0 fi ;; diff --git a/scripts/shot b/scripts/shot index 4a58dd2..1d296c8 100755 --- a/scripts/shot +++ b/scripts/shot @@ -5,11 +5,10 @@ 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 + -d [File] Write to File + -s Select the area with the cursor + -h Print this message and exit NOTE: save directory is ~/pics/screenshots EOF diff --git a/scripts/slib b/scripts/slib index 30e32ca..e598db7 100755 --- a/scripts/slib +++ b/scripts/slib @@ -1,7 +1,7 @@ #!/bin/sh # Avoid using full paths instead only use the program names. -argv0=$(basename "${0}") +argv0="${0}" # @FUNCTION: err # @USAGE: [-x] <message> ... @@ -15,7 +15,6 @@ argv0=$(basename "${0}") # @EXAMPLE: # err "Invalid usage" "Try '${argv0} -h' for help." - err() { if [ "${1}" != "-x" ]; then printf "%s: " "${argv0}" @@ -32,7 +31,7 @@ err() { # @FUNCTION: invalid_use # USAGE: [-h] # @DESCRIPTION: -# Output a usage error message. If `-h` is not specified output: +# Output a usage error message. If `-h` is not specified output: # "<program>: Invalid usage " # "Try 'program -h' for help." # else output only: @@ -72,6 +71,10 @@ check_program() { # To add a failure message a success message must also be present. # The output of the command is not suppressed. # +# This implementation does **not** use `eval`. Only simple commands and arguments are supported. +# Shell control operators like `&&`, `||`, pipes (`|`), or redirection (`>`, `>>`, etc.) will not work. +# This prevents unintended execution and makes it safe for use in scripts. +# # @EXAMPLE: # Run xwallpaper command if success print out ${image}: # diff --git a/scripts/slight b/scripts/slight index 0f8cba0..0289ff4 100755 --- a/scripts/slight +++ b/scripts/slight @@ -5,13 +5,12 @@ 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 + -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 diff --git a/scripts/svol b/scripts/svol index f0765bb..ec60450 100755 --- a/scripts/svol +++ b/scripts/svol @@ -5,14 +5,13 @@ 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 + -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 diff --git a/scripts/swall b/scripts/swall index 34c4bc8..2588b4b 100755 --- a/scripts/swall +++ b/scripts/swall @@ -5,11 +5,10 @@ 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 + -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 |