diff options
Diffstat (limited to '.local/bin')
42 files changed, 553 insertions, 0 deletions
diff --git a/.local/bin/alarm b/.local/bin/alarm new file mode 100755 index 0000000..2909ecf --- /dev/null +++ b/.local/bin/alarm | |||
@@ -0,0 +1,17 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | [ $1 = "-h" -o $1 = "--help" ] && echo "usage: alarm time sound_file" && exit 0 | ||
4 | [ $# != 2 ] && echo "usage: alarm time sound_file" && exit 1 | ||
5 | |||
6 | echo "alarm set for $1" | ||
7 | echo "$(basename "$2") is the alarm tone" | ||
8 | |||
9 | while [ $(date +%H:%M) != "$1" ] | ||
10 | do | ||
11 | sleep 1 | ||
12 | done | ||
13 | |||
14 | amixer -q sset Master 100% unmute | ||
15 | pkill -RTMIN+10 i3blocks | ||
16 | mpv --loop=inf $2 | ||
17 | |||
diff --git a/.local/bin/backups/borg-offsite b/.local/bin/backups/borg-offsite new file mode 100755 index 0000000..dfc9c01 --- /dev/null +++ b/.local/bin/backups/borg-offsite | |||
@@ -0,0 +1,25 @@ | |||
1 | #!/bin/sh | ||
2 | # Full system backup with Borg | ||
3 | |||
4 | # Backup root partition | ||
5 | sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \ | ||
6 | --exclude '/dev/*' \ | ||
7 | --exclude '/proc/*' \ | ||
8 | --exclude '/sys/*' \ | ||
9 | --exclude '/tmp/*' \ | ||
10 | --exclude '/mnt/*' \ | ||
11 | --exclude '/media/*' \ | ||
12 | "/mnt/offsite-backup/titan::root-{now:%Y-%m-%d}" / | ||
13 | |||
14 | # Backup boot parition | ||
15 | sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \ | ||
16 | "/mnt/offsite-backup/titan::boot-{now:%Y-%m-%d}" /boot | ||
17 | |||
18 | # Backup home partition | ||
19 | sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \ | ||
20 | "/mnt/offsite-backup/titan::home-{now:%Y-%m-%d}" /home | ||
21 | |||
22 | # Backup var partition | ||
23 | sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \ | ||
24 | "/mnt/offsite-backup/titan::var-{now:%Y-%m-%d}" /var | ||
25 | |||
diff --git a/.local/bin/backups/borg-onsite b/.local/bin/backups/borg-onsite new file mode 100755 index 0000000..658c425 --- /dev/null +++ b/.local/bin/backups/borg-onsite | |||
@@ -0,0 +1,25 @@ | |||
1 | #!/bin/sh | ||
2 | # Full system backup with Borg | ||
3 | |||
4 | # Backup root partition | ||
5 | sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \ | ||
6 | --exclude '/dev/*' \ | ||
7 | --exclude '/proc/*' \ | ||
8 | --exclude '/sys/*' \ | ||
9 | --exclude '/tmp/*' \ | ||
10 | --exclude '/mnt/*' \ | ||
11 | --exclude '/media/*' \ | ||
12 | "/mnt/onsite-backup/titan::root-{now:%Y-%m-%d}" / | ||
13 | |||
14 | # Backup boot parition | ||
15 | sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \ | ||
16 | "/mnt/onsite-backup/titan::boot-{now:%Y-%m-%d}" /boot | ||
17 | |||
18 | # Backup home partition | ||
19 | sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \ | ||
20 | "/mnt/onsite-backup/titan::home-{now:%Y-%m-%d}" /home | ||
21 | |||
22 | # Backup var partition | ||
23 | sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \ | ||
24 | "/mnt/onsite-backup/titan::var-{now:%Y-%m-%d}" /var | ||
25 | |||
diff --git a/.local/bin/bgscript b/.local/bin/bgscript new file mode 100755 index 0000000..4ec7706 --- /dev/null +++ b/.local/bin/bgscript | |||
@@ -0,0 +1,4 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | #feh --no-fehbg --recursive --randomize --bg-scale ~/pictures/wallpapers | ||
4 | feh --no-fehbg --bg-scale ~/pictures/wallpapers/miscbest/4.jpg | ||
diff --git a/.local/bin/cmus/toggle-mode b/.local/bin/cmus/toggle-mode new file mode 100755 index 0000000..e73edc6 --- /dev/null +++ b/.local/bin/cmus/toggle-mode | |||
@@ -0,0 +1,14 @@ | |||
1 | #!/bin/sh | ||
2 | # Toggles the cmus aaa mode (all,album,artist) | ||
3 | |||
4 | cmus-remote -C "toggle aaa_mode" | ||
5 | mode=$(cmus-remote -Q | grep "aaa_mode" | cut -d ' ' -f 3) | ||
6 | artist=$(cmus-remote -Q | grep "tag artist" | cut -d ' ' -f 3-) | ||
7 | album=$(cmus-remote -Q | grep "tag album" | cut -d ' ' -f 3-) | ||
8 | |||
9 | [ "$mode" = "all" ] && dunstctl close-all && notify-send "Playing from full library" \ | ||
10 | && exit | ||
11 | [ "$mode" = "artist" ] && dunstctl close-all && notify-send "Playing by artist: $artist" \ | ||
12 | && exit | ||
13 | [ "$mode" = "album" ] && dunstctl close-all && notify-send "Playing from album: $album" \ | ||
14 | && exit | ||
diff --git a/.local/bin/cmus/toggle-shuf b/.local/bin/cmus/toggle-shuf new file mode 100755 index 0000000..57c2606 --- /dev/null +++ b/.local/bin/cmus/toggle-shuf | |||
@@ -0,0 +1,7 @@ | |||
1 | #!/bin/sh | ||
2 | # Toggle and report status of shuffle mode in cmus | ||
3 | |||
4 | cmus-remote --shuffle | ||
5 | status=$(cmus-remote -Q | grep shuffle | cut -d ' ' -f 3) | ||
6 | dunstctl close-all | ||
7 | [ "$status" = "true" ] && notify-send "Shuffle on" || notify-send "Shuffle off" | ||
diff --git a/.local/bin/compile b/.local/bin/compile new file mode 100755 index 0000000..837766b --- /dev/null +++ b/.local/bin/compile | |||
@@ -0,0 +1,14 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Script for automatic compilation (or interpretation) of various file types | ||
4 | # The filename needs to be passed to this script as the only argument | ||
5 | file="$1" | ||
6 | base="${file%.*}" | ||
7 | ext="${file##*.}" | ||
8 | |||
9 | case $ext in | ||
10 | mom) groff -mom -Tpdf "$file" > "$base.pdf" ;; | ||
11 | ms) groff -me -Tpdf "$file" > "$base.pdf" ;; | ||
12 | me) groff -me -Tpdf "$file" > "$base.pdf" ;; | ||
13 | py) python3 "$file" ;; | ||
14 | esac | ||
diff --git a/.local/bin/cryptusb/create-cryptusb b/.local/bin/cryptusb/create-cryptusb new file mode 100755 index 0000000..e0f49fe --- /dev/null +++ b/.local/bin/cryptusb/create-cryptusb | |||
@@ -0,0 +1,34 @@ | |||
1 | #!/bin/sh | ||
2 | # Prompts for and creates a LUKS encrypted partition on a device | ||
3 | |||
4 | # Get disks connected to the system that are hotpluggable (USBs) | ||
5 | devices="$(lsblk -lp -o NAME,SIZE,HOTPLUG,TYPE | grep "1 disk" | awk '{print $1,"-",$2}')" | ||
6 | [ "$devices" = "" ] && echo "no devices available" && exit 0 | ||
7 | |||
8 | # Prompt for device selection from the user | ||
9 | select=$(echo "$devices" | dmenu -i -p "Select a device") | ||
10 | [ "$select" = "" ] && echo "no device selected" && exit 0 | ||
11 | |||
12 | # Get confirmation since this is a potentially dangerous operation | ||
13 | yn=$(echo "No\nYes" | dmenu -i -p "Create encrypted partition on $select") | ||
14 | [ "$yn" != "Yes" ] && exit 0 | ||
15 | |||
16 | # Get device path from selection string | ||
17 | usb=$(echo $select | cut -d ' ' -f 1) | ||
18 | echo $usb | ||
19 | |||
20 | # Create LUKS partition on selected device (user will be promted for password to encrypt) | ||
21 | sudo cryptsetup --type luks2 luksFormat "$usb" | ||
22 | |||
23 | # Open device and create filesystem on partition | ||
24 | echo "creating filesystem" | ||
25 | map_name="crypt-create" | ||
26 | sudo cryptsetup open "$usb" "$map_name" | ||
27 | sudo mkfs.ext4 "/dev/mapper/$map_name" | ||
28 | |||
29 | # Close device after creating filesystem | ||
30 | sudo cryptsetup close "$map_name" | ||
31 | |||
32 | echo "done" | ||
33 | |||
34 | |||
diff --git a/.local/bin/cryptusb/handle-cryptusb b/.local/bin/cryptusb/handle-cryptusb new file mode 100755 index 0000000..63d6ef4 --- /dev/null +++ b/.local/bin/cryptusb/handle-cryptusb | |||
@@ -0,0 +1,8 @@ | |||
1 | #!/bin/sh | ||
2 | # Single script for easy handling of encrypted USB | ||
3 | # Calls mount, sync, and umount scripts to automatically handle what is commonly | ||
4 | # run for encrypted USBs | ||
5 | |||
6 | mount-cryptusb && notify-send "Encrypted USB mounted" | ||
7 | sync-cryptusb && notify-send "Encrypted USB synced" | ||
8 | umount-cryptusb && notify-send "Encrypted USB unmounted" | ||
diff --git a/.local/bin/cryptusb/mount-cryptusb b/.local/bin/cryptusb/mount-cryptusb new file mode 100755 index 0000000..882734c --- /dev/null +++ b/.local/bin/cryptusb/mount-cryptusb | |||
@@ -0,0 +1,5 @@ | |||
1 | #!/bin/sh | ||
2 | # Mounts LUKS encrypted USB | ||
3 | |||
4 | sudo cryptsetup open /dev/sdc cryptusb | ||
5 | sudo mount /dev/mapper/cryptusb /mnt/cryptusb | ||
diff --git a/.local/bin/cryptusb/sync-cryptusb b/.local/bin/cryptusb/sync-cryptusb new file mode 100755 index 0000000..e9d3f1a --- /dev/null +++ b/.local/bin/cryptusb/sync-cryptusb | |||
@@ -0,0 +1,6 @@ | |||
1 | #!/bin/sh | ||
2 | # Syncs important files to encrypted USB | ||
3 | |||
4 | rsync -avP --exclude=".steam*" --exclude="virtual_machines*" --exclude="media*" \ | ||
5 | --exclude="*.iso" --exclude="*.qcow2" \ | ||
6 | $HOME/ /mnt/cryptusb/$USER@$(hostname)/ | ||
diff --git a/.local/bin/cryptusb/umount-cryptusb b/.local/bin/cryptusb/umount-cryptusb new file mode 100755 index 0000000..c3c4b93 --- /dev/null +++ b/.local/bin/cryptusb/umount-cryptusb | |||
@@ -0,0 +1,5 @@ | |||
1 | #!/bin/sh | ||
2 | # Unmounts LUKS encrypted USB | ||
3 | |||
4 | sudo umount /mnt/cryptusb | ||
5 | sudo cryptsetup close cryptusb | ||
diff --git a/.local/bin/dmenu/mount-device b/.local/bin/dmenu/mount-device new file mode 100755 index 0000000..e325a65 --- /dev/null +++ b/.local/bin/dmenu/mount-device | |||
@@ -0,0 +1,27 @@ | |||
1 | #!/bin/sh | ||
2 | # Script for mounting block devices | ||
3 | |||
4 | # Set askpass program for authentication | ||
5 | export SUDO_ASKPASS=/usr/bin/ssh-askpass | ||
6 | |||
7 | # Check for and get device to mount from user | ||
8 | devs="$(lsblk -lp | grep "part $" | awk '{print $1,"-",$4}')" | ||
9 | [ "$devs" = "" ] && exit 0 | ||
10 | dev="$(echo $devs | dmenu -i -p "Select device" | cut -d ' ' -f 1)" | ||
11 | [ "$dev" = "" ] && exit 0 | ||
12 | |||
13 | # Attempt to mount without mountpoint for devices in /etc/fstab | ||
14 | sudo -A mount "$dev" 2>/dev/null && exit 0 | ||
15 | |||
16 | # Get mountpoint from user | ||
17 | mntpnt="$(find /mnt -maxdepth 3 -type d 2>/dev/null | dmenu -i -p "Select mountpoint")" | ||
18 | [ "$mntpnt" = "" ] && exit 1 | ||
19 | |||
20 | # If selected mountpoint does not exist ask to create it | ||
21 | # If user decides not to create non-existent drive, exit | ||
22 | [ ! -d $mntpnt ] && create="$(echo "No\nYes" | \ | ||
23 | dmenu -i -p "$mntpnt does not exist, would you like to create it?")" && \ | ||
24 | ([ "$create" = "Yes" ] && sudo -A mkdir -p $mntpnt || exit 0) | ||
25 | |||
26 | sudo -A mount $dev $mntpnt && pgrep -x dunst && notify-send "$dev mounted to $mntpnt" | ||
27 | |||
diff --git a/.local/bin/dmenu/unicode-select b/.local/bin/dmenu/unicode-select new file mode 100755 index 0000000..f42cd6e --- /dev/null +++ b/.local/bin/dmenu/unicode-select | |||
@@ -0,0 +1,9 @@ | |||
1 | #!/bin/sh | ||
2 | # Select unicode character via dmenu and copy to clipboard | ||
3 | |||
4 | line="$(cat ~/.local/share/unicode_list | dmenu -i -l 10)" | ||
5 | grep "$line" ~/.local/src/unicode_list | tr -d [:print:] | | ||
6 | xclip -r -selection "clipboard" && | ||
7 | notify-send "$(xclip -selection "clipboard" -o) copied to clipboard" | ||
8 | |||
9 | |||
diff --git a/.local/bin/dmenu/unmount-device b/.local/bin/dmenu/unmount-device new file mode 100755 index 0000000..75cb10f --- /dev/null +++ b/.local/bin/dmenu/unmount-device | |||
@@ -0,0 +1,19 @@ | |||
1 | #!/bin/sh | ||
2 | # Script for unmounting filesystems | ||
3 | |||
4 | # Set askpass program for authentication | ||
5 | export SUDO_ASKPASS=/usr/bin/ssh-askpass | ||
6 | |||
7 | # Get list of unmountable filesystems excluding critical ones (/, /home, /boot, etc...) | ||
8 | exclude="\(/\|/boot\|/boot/efi\|/var\|/tmp\|/home\)$" | ||
9 | parts="$(lsblk -lp | grep "part /" | grep -v "$exclude" | awk '{print $7,"-",$4}')" | ||
10 | [ "$parts" = "" ] && exit 0 | ||
11 | |||
12 | # Get filesystem to unmount from user | ||
13 | select="$(echo "$parts" | dmenu -i -p "Select filesystem to unmount" | cut -d ' ' -f 1)" | ||
14 | [ "$select" = "" ] && exit 0 | ||
15 | dev="$(lsblk -lp | grep "$select" | awk '{print $1}')" | ||
16 | |||
17 | # Unmount the filesystem | ||
18 | sudo -A umount $select && pgrep -x dunst && notify-send "Unmounted $select ($dev)" \ | ||
19 | || notify-send "Error: unable to unmount $select" "Are you in it?" | ||
diff --git a/.local/bin/exiti3 b/.local/bin/exiti3 new file mode 100755 index 0000000..0fe76bf --- /dev/null +++ b/.local/bin/exiti3 | |||
@@ -0,0 +1,4 @@ | |||
1 | #!/bin/sh | ||
2 | read -p "Exit i3 [Y]/n?" exit | ||
3 | [ "$exit" = "Y" ] && i3-msg exit | ||
4 | |||
diff --git a/.local/bin/ffmpeg-convert b/.local/bin/ffmpeg-convert new file mode 100755 index 0000000..171a97b --- /dev/null +++ b/.local/bin/ffmpeg-convert | |||
@@ -0,0 +1,60 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Converts audio/video files to a different specified container format with ffmpeg | ||
4 | # Depends on the youtube-filename-fixer script for cleaining up YouTube filenames | ||
5 | |||
6 | usage() { | ||
7 | echo "usage: ffmpeg-convert [options] container video_codec audio_codec files" | ||
8 | echo "\npositional parameters" | ||
9 | echo "\tcontainer\textension of the container that is being converted to" | ||
10 | echo "\tvideo_codec\tvideo codec of the output file" | ||
11 | echo "\taudio_codec\taudio codec of the output file" | ||
12 | echo "\noptions" | ||
13 | echo "\t-d\tdelete original files after conversion" | ||
14 | echo "\t-h\tshow this help and exit" | ||
15 | } | ||
16 | stdin() { | ||
17 | while read -r infile | ||
18 | do | ||
19 | outfile="$(echo $infile | rev | cut -d '.' -f 2 | rev)$container" | ||
20 | echo "converting $infile -> $outfile..." | ||
21 | ffmpeg -nostdin -loglevel 16 -i "$infile" -c:v $video -c:a $audio "$outfile" | ||
22 | [ $delete -eq 1 ] && rm -v "$infile" | ||
23 | done | ||
24 | } | ||
25 | cli() { | ||
26 | for infile in $@ | ||
27 | do | ||
28 | outfile="$(echo $infile | rev | cut -d '.' -f 2 | rev)$container" | ||
29 | echo "converting $infile -> $outfile..." | ||
30 | ffmpeg -nostdin -loglevel 16 -i "$infile" -c:v $video -c:a $audio "$outfile" | ||
31 | [ $delete -eq 1 ] && rm -v "$infile" | ||
32 | done | ||
33 | } | ||
34 | |||
35 | options=$(getopt -o 'dhs' -- "$@") | ||
36 | eval set -- "$options" | ||
37 | delete=0 | ||
38 | stdin=0 | ||
39 | while true | ||
40 | do | ||
41 | case $1 in | ||
42 | '-h') usage ; exit 0 ;; | ||
43 | '-d') delete=1; shift; continue ;; | ||
44 | '-s') stdin=1; shift; continue ;; | ||
45 | '--') shift; break;; | ||
46 | *) echo "internal error"; exit 1 ;; | ||
47 | esac | ||
48 | done | ||
49 | [ $# -ge 3 ] || (usage && exit 1) | ||
50 | |||
51 | # Set variables specified on command line | ||
52 | container="$1"; shift; video="$1"; shift; audio="$1"; shift; | ||
53 | |||
54 | # Prepend a dot to the container name if not specified already | ||
55 | [ "${container#.}" = "$container" ] && container=".$container" | ||
56 | |||
57 | # If there is only one file argument and it is "-" | ||
58 | [ $stdin -eq 1 ] && stdin || cli $@ | ||
59 | |||
60 | |||
diff --git a/.local/bin/get-pkgs b/.local/bin/get-pkgs new file mode 100755 index 0000000..19e64f3 --- /dev/null +++ b/.local/bin/get-pkgs | |||
@@ -0,0 +1,8 @@ | |||
1 | #!/bin/sh | ||
2 | # Creates files containing lists of installed and manually installed packages | ||
3 | # in cache directory | ||
4 | |||
5 | pkgdir="$HOME/.cache/packages" | ||
6 | apt list --installed | tail -n+2 | cut -d '/' -f 1 > $pkgdir/installed | ||
7 | apt list --manual-installed | tail -n+2 | | ||
8 | cut -d '/' -f 1 > $pkgdir/manual-installed | ||
diff --git a/.local/bin/kbremaps b/.local/bin/kbremaps new file mode 100755 index 0000000..b914b7f --- /dev/null +++ b/.local/bin/kbremaps | |||
@@ -0,0 +1,7 @@ | |||
1 | #!/bin/sh | ||
2 | # Script for keyboard changes | ||
3 | |||
4 | # Change autorepeat rate | ||
5 | xset r rate 300 50 | ||
6 | # Remap caps lock and escape | ||
7 | setxkbmap -option caps:swapescape | ||
diff --git a/.local/bin/kill-steam b/.local/bin/kill-steam new file mode 100755 index 0000000..5572ae7 --- /dev/null +++ b/.local/bin/kill-steam | |||
@@ -0,0 +1,3 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | pkill -f steam | ||
diff --git a/.local/bin/lock b/.local/bin/lock new file mode 100755 index 0000000..223ac59 --- /dev/null +++ b/.local/bin/lock | |||
@@ -0,0 +1,7 @@ | |||
1 | #!/bin/sh | ||
2 | # Locks the screen with a blurred screenshot of the current window as the lock image | ||
3 | # Also pauses any music that is playing | ||
4 | |||
5 | maim | convert - -paint 5 ~/.cache/lock.png | ||
6 | [ "$(cmus-remote -Q | head -1 | cut -d ' ' -f 2)" != "playing" ] || cmus-remote --pause | ||
7 | i3lock -u -e -i ~/.cache/lock.png | ||
diff --git a/.local/bin/mount-media b/.local/bin/mount-media new file mode 100755 index 0000000..e748941 --- /dev/null +++ b/.local/bin/mount-media | |||
@@ -0,0 +1,6 @@ | |||
1 | #!/bin/sh | ||
2 | # Uses sshfs to locally mount media directories | ||
3 | # Check if the media computer is reachable and if so mount the media | ||
4 | ping -W 0.01 -c 1 prometheus >/dev/null && \ | ||
5 | sshfs sisko@prometheus:/mnt/raid/media/ $HOME/media/prometheus/ | ||
6 | |||
diff --git a/.local/bin/pdf-preview b/.local/bin/pdf-preview new file mode 100755 index 0000000..1587f36 --- /dev/null +++ b/.local/bin/pdf-preview | |||
@@ -0,0 +1,8 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Typically called from vim | ||
4 | # Displays a pdf preview of an in-progress groff document | ||
5 | # Takes the filename as the only argument | ||
6 | # The pdf file is expected to have the same name as the groff document | ||
7 | |||
8 | zathura "${1%.*}.pdf" & | ||
diff --git a/.local/bin/screenshot b/.local/bin/screenshot new file mode 100755 index 0000000..3f24f70 --- /dev/null +++ b/.local/bin/screenshot | |||
@@ -0,0 +1,8 @@ | |||
1 | #!/bin/sh | ||
2 | # Take screenshot with interactive area selection | ||
3 | # Saves screenshot with timestamp in directory named after the date | ||
4 | |||
5 | time=$(date +%b-%d-%Y-%T.%N) | ||
6 | day=$(date +%b-%d-%Y) | ||
7 | [ -d ~/pictures/screenshots/$day ] || mkdir ~/pictures/screenshots/$day | ||
8 | maim -s > ~/pictures/screenshots/$day/$time.png && notify-send "Screenshot Taken" | ||
diff --git a/.local/bin/signal-vol b/.local/bin/signal-vol new file mode 100755 index 0000000..e5739f6 --- /dev/null +++ b/.local/bin/signal-vol | |||
@@ -0,0 +1,4 @@ | |||
1 | #!/bin/sh | ||
2 | # Signals the dwmblocks volume block to update | ||
3 | |||
4 | pkill -RTMIN+10 dwmblocks | ||
diff --git a/.local/bin/statusbar/bar-calcurse b/.local/bin/statusbar/bar-calcurse new file mode 100755 index 0000000..dca82f3 --- /dev/null +++ b/.local/bin/statusbar/bar-calcurse | |||
@@ -0,0 +1,15 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | #i3blocks calcurse module | ||
4 | |||
5 | case $BUTTON in | ||
6 | 3)notify-send -t 5000 "$(calcurse -D ~/.config/calcurse/ -c ~/.config/calcurse/apts -a)";; | ||
7 | 1)notify-send -t 20000 "$(calcurse -D ~/.config/calcurse/ -c ~/.config/calcurse/apts -r7)";; | ||
8 | 2)notify-send -t 5000 "$(calcurse -D ~/.config/calcurse/ -t)" | ||
9 | esac | ||
10 | |||
11 | name="$(calcurse -D ~/.config/calcurse/ -c ~/.config/calcurse/apts -n | grep "\[" | sed "s/\s*\[/\[/" | cut -d ' ' -f 2-)" | ||
12 | [ "$name" = "" ] && echo "Nothing Scheduled" && exit 0 | ||
13 | time="$(grep "$name" ~/.config/calcurse/apts | head -1 | cut -d ' ' -f 3)" | ||
14 | [ ${time%%:*} -gt 12 ] && time="$((${time%%:*}-12)):${time##*:} PM" || time="$time AM" | ||
15 | echo "$name @ $time" | ||
diff --git a/.local/bin/statusbar/bar-cmus b/.local/bin/statusbar/bar-cmus new file mode 100755 index 0000000..947f950 --- /dev/null +++ b/.local/bin/statusbar/bar-cmus | |||
@@ -0,0 +1,25 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | case $BUTTON in | ||
4 | 1)notify-send "$(cmus-remote -Q | grep position | awk '{ printf "%02i:%02i", $2/60, $2%60}')/$(cmus-remote -Q | grep duration | awk '{ printf "%02i:%02i\n", $2/60, $2%60} ') ($(cmus-remote -Q | grep status | cut -d ' ' -f 2-)) | ||
5 | Artist: $(cmus-remote -Q | grep "tag artist " | cut -d ' ' -f 3-) | ||
6 | Album: $(cmus-remote -Q | grep "tag album " | cut -d ' ' -f 3-) | ||
7 | Track: $(cmus-remote -Q | grep "tag title " | cut -d ' ' -f 3-) | ||
8 | Genre: $(cmus-remote -Q | grep "tag genre " | cut -d ' ' -f 3-) | ||
9 | Mode: $(cmus-remote -Q | grep "aaa_mode" | cut -d ' ' -f 3) | ||
10 | Format: $(cmus-remote -Q | grep file | rev | cut -d '.' -f 1 | rev) | ||
11 | Shuffle: $(cmus-remote -Q | grep "set shuffle " | cut -d ' ' -f 3-) | ||
12 | Repeat: $(cmus-remote -Q | grep "set repeat_current " | cut -d ' ' -f 3-)";; | ||
13 | |||
14 | 3)urxvt -e vim ~/.local/bin/statusbar/cmus;; | ||
15 | 4)cmus-remote --next;; | ||
16 | 5)cmus-remote --prev;; | ||
17 | esac | ||
18 | |||
19 | pgrep -x cmus >/dev/null || exit 0 | ||
20 | |||
21 | status="$(cmus-remote -Q | grep status | cut -d ' ' -f 2)" | ||
22 | artist="$(cmus-remote -Q | grep "tag artist" | cut -d ' ' -f 3- | tr -d "\n")" | ||
23 | track="$(cmus-remote -Q | grep "tag title" | cut -d ' ' -f 3- | tr -d "\n")" | ||
24 | echo -n "$artist - $track" | ||
25 | [ "$status" = "playing" ] || echo -n " [P]" | ||
diff --git a/.local/bin/statusbar/bar-cpu b/.local/bin/statusbar/bar-cpu new file mode 100755 index 0000000..c21fe20 --- /dev/null +++ b/.local/bin/statusbar/bar-cpu | |||
@@ -0,0 +1,7 @@ | |||
1 | #!/bin/sh | ||
2 | case $BUTTON in | ||
3 | 1) notify-send "$(ps axc -o cmd:15,%cpu --sort=-%cpu | head -6)";; | ||
4 | 3) urxvt -e vim ~/.local/bin/statusbar/cpu | ||
5 | esac | ||
6 | mpstat 1 1 | awk '/Average/ { printf "%.2f% ",100-$12 }' | ||
7 | temp="$(sensors | awk '/Tctl/ { print $2 } ')"; echo -n ${temp#+} | ||
diff --git a/.local/bin/statusbar/bar-gpu b/.local/bin/statusbar/bar-gpu new file mode 100755 index 0000000..5351a2f --- /dev/null +++ b/.local/bin/statusbar/bar-gpu | |||
@@ -0,0 +1,6 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | temp="$(sensors | awk '/edge/ { print $2 } ')" | ||
4 | fan="$(sensors | awk '/fan1/ { print $2 } ')" | ||
5 | power="$(sensors | awk '/power1/ { print $2 } ')" | ||
6 | echo -n "${temp#+} $fan RPM" | ||
diff --git a/.local/bin/statusbar/bar-ipv4 b/.local/bin/statusbar/bar-ipv4 new file mode 100755 index 0000000..4e51eca --- /dev/null +++ b/.local/bin/statusbar/bar-ipv4 | |||
@@ -0,0 +1,9 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | case $BUTTON in | ||
4 | 1)notify-send --expire-time=60000 "IP Addresses" "$(ip a | awk '/\/24|\/64/ {if($5=="temporary")print $2 " " $5;else print $2;}')";; | ||
5 | 3)urxvt -e ~/.local/bin/statusbar/ipv4 | ||
6 | esac | ||
7 | ip a | awk '/\/24/ { print $2 }' | cut -d '/' -f 1 | ||
8 | |||
9 | |||
diff --git a/.local/bin/statusbar/bar-memory b/.local/bin/statusbar/bar-memory new file mode 100755 index 0000000..1e98cca --- /dev/null +++ b/.local/bin/statusbar/bar-memory | |||
@@ -0,0 +1,8 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | case $BUTTON in | ||
4 | 1)notify-send "$(ps axc -o cmd:15,%mem --sort=-%mem | head -6)";; | ||
5 | 3)urxvt -e vim ~/.local/bin/statusbar/memory | ||
6 | esac | ||
7 | free --si -h | grep Mem | awk '{ print $3 "/" $2 }' | ||
8 | |||
diff --git a/.local/bin/statusbar/bar-storage b/.local/bin/statusbar/bar-storage new file mode 100755 index 0000000..d7b5fcf --- /dev/null +++ b/.local/bin/statusbar/bar-storage | |||
@@ -0,0 +1,7 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | case $BUTTON in | ||
4 | 1)notify-send "$(df -H | grep "Filesystem\|/dev/sd")";; | ||
5 | 3)urxvt -e vim ~/.local/bin/statusbar/storage | ||
6 | esac | ||
7 | df -H | awk '/\/home/ { print $4 }' | ||
diff --git a/.local/bin/statusbar/bar-time b/.local/bin/statusbar/bar-time new file mode 100755 index 0000000..f61a268 --- /dev/null +++ b/.local/bin/statusbar/bar-time | |||
@@ -0,0 +1,7 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | case $BUTTON in | ||
4 | 1)notify-send "$(ncal -hb)";; | ||
5 | 3)urxvt -e vim ~/.local/bin/statusbar/time | ||
6 | esac | ||
7 | date +"%r %A %D" | ||
diff --git a/.local/bin/statusbar/bar-volume b/.local/bin/statusbar/bar-volume new file mode 100755 index 0000000..d9bcc9d --- /dev/null +++ b/.local/bin/statusbar/bar-volume | |||
@@ -0,0 +1,13 @@ | |||
1 | #!/bin/sh | ||
2 | # i3blocks volume module | ||
3 | |||
4 | case $BUTTON in | ||
5 | 1)urxvt -e alsamixer;; | ||
6 | 3)urxvt -e vim ~/.local/bin/statusbar/volume;; | ||
7 | 4)amixer -q sset Master 1%+ unmute;; | ||
8 | 5)amixer -q sset Master 1%- unmute;; | ||
9 | esac | ||
10 | |||
11 | stats=$(amixer sget Master | grep "Front Left:" | cut -d ' ' -f 7,8 | tr -d '[]') | ||
12 | [ "${stats##* }" = "on" ] && echo -n "${stats%% *}" || echo -n "${stats%% *}" | ||
13 | |||
diff --git a/.local/bin/stop-alarm b/.local/bin/stop-alarm new file mode 100755 index 0000000..4607b11 --- /dev/null +++ b/.local/bin/stop-alarm | |||
@@ -0,0 +1,5 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | pkill mpv | ||
4 | amixer -q sset Master 50% | ||
5 | pkill -RTMIN+10 i3blocks | ||
diff --git a/.local/bin/sync-music b/.local/bin/sync-music new file mode 100755 index 0000000..4619a23 --- /dev/null +++ b/.local/bin/sync-music | |||
@@ -0,0 +1,4 @@ | |||
1 | #!/bin/sh | ||
2 | # Sync music from media computer to local computer | ||
3 | |||
4 | rsync -av sisko@prometheus:/mnt/raid/media/music/ $HOME/media/music/ | ||
diff --git a/.local/bin/theme/get-gradient b/.local/bin/theme/get-gradient new file mode 100755 index 0000000..91f9391 --- /dev/null +++ b/.local/bin/theme/get-gradient | |||
@@ -0,0 +1,13 @@ | |||
1 | #!/bin/sh | ||
2 | # Gets and sets a color gradient for cava | ||
3 | |||
4 | start="$1" | ||
5 | end="$2" | ||
6 | colors=$(~/.local/bin/theme/gradient.py $start $end 7) | ||
7 | |||
8 | num=1 | ||
9 | path="$HOME/.config/cava/config" | ||
10 | for color in $colors; do | ||
11 | sed -i "s/gradient_color_$num.*$/gradient_color_$num = '$color'/" $path | ||
12 | num=$((num+1)) | ||
13 | done | ||
diff --git a/.local/bin/theme/gradient.py b/.local/bin/theme/gradient.py new file mode 100755 index 0000000..f95bb07 --- /dev/null +++ b/.local/bin/theme/gradient.py | |||
@@ -0,0 +1,24 @@ | |||
1 | #!/usr/bin/python3 | ||
2 | # Gets a color gradient based on input color and number | ||
3 | # Depends on python3-colour | ||
4 | |||
5 | import colour,sys | ||
6 | |||
7 | if len(sys.argv) != 4: | ||
8 | print("arg error") | ||
9 | sys.exit(1) | ||
10 | |||
11 | start = sys.argv[1] | ||
12 | end = sys.argv[2] | ||
13 | num = int(sys.argv[3]) | ||
14 | |||
15 | grad = colour.color_scale(colour.hex2hsl(start),colour.hex2hsl(end),num) | ||
16 | grad_hex = [] | ||
17 | for hsl in grad: | ||
18 | grad_hex.append(colour.hsl2hex(hsl)) | ||
19 | |||
20 | for color in grad_hex: | ||
21 | sys.stdout.write(color + "\n") | ||
22 | |||
23 | |||
24 | |||
diff --git a/.local/bin/volctl b/.local/bin/volctl new file mode 100755 index 0000000..faa8de6 --- /dev/null +++ b/.local/bin/volctl | |||
@@ -0,0 +1,12 @@ | |||
1 | #!/bin/sh | ||
2 | # Script for volume control | ||
3 | # | ||
4 | # Accepts either a number and a +,- operator (volctl 5 +) or "toggle" (volctl toggle) | ||
5 | |||
6 | # If the lone argument is "toggle", toggle mute/unmute | ||
7 | [ "$1" = "toggle" ] && amixer -q sset Master toggle && signal-vol && exit | ||
8 | |||
9 | num=$1 | ||
10 | dir=$2 | ||
11 | |||
12 | amixer -q sset Master $num%$dir unmute && signal-vol | ||
diff --git a/.local/bin/who-depends b/.local/bin/who-depends new file mode 100755 index 0000000..d1fb0c2 --- /dev/null +++ b/.local/bin/who-depends | |||
@@ -0,0 +1,13 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Script that takes a package as an argument and returns installed packages | ||
4 | # that are dependent on it | ||
5 | |||
6 | [ $# -eq 1 ] || echo "usage: who-depends package" | ||
7 | apt list --installed | tail -n+2 | cut -d '/' -f 1 > /tmp/whodepends | ||
8 | pkg="$1" | ||
9 | deps_all=$(apt-cache rdepends $pkg | tail -n+3 | sed "s/^\s*//") | ||
10 | for dep in $deps_all | ||
11 | do | ||
12 | grep -lq "$dep" /tmp/whodepends && echo "$dep" | ||
13 | done | ||
diff --git a/.local/bin/windowshot b/.local/bin/windowshot new file mode 100755 index 0000000..a7b143b --- /dev/null +++ b/.local/bin/windowshot | |||
@@ -0,0 +1,9 @@ | |||
1 | #!/bin/sh | ||
2 | # Take screenshot of current window | ||
3 | # Saves screenshot with timestamp in directory named after the date | ||
4 | |||
5 | time=$(date +%b-%d-%Y-%T.%N) | ||
6 | day=$(date +%b-%d-%Y) | ||
7 | [ -d "~/pictures/screenshots/$day" ] || mkdir -p ~/pictures/screenshots/$day | ||
8 | maim > ~/pictures/screenshots/$day/$time.png && notify-send "Screenshot Taken" | ||
9 | |||
diff --git a/.local/bin/yt-fix b/.local/bin/yt-fix new file mode 100755 index 0000000..69e771a --- /dev/null +++ b/.local/bin/yt-fix | |||
@@ -0,0 +1,42 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Takes files downloaded through youtube-dl and cleans up their filenames | ||
4 | |||
5 | stdin() { | ||
6 | while read -r infile | ||
7 | do | ||
8 | ext=".$(echo $infile | rev | cut -d '.' -f 1 | rev)" | ||
9 | ext_length=${#ext} | ||
10 | remove=$((12+$ext_length)) | ||
11 | filename="$(echo $infile | rev | cut -c $remove- | rev)" | ||
12 | mv "$infile" "$filename$ext" | ||
13 | done | ||
14 | } | ||
15 | |||
16 | cli() { | ||
17 | for infile in "$@" | ||
18 | do | ||
19 | ext=".$(echo $infile | rev | cut -d '.' -f 1 | rev)" | ||
20 | ext_length=${#ext} | ||
21 | remove=$((12+$ext_length)) | ||
22 | filename="$(echo $infile | rev | cut -c $remove- | rev)" | ||
23 | mv "$infile" "$filename$ext" | ||
24 | done | ||
25 | } | ||
26 | |||
27 | options=$(getopt -o 'hsx' -- "$@") | ||
28 | eval set -- "$options" | ||
29 | read_stdin=0 | ||
30 | noext=0 | ||
31 | while true | ||
32 | do | ||
33 | case "$1" in | ||
34 | '-h') echo "usage: yt-fix [options] [files]\n\th\tprint this help and exit\n\tx\tdo not include extension in output\n\ts\tread from stdin"; exit 0;; | ||
35 | '-s') read_stdin=1; shift; continue;; | ||
36 | '-x') noext=1; shift; continue;; | ||
37 | '--') shift; break;; | ||
38 | esac | ||
39 | done | ||
40 | |||
41 | [ $read_stdin -eq 0 ] && cli "$@" || stdin | ||
42 | |||