diff options
Diffstat (limited to 'scripts/util')
-rwxr-xr-x | scripts/util/afk.sh | 17 | ||||
-rwxr-xr-x | scripts/util/arcc | 11 | ||||
-rwxr-xr-x | scripts/util/arco | 11 | ||||
-rw-r--r-- | scripts/util/assets/accents.txt | 40 | ||||
-rwxr-xr-x | scripts/util/blue | 9 | ||||
-rwxr-xr-x | scripts/util/bmark.sh | 3 | ||||
-rwxr-xr-x | scripts/util/croc.sh | 7 | ||||
-rwxr-xr-x | scripts/util/dic | 5 | ||||
-rwxr-xr-x | scripts/util/dupt.sh | 5 | ||||
-rwxr-xr-x | scripts/util/fcd.sh | 13 | ||||
-rwxr-xr-x | scripts/util/fr-acc.sh | 5 | ||||
-rwxr-xr-x | scripts/util/gtab_init.sh | 24 | ||||
-rwxr-xr-x | scripts/util/hist.sh | 3 | ||||
-rwxr-xr-x | scripts/util/killpid.sh | 3 | ||||
-rwxr-xr-x | scripts/util/manfzf.sh | 13 | ||||
-rwxr-xr-x | scripts/util/netsel.sh | 6 | ||||
-rwxr-xr-x | scripts/util/open_1 | 5 | ||||
-rwxr-xr-x | scripts/util/passmen.sh | 6 | ||||
-rwxr-xr-x | scripts/util/pgen.sh | 34 | ||||
-rwxr-xr-x | scripts/util/power | 16 | ||||
-rwxr-xr-x | scripts/util/prompt | 8 | ||||
-rwxr-xr-x | scripts/util/sc.sh | 3 | ||||
-rwxr-xr-x | scripts/util/sp.sh | 11 | ||||
-rwxr-xr-x | scripts/util/update-web.sh | 6 | ||||
-rwxr-xr-x | scripts/util/vol | 19 | ||||
-rwxr-xr-x | scripts/util/vol+ | 17 | ||||
-rwxr-xr-x | scripts/util/vol- | 22 | ||||
-rwxr-xr-x | scripts/util/vpn.sh | 63 |
28 files changed, 385 insertions, 0 deletions
diff --git a/scripts/util/afk.sh b/scripts/util/afk.sh new file mode 100755 index 0000000..34d1226 --- /dev/null +++ b/scripts/util/afk.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# Prevent screen from sleeping or trick websites to think you're present while afk + +dzen_opts="-bg white -fg black -p 1 -x -475 -y 50 -w 475 -h 50" +message="Away from keyboard for ~$1 minutes" + +while true; do + for direction in "10 0" "0 10" "-10 0" "0 -10"; do # move around + xdotool mousemove_relative -- $direction + printf '%s\n' "$message" | dzen2 $dzen_opts + done + + xdotool mousemove 2880 540 # someplace near the middle +done + +rm "$PID_FILE" diff --git a/scripts/util/arcc b/scripts/util/arcc new file mode 100755 index 0000000..7bb25e7 --- /dev/null +++ b/scripts/util/arcc @@ -0,0 +1,11 @@ +#!/bin/bash + +if df | grep -q aa && df | grep -q arc ; then + sudo umount ~/Digital/Drives/D2 + sudo cryptsetup close /dev/mapper/arc && + + sudo umount ~/Digital/Drives/ED + sudo cryptsetup close /dev/mapper/aa + else + echo "Error: Drive not mounted."; +fi diff --git a/scripts/util/arco b/scripts/util/arco new file mode 100755 index 0000000..2d93661 --- /dev/null +++ b/scripts/util/arco @@ -0,0 +1,11 @@ +#!/bin/bash + +if lsblk | grep -q sdc && lsblk | grep -q sdb ; then + sudo cryptsetup open /dev/sdb arc + sudo mount /dev/mapper/arc ~/Digital/Drives/D2 -o compress-force && + + sudo cryptsetup open /dev/sdc aa + sudo mount /dev/mapper/aa ~/Digital/Drives/ED +else + echo "Error: Drive not mounted."; +fi diff --git a/scripts/util/assets/accents.txt b/scripts/util/assets/accents.txt new file mode 100644 index 0000000..7ab76a8 --- /dev/null +++ b/scripts/util/assets/accents.txt @@ -0,0 +1,40 @@ +# Vowels: +À (capital A with grave accent) +à (lowercase a with grave accent) + (capital A with circumflex accent) +â (lowercase a with circumflex accent) +Ä (capital A with diaeresis/umlaut) +ä (lowercase a with diaeresis/umlaut) +É (capital E with acute accent) +é (lowercase e with acute accent) +È (capital E with grave accent) +è (lowercase e with grave accent) +Ê (capital E with circumflex accent) +ê (lowercase e with circumflex accent) +Ë (capital E with diaeresis/umlaut) +ë (lowercase e with diaeresis/umlaut) +Î (capital I with circumflex accent) +î (lowercase i with circumflex accent) +Ï (capital I with diaeresis/umlaut) +ï (lowercase i with diaeresis/umlaut) +Ô (capital O with circumflex accent) +ô (lowercase o with circumflex accent) +Ù (capital U with grave accent) +ù (lowercase u with grave accent) +Û (capital U with circumflex accent) +û (lowercase u with circumflex accent) +Ü (capital U with diaeresis/umlaut) +ü (lowercase u with diaeresis/umlaut) +Ÿ (capital Y with diaeresis/umlaut) +ÿ (lowercase y with diaeresis/umlaut) + +# Ligatures: +Æ (capital AE ligature) +æ (lowercase ae ligature) +Œ (capital OE ligature) +œ (lowercase oe ligature) + +Other: +Ç (capital C with cedilla) +ç (lowercase c with cedilla) +ß (eszett or sharp S, used in German but occasionally found in French) diff --git a/scripts/util/blue b/scripts/util/blue new file mode 100755 index 0000000..14675b3 --- /dev/null +++ b/scripts/util/blue @@ -0,0 +1,9 @@ +#!/bin/sh + +case "$(printf " connect\n disconnect" | dmenu -i -p 'Connect or Disconnect')" in + ' connect') case "$(printf " crusher\n " | dmenu -i -p 'Connect a Device')" in + ' crusher' ) bluetoothctl agent on ; bluetoothctl default-agent ; bluetoothctl power on ; bluetoothctl trust 38:F3:2E:BC:D1:F2 ; bluetoothctl connect 38:F3:2E:BC:D1:F2 ;; + esac ;; + ' disconnect') bluetoothctl disconnect ;; + *) exit 1 ;; +esac diff --git a/scripts/util/bmark.sh b/scripts/util/bmark.sh new file mode 100755 index 0000000..466414c --- /dev/null +++ b/scripts/util/bmark.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +xdotool type $(grep -v '^#' ~/.local/share/bmark/bmarks.txt | dmenu -i -l 30 | cut -d' ' -f1) diff --git a/scripts/util/croc.sh b/scripts/util/croc.sh new file mode 100755 index 0000000..ae7efbd --- /dev/null +++ b/scripts/util/croc.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +nmcli c show --active | grep -q "wg-mullvad" 2>>/dev/null && read -p "VPN is active. Contine? [Y/n] " ON || echo "VPN is off, aborting."; break ; + +case $ON in + [Yy]* ) croc $1; +esac diff --git a/scripts/util/dic b/scripts/util/dic new file mode 100755 index 0000000..58755a8 --- /dev/null +++ b/scripts/util/dic @@ -0,0 +1,5 @@ +#!/bin/sh + +# Online CLI dictionary + +curl -s https://www.wordnik.com/words/"$1" | awk '/id="define/{p=1}p' | awk '/div/{p++}p==2' | sed -e 's/<[^>]*>//g' | sed 's/^ *$//g' | expand --tabs=1 | less diff --git a/scripts/util/dupt.sh b/scripts/util/dupt.sh new file mode 100755 index 0000000..61d2260 --- /dev/null +++ b/scripts/util/dupt.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +# open a new terminal in the current working directory + +st -e sh -c 'cd "$PWD" && exec $SHELL' >/dev/null 2>&1 & diff --git a/scripts/util/fcd.sh b/scripts/util/fcd.sh new file mode 100755 index 0000000..09c1e50 --- /dev/null +++ b/scripts/util/fcd.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# CD into chosen directory, otherwise terminate + +fcd() { + cd "$(fd -t d -E Digital/D1 -E /home/black/Games | fzf --reverse || exit)" +} + +fcd + +if [ $? -eq 0 ]; then + exec "$SHELL" #-i +fi diff --git a/scripts/util/fr-acc.sh b/scripts/util/fr-acc.sh new file mode 100755 index 0000000..ef5f301 --- /dev/null +++ b/scripts/util/fr-acc.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +selected=$(grep -v '^#' ~/.local/share/scripts/accents.txt | dmenu -i -l 30 | cut -d' ' -f1) +echo -n "$selected" | xclip -selection clipboard +printf '%s\n' "$selected has been copied to the clipboard." | dzen2 -bg white -fg black -p 2 -x -475 -y 50 -w 475 -h 50 diff --git a/scripts/util/gtab_init.sh b/scripts/util/gtab_init.sh new file mode 100755 index 0000000..76284d9 --- /dev/null +++ b/scripts/util/gtab_init.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +pad_id=$(xinput | grep "HID 256c:006d Pad pad" | cut -f 2 | cut -d '=' -f 2) +stylus_id=$(xinput | grep "HID 256c:006d Pen stylus" | cut -f 2 | cut -d '=' -f 2) + +# Clear +xsetwacom set $pad_id Button 1 "key + " +xsetwacom set $pad_id Button 2 "key + " +xsetwacom set $pad_id Button 3 "key + " +xsetwacom set $pad_id Button 8 "key + " +xsetwacom set $pad_id Button 9 "key + " +xsetwacom set $pad_id Button 10 "key + " +xsetwacom set $pad_id Button 11 "key + " +xsetwacom set $pad_id Button 12 "key + " + +# Set +xsetwacom --set $pad_id Button 1 "key +ctrl z -ctrl" +xsetwacom --set $pad_id Button 2 "key +ctrl s -ctrl" +xsetwacom --set $pad_id Button 9 "key +ctrl shift p -ctrl" +xsetwacom --set $pad_id Button 10 "key +ctrl shift e -ctrl" +xsetwacom --set $pad_id Button 11 "key +ctrl shift a -ctrl" +xsetwacom --set $pad_id Button 12 "key +ctrl shift r -ctrl" + +xsetwacom set $stylus_id MapToOutput $1 diff --git a/scripts/util/hist.sh b/scripts/util/hist.sh new file mode 100755 index 0000000..e95a0f9 --- /dev/null +++ b/scripts/util/hist.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +$(cat ~/.bash_history | fzf) diff --git a/scripts/util/killpid.sh b/scripts/util/killpid.sh new file mode 100755 index 0000000..34a738a --- /dev/null +++ b/scripts/util/killpid.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +ps -aux | fzf | awk '{print $2}' | xargs -r kill diff --git a/scripts/util/manfzf.sh b/scripts/util/manfzf.sh new file mode 100755 index 0000000..aa25d11 --- /dev/null +++ b/scripts/util/manfzf.sh @@ -0,0 +1,13 @@ +# Man without options will use fzf to select a page +function fzf-man(){ + MAN="/usr/bin/man" + if [ -n "$1" ]; then + $MAN "$@" + return $? + else + $MAN -k . | fzf --reverse --preview="echo {1,2} | sed 's/ (/./' | sed -E 's/\)\s*$//' | xargs $MAN" | awk '{print $1 "." $2}' | tr -d '()' | xargs -r $MAN + return $? + fi +} + +fzf-man diff --git a/scripts/util/netsel.sh b/scripts/util/netsel.sh new file mode 100755 index 0000000..b1b2a88 --- /dev/null +++ b/scripts/util/netsel.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +BSSID=$(printf "%s" "$(nmcli d wifi | fzf --height 40%)" | sed 's/\*//' | awk '{print $1}') +#read -sp "Enter password for $BSSID: " PASSWORD + +nmcli d wifi connect $BSSID #password "$PASSWORD" diff --git a/scripts/util/open_1 b/scripts/util/open_1 new file mode 100755 index 0000000..58c8efc --- /dev/null +++ b/scripts/util/open_1 @@ -0,0 +1,5 @@ +#!/bin/sh + +sudo cryptsetup open /dev/sda1 one + +sudo mount /dev/mapper/one ~/Digital/Drives/D1 -o compress-force diff --git a/scripts/util/passmen.sh b/scripts/util/passmen.sh new file mode 100755 index 0000000..d2d9cf8 --- /dev/null +++ b/scripts/util/passmen.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +accnts=$(pass | sed '1d; s/^[^ ]* //' | sed 's/\x1B\[[0-9;]*[a-zA-Z]//g') +selected=$(printf '%s\n' "${accnts}" | dmenu -l 10 -p "Select an account:") + +pass show "$selected" | xclip -selection clipboard | printf '%s\n' "Password for $selected has been copied!" | dzen2 -p 1 -bg white -fg black -x -375 -y 50 -w 475 -h 50 diff --git a/scripts/util/pgen.sh b/scripts/util/pgen.sh new file mode 100755 index 0000000..f3a7976 --- /dev/null +++ b/scripts/util/pgen.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# A pseudorandom password generator + +LEN=16 # default length +SYMBOLS=true + +gen_psw() { + local len=$1 + local symbols=$2 + local charset="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + + [[ $symbols == true ]] && charset="${charset}!@#$%^&*()_+{}|:<>?" + + psw=$(< /dev/urandom tr -dc "$charset" | head -c "$len") + echo "$psw" +} + +while [[ "$#" -gt 0 ]]; do + case $1 in + -l|--length) LEN="$2"; shift ;; + -ns|--no-symbols) SYMBOLS=false ;; + *) echo "Unknown flag: $1"; exit 1 ;; + esac + shift +done + +PASSWORD=$(gen_psw "$LEN" "$SYMBOLS") +echo "$PASSWORD" + +if command -v xclip &> /dev/null; then + echo -n "$PASSWORD" | xclip -selection clipboard + printf '%s\n' "Password has been copied." | dzen2 -p 1 -bg white -fg black -x -305 -y 50 -w 455 -h 50 +fi diff --git a/scripts/util/power b/scripts/util/power new file mode 100755 index 0000000..ce9a8f5 --- /dev/null +++ b/scripts/util/power @@ -0,0 +1,16 @@ +#!/bin/sh + + +case "$(readlink -f /sbin/init)" in + *systemd*) ctl='systemctl' ;; + *) ctl='loginctl' ;; +esac + +case "$(printf " reboot\n shutdown\n sleep\n lock\n kill dwm\n" | dmenu -i -p 'Action: ')" in + ' lock') slock ;; + ' leave dwm') kill -TERM "$(pgrep -u "$USER" "\bdwm$")" ;; + ' sleep') slock $ctl suspend ;; + ' reboot') /bin/reboot ;; + ' shutdown') /bin/shutdown -h now ;; + *) exit 1 ;; +esac diff --git a/scripts/util/prompt b/scripts/util/prompt new file mode 100755 index 0000000..75eccc5 --- /dev/null +++ b/scripts/util/prompt @@ -0,0 +1,8 @@ +#!/bin/sh + +case "$(printf " power\n bluetooth\n network\n " | dmenu -i -p 'Run a Dmenu script:')" in + ' power') /bin/power ;; + ' bluetooth') /bin/blue ;; + ' network') /bin/network ;; + *) exit 1 ;; +esac diff --git a/scripts/util/sc.sh b/scripts/util/sc.sh new file mode 100755 index 0000000..9557e34 --- /dev/null +++ b/scripts/util/sc.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +maim -s -m 10 | tee ~/Digital/Pictures/Screen\ Shots/$(date +%Y-%m-%d__%S%S).jpg | xclip -selection clipboard -t image/png diff --git a/scripts/util/sp.sh b/scripts/util/sp.sh new file mode 100755 index 0000000..b4ce819 --- /dev/null +++ b/scripts/util/sp.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# pacman wrapper + +case $* in + -Syu ) sudo pacman -Syu + echo 0 > ~/.local/share/updates.txt ;; + -Syyu ) sudo pacman -Syyu + echo 0 > ~/.local/share/updates.txt ;; + * ) sudo pacman ;; +esac diff --git a/scripts/util/update-web.sh b/scripts/util/update-web.sh new file mode 100755 index 0000000..cda3e92 --- /dev/null +++ b/scripts/util/update-web.sh @@ -0,0 +1,6 @@ +#!/bin/sh + + +SITE=$(printf "$(ls ~/Dev/website)" | dmenu -i -p "Pick a site to update"); +rsync -uvrp --delete-after ~/Dev/website/"$SITE"/ root@nagy.contact:/var/www/"$SITE"/ +printf "Updating: $SITE\n" | dzen2 -bg white -fg black -p 2 -x -375 -y 50 -w 275 -h 50 diff --git a/scripts/util/vol b/scripts/util/vol new file mode 100755 index 0000000..1aa82c0 --- /dev/null +++ b/scripts/util/vol @@ -0,0 +1,19 @@ +#!/bin/sh + + mute_state=$(amixer -c 3 get 'Master',0 | grep -o '\[on\]') + + if [[ $mute_state == "[on]" ]]; then + amixer -c 3 set 'Master',0 mute + printf '%s\n' "Volume: Off" | dzen2 -p 1 -bg white -fg black -x -375 -y 50 -w 275 -h 50 + amixer -c 3 set 'Headphone',0 mute + else + amixer -c 3 set 'Master',0 unmute + amixer -c 3 set 'Headphone',0 unmute + printf '%s\n' "Volume: On" | dzen2 -p 1 -bg white -fg black -x -375 -y 50 -w 275 -h 50 + fi + + +#amixer -D pulse sset Master toggle +#state=$(amixer -D pulse sget Master | grep 'Front Left:' | sed -E 's/.*\[([a-z]+)\].*/\1/') +#printf 'Volume %s\n' "$state" | dzen2 -p 1 -bg white -fg black -x -375 -y 50 -w 275 -h 50 +# amixer set Master toggle ; a="$(awk -F"[][]" '/Front Left/ { print $4 }' <(amixer sget Master) | tail -n +2)"; printf '%s\n' "Volume: $a" | dzen2 -p 1 -bg white -fg black -x -375 -y 50 -w 275 -h 50 diff --git a/scripts/util/vol+ b/scripts/util/vol+ new file mode 100755 index 0000000..89c8fcb --- /dev/null +++ b/scripts/util/vol+ @@ -0,0 +1,17 @@ +#!/bin/bash + +MASTER_SINK=$(pactl list short sinks | grep "RUNNING" | awk '{print $1}') +if [ $# -eq 0 ] +then + pactl set-sink-volume $MASTER_SINK +5% +else + pactl set-sink-volume $MASTER_SINK +$@% +fi +level=$(pactl list sinks | grep -E "RUNNING|Volume" | grep -A1 "RUNNING" | grep -E -o "[[:digit:]]{1,5}%" | head -n1) +printf '%s\n' "Vol $(echo $level)" | dzen2 -p 1 -bg white -fg black -x -375 -y 50 -w 275 -h 50 + +#amixer -D pulse sset Master -c 3 5%+ +#level=$(amixer -D pulse sget Master -c 3 | sed -n 's/^[^[]*\[\([0-9]*%\)\].*$/\1/p') +#3printf '%s\n' "Vol $(echo $level)" | dzen2 -p 1 -bg white -fg black -x -375 -y 50 -w 275 -h 50 + +#amixer set Master -c 3 5%+ > /dev/null 2>&1 ; a="$()" ; printf '%s\n' "Vol $(amixer -c 3 sget Master | awk -F'[][]' '/Mono: Playback/ {print $2}')" | dzen2 -p 1 -bg white -fg black -x -375 -y 50 -w 275 -h 50 diff --git a/scripts/util/vol- b/scripts/util/vol- new file mode 100755 index 0000000..c2c2f9c --- /dev/null +++ b/scripts/util/vol- @@ -0,0 +1,22 @@ +#!/bin/bash + + +MASTER_SINK=$(pactl list short sinks | grep "RUNNING" | awk '{print $1}') +if [ $# -eq 0 ] +then + pactl set-sink-volume $MASTER_SINK -5% +else + pactl set-sink-volume $MASTER_SINK -$@% +fi + +level=$(pactl list sinks | grep -E "RUNNING|Volume" | grep -A1 "RUNNING" | grep -E -o "[[:digit:]]{1,5}%" | head -n1) +printf '%s\n' "Vol $(echo $level)" | dzen2 -p 1 -bg white -fg black -x -375 -y 50 -w 275 -h 50 + + +#amixer -D pulse sset Master -c 3 5%- + +#level=$(amixer -D pulse sget Master -c 3 | grep 'Front Left:' | sed -E 's/.*\[([0-9]+%)\].*/\1/') +#level=$(amixer -D pulse sget Master -c 3 | sed -n 's/^[^[]*\[\([0-9]*%\)\].*$/\1/p') +#printf '%s\n' "Vol $(echo $level)" | dzen2 -p 1 -bg white -fg black -x -375 -y 50 -w 275 -h 50 + +#amixer set Master -c 2 5%- > /dev/null 2>&1 ; a="$()" ; printf '%s\n' "Vol $(amixer -c 2 sget Master | awk -F'[][]' '/Mono: Playback/ {print $2}')" | dzen2 -p 1 -bg white -fg black -x -375 -y 50 -w 275 -h 50 diff --git a/scripts/util/vpn.sh b/scripts/util/vpn.sh new file mode 100755 index 0000000..b994e5a --- /dev/null +++ b/scripts/util/vpn.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +vpn_stat() +{ + stat=$(mullvad status) + + if echo "$stat" | grep -q "Disconnected"; then + echo 0 + elif echo "$stat" | grep -q "Connected"; then + echo 1 + elif echo "$stat" | grep -q "Connecting"; then + echo "Connecting" + else + echo "Unkown Status" + fi +} + +vpn_stat_verbose() +{ + mullvad status +} + +rand_conn() +{ +relays=$(mullvad relay list | awk 'NR>1 {gsub(/[()]/, "", $2); print $1 "-" $2}' | grep -v '^-$') + + if [ -z "$relays" ]; then + echo "No valid relays found." + return 1 + fi + + random_relay=$(echo "$relays" | shuf -n 1) + + country=$(echo "$random_relay" | cut -d'-' -f1) + city=$(echo "$random_relay" | cut -d'-' -f2) + + mullvad relay set location $country $city + mullvad connect + echo "Connected to $country $city" +} + + + +if [ "$#" -eq 0 ] || [ "$1" = "-s" ]; then + if [ "$#" -eq 2 ] && [ "$2" = "-v" ]; then + vpn_stat_verbose + else + vpn_stat + fi +elif [ "$1" = "-c" ]; then + if [ "$2" = "--rand" ]; then + rand_conn + elif [ "$#" -eq 3 ]; then + country=$2 + city=$3 + mullvad relay set location $country $city + mullvad connect + echo "Connected to $country $city" + else + echo "Invalid usage. Use ./vpn.sh -c [country] [city] or ./vpn.sh -c --rand" + exit 1 + fi +fi |