summaryrefslogtreecommitdiff
path: root/scripts/cli
diff options
context:
space:
mode:
authorSuleyman Farajli <suleyman@farajli.net>2025-10-26 22:23:31 +0400
committerSuleyman Farajli <suleyman@farajli.net>2025-10-26 22:23:31 +0400
commitcb78290f31886fb1f9a5e7c2a764dda55a459e50 (patch)
tree72a2df0645405658d8590d4b8d7d87f1e099f596 /scripts/cli
parentf8d1bfbd0f27e0763cf75fcda58d010e346515ab (diff)
chore: split script installation into CLI and GUI sections
Diffstat (limited to 'scripts/cli')
-rwxr-xr-xscripts/cli/noc7
-rwxr-xr-xscripts/cli/nospac23
-rwxr-xr-xscripts/cli/sdev80
-rwxr-xr-xscripts/cli/slight48
-rwxr-xr-xscripts/cli/sroll5
-rwxr-xr-xscripts/cli/svol50
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