summaryrefslogtreecommitdiff
path: root/guix/kolwynia/home/bdunahu/files/.local
diff options
context:
space:
mode:
Diffstat (limited to 'guix/kolwynia/home/bdunahu/files/.local')
-rwxr-xr-xguix/kolwynia/home/bdunahu/files/.local/bin/bkup-home6
-rwxr-xr-xguix/kolwynia/home/bdunahu/files/.local/bin/fetch-album38
-rwxr-xr-xguix/kolwynia/home/bdunahu/files/.local/bin/guix-gc7
-rwxr-xr-xguix/kolwynia/home/bdunahu/files/.local/bin/mail-string4
-rwxr-xr-xguix/kolwynia/home/bdunahu/files/.local/bin/sort-music101
-rwxr-xr-xguix/kolwynia/home/bdunahu/files/.local/bin/string-weather3
-rwxr-xr-xguix/kolwynia/home/bdunahu/files/.local/bin/t1-string17
-rwxr-xr-xguix/kolwynia/home/bdunahu/files/.local/bin/tag-media44
-rwxr-xr-xguix/kolwynia/home/bdunahu/files/.local/bin/touchpad-defaults6
-rwxr-xr-xguix/kolwynia/home/bdunahu/files/.local/bin/unfreeze8
-rwxr-xr-xguix/kolwynia/home/bdunahu/files/.local/bin/upload43
-rwxr-xr-xguix/kolwynia/home/bdunahu/files/.local/bin/xkeyboard-auto12
-rwxr-xr-xguix/kolwynia/home/bdunahu/files/.local/bin/xkeyboard-layout12
-rwxr-xr-xguix/kolwynia/home/bdunahu/files/.local/bin/xkeyboard-toggle5
-rwxr-xr-xguix/kolwynia/home/bdunahu/files/.local/bin/xrandr-refresh10
-rwxr-xr-xguix/kolwynia/home/bdunahu/files/.local/bin/xrandr-toggle15
-rwxr-xr-xguix/kolwynia/home/bdunahu/files/.local/bin/xxinit6
17 files changed, 337 insertions, 0 deletions
diff --git a/guix/kolwynia/home/bdunahu/files/.local/bin/bkup-home b/guix/kolwynia/home/bdunahu/files/.local/bin/bkup-home
new file mode 100755
index 0000000..b2d31b6
--- /dev/null
+++ b/guix/kolwynia/home/bdunahu/files/.local/bin/bkup-home
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+cryptsetup open /dev/sdb1 bkup
+mount /dev/mapper/bkup /mnt
+
+rsync -aPHAXSu --inplace --delete /home/ /mnt/
diff --git a/guix/kolwynia/home/bdunahu/files/.local/bin/fetch-album b/guix/kolwynia/home/bdunahu/files/.local/bin/fetch-album
new file mode 100755
index 0000000..3885f88
--- /dev/null
+++ b/guix/kolwynia/home/bdunahu/files/.local/bin/fetch-album
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+err() { echo "Usage:
+ rename [OPTIONS]
+Options:
+ -d: delimiter
+ -a: artist/author
+ -A: album/book title
+ -y: year of publication
+You will be prompted for these fields if not given." && exit 1 ;}
+
+[ "$PWD" = "${HOME}/ik/tmp" ] || { echo "Unsafe directory!" && exit 1 ;}
+
+while getopts "d:a:A:y:" o; do case "${o}" in
+ d) delimiter="${OPTARG}" ;;
+ a) artist="${OPTARG}" ;;
+ A) album="${OPTARG}" ;;
+ y) year="${OPTARG}" ;;
+ *) printf "Invalid option: -%s\\n" "$OPTARG" && err ;;
+ esac done
+files=(*)
+echo "Reference: ${files[0]}"
+[ -z "$delimiter" ] && echo "What are the delimiters for these files?" && read -r delimiter
+echo "Which index contains the track title? (Starting from 1)" && read -r index
+
+[ -z "$artist" ] && echo 'Enter an artist.' && read -r artist
+[ -z "$album" ] && echo 'Enter an album.' && read -r album
+[ -z "$year" ] && echo 'Enter a year.' && read -r year
+
+for file in *;
+do
+ extension=$(echo $file | awk -F "." '{print $NF}')
+ title=$(echo $file | awk -F "${delimiter}" "{print \$${index}}" |
+ sed -re 's/^[[:blank:]]+|[[:blank:]]+$//g' -e 's/[[:blank:]]+/ /g')
+ new_file="${title}_${artist}_${album}_${year}.${extension}"
+ mv "./$file" "./$new_file"
+ tag-media -a "${artist}" -t "${title}" -A "${album}" -d "${year}" "${new_file}"
+done
diff --git a/guix/kolwynia/home/bdunahu/files/.local/bin/guix-gc b/guix/kolwynia/home/bdunahu/files/.local/bin/guix-gc
new file mode 100755
index 0000000..23a423b
--- /dev/null
+++ b/guix/kolwynia/home/bdunahu/files/.local/bin/guix-gc
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+sudo guix system delete-generations 2w
+guix home delete-generations 2w
+guix package --delete-generations=2w
+guix pull --delete-generations=2w
+guix gc
diff --git a/guix/kolwynia/home/bdunahu/files/.local/bin/mail-string b/guix/kolwynia/home/bdunahu/files/.local/bin/mail-string
new file mode 100755
index 0000000..e4f1d20
--- /dev/null
+++ b/guix/kolwynia/home/bdunahu/files/.local/bin/mail-string
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+mail="$(find /home/bdunahu/.ml/*/[Ii][Nn][Bb][Oo][Xx]/new/* -type f 2>/dev/null | wc -l)"
+echo -n "${mail}M"
diff --git a/guix/kolwynia/home/bdunahu/files/.local/bin/sort-music b/guix/kolwynia/home/bdunahu/files/.local/bin/sort-music
new file mode 100755
index 0000000..013f194
--- /dev/null
+++ b/guix/kolwynia/home/bdunahu/files/.local/bin/sort-music
@@ -0,0 +1,101 @@
+#!/usr/bin/env -S guix shell python -- python3
+
+''' Imports '''
+import argparse
+import logging
+import sys
+import glob
+import os
+
+''' Global variables '''
+logger = logging.getLogger('sort_music.py')
+
+'''-----------------------------------------'''
+
+def parse_arguments():
+ ''' Parse command line arguments '''
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-a', '--album', help='EXACT album name shared across designated files.',
+ required=True)
+ parser.add_argument('-f', '--format', help='ncmpcpp format of files. Default is %t_%a_%b_%y. Read the documentation for that program for more information. It MUST include an artist name (%a) and year (%y).',
+ default="%t_%a_%b_%y")
+ parser.add_argument('-v', '--verbose', help='Enable full debug output.',
+ action='store_true')
+ return parser.parse_args()
+
+
+
+def configure_logs(verbose):
+ ''' Configure program logging level '''
+ level = logging.DEBUG if verbose else logging.INFO
+
+ ''' Configure stream handler '''
+ stream_handler = logging.StreamHandler(sys.stdout)
+ stream_handler.setFormatter(logging.Formatter('%(name)s - %(levelname)s - %(message)s'))
+
+ ''' For main logger '''
+ logger.addHandler(stream_handler)
+ logger.setLevel(level)
+
+'''-----------------------------------------'''
+
+class SortMusic():
+ def __init__(self, logger, args):
+ self.logger = logger
+ self.album = args.album
+ self.delimiter = args.format[2]
+ self.artist_index = args.format.split(self.delimiter).index('%a')
+ self.year_index = args.format.split(self.delimiter).index('%y')
+
+ logger.info(f'Starting rename with file extension {self.album} and artist_index {self.artist_index}')
+
+ self.files = None # list of relevant files in specified directory
+ self.artist = None
+ self.year = None
+
+
+ def run(self):
+ self._find_files()
+ self._prompt()
+ self._organize()
+
+
+ def _find_files(self):
+ self.files = list(glob.glob(f"*{self.album}*"))
+ if len(self.files) == 0:
+ self.logger.error(f'Files in this album NOT found!')
+ exit(1)
+
+ self.artist = self.files[0].split(self.delimiter).pop(self.artist_index).rsplit(".",1)[0] # remove file extension (sometimes occurs)
+ self.year = self.files[0].split(self.delimiter).pop(self.year_index).rsplit(".",1)[0]
+
+ def _prompt(self):
+ self.logger.info(f'Found {len(self.files)} files written by {self.artist} in {self.year}.')
+ quit = input(f'Files will now be organized (y/n)\t').lower()
+
+ if not quit.startswith('y'):
+ exit(1)
+
+ def _organize(self):
+ path = f'./{self.artist}/({self.year}) {self.album}'
+ if not os.path.exists(path):
+ logger.info(f'Creating previously missing path {path}')
+ os.makedirs(path)
+ for file in self.files:
+ os.rename(f'./{file}', f'{path}/{file}')
+
+'''-----------------------------------------'''
+
+def main():
+ ''' This is the main function '''
+ args = parse_arguments()
+ configure_logs(args.verbose)
+
+ ''' Initialize and run '''
+ sorter = SortMusic(logger, args)
+ sorter.run()
+
+
+
+if __name__ == '__main__':
+ main()
diff --git a/guix/kolwynia/home/bdunahu/files/.local/bin/string-weather b/guix/kolwynia/home/bdunahu/files/.local/bin/string-weather
new file mode 100755
index 0000000..01ece24
--- /dev/null
+++ b/guix/kolwynia/home/bdunahu/files/.local/bin/string-weather
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+curl wttr.in/Amherst?format="%x+%t+%m\n"
diff --git a/guix/kolwynia/home/bdunahu/files/.local/bin/t1-string b/guix/kolwynia/home/bdunahu/files/.local/bin/t1-string
new file mode 100755
index 0000000..ffdd61a
--- /dev/null
+++ b/guix/kolwynia/home/bdunahu/files/.local/bin/t1-string
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+loop=$(cat /tmp/t1 | jq .stat | tr -d '"')
+[ -n "$loop" ] && echo -n "${loop} "
+bg=$(cat /tmp/t1 | jq .bg)
+[ -n "$bg" ] && echo -n "${bg}B "
+iob=$(cat /tmp/t1 | jq .iob)
+[ -n "$iob" ] && echo -n " ${iob}U"
+rbat=$(cat /tmp/t1 | jq .rbat)
+[ -n "$rbat" ] && [ "$rbat" -lt 25 ] && echo -n " RB"
+res=$(echo "$(cat /tmp/t1 | jq .res) * 100 / 1" | bc)
+[ -n "$res" ] && [ "$res" -lt 2500 ] && echo -n " PR"
+pbat=$(echo "$(cat /tmp/t1 | jq .pbat) * 100 / 1" | bc)
+[ -n "$pbat" ] && [ "$pbat" -lt 136 ] && echo -n " PB"
+cage=$(cat /tmp/t1 | jq .cage)
+[ -n "$cage" ] && [ 14 -lt "$cage" ] && echo -n " CA"
+echo -n
diff --git a/guix/kolwynia/home/bdunahu/files/.local/bin/tag-media b/guix/kolwynia/home/bdunahu/files/.local/bin/tag-media
new file mode 100755
index 0000000..64b4586
--- /dev/null
+++ b/guix/kolwynia/home/bdunahu/files/.local/bin/tag-media
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+err() { echo "Usage:
+ tag [OPTIONS] file
+Options:
+ -a: artist/author
+ -t: song/chapter title
+ -A: album/book title
+ -d: year of publication
+ -g: genre
+ -c: comment
+You will be prompted for title, artist, album and date if not given." && exit 1 ;}
+
+while getopts "a:t:A:d:g:c:" o; do case "${o}" in
+ a) artist="${OPTARG}" ;;
+ t) title="${OPTARG}" ;;
+ A) album="${OPTARG}" ;;
+ d) date="${OPTARG}" ;;
+ g) genre="${OPTARG}" ;;
+ c) comment="${OPTARG}" ;;
+ *) printf "Invalid option: -%s\\n" "$OPTARG" && err ;;
+ esac done
+
+shift $((OPTIND - 1))
+
+file="$1"
+
+temp="$(mktemp -p "$(dirname "$file")")"
+trap 'rm -f $temp' HUP INT QUIT TERM PWR EXIT
+
+[ ! -f "$file" ] && echo 'Provide file to tag.' && err
+
+[ -z "$title" ] && echo 'Enter a title.' && read -r title
+[ -z "$artist" ] && echo 'Enter an artist.' && read -r artist
+[ -z "$album" ] && echo 'Enter an album.' && read -r album
+[ -z "$date" ] && echo 'Enter a date.' && read -r date
+
+cp -f "$file" "$temp" && ffmpeg -i "$temp" -map 0 -y -codec copy \
+ -metadata title="$title" \
+ -metadata album="$album" \
+ -metadata artist="$artist" \
+ -metadata date="$date" \
+ ${genre:+-metadata genre="$genre"} \
+ ${comment:+-metadata comment="$comment"} "$file"
diff --git a/guix/kolwynia/home/bdunahu/files/.local/bin/touchpad-defaults b/guix/kolwynia/home/bdunahu/files/.local/bin/touchpad-defaults
new file mode 100755
index 0000000..6c07797
--- /dev/null
+++ b/guix/kolwynia/home/bdunahu/files/.local/bin/touchpad-defaults
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# see:
+# xinput --list
+# xinput --list-props 'ELAN0412:00 04F3:311D Touchpad'
+[[ $HOSTNAME == "garmr" ]] && xinput --set-prop "ELAN0412:00 04F3:311D Touchpad" "libinput Tapping Enabled" 1
diff --git a/guix/kolwynia/home/bdunahu/files/.local/bin/unfreeze b/guix/kolwynia/home/bdunahu/files/.local/bin/unfreeze
new file mode 100755
index 0000000..072473d
--- /dev/null
+++ b/guix/kolwynia/home/bdunahu/files/.local/bin/unfreeze
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+epid=$(pidof emacs)
+
+kill -USR2 "$epid"
+kill -USR1 "$epid"
+
+echo "Done."
diff --git a/guix/kolwynia/home/bdunahu/files/.local/bin/upload b/guix/kolwynia/home/bdunahu/files/.local/bin/upload
new file mode 100755
index 0000000..a2db9b5
--- /dev/null
+++ b/guix/kolwynia/home/bdunahu/files/.local/bin/upload
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+
+err() { echo "Usage:
+ upload [OPTIONS]
+Options:
+ -t: time from now to expire in hours (default: 48)
+ file: a path to a file. If this is not given, receives input from stdin." && exit 1 ;}
+
+hours=48
+
+while getopts ":t:" opt; do
+ case $opt in
+ t)
+ hours=$OPTARG
+ if [[ $OPTARG =~ ^-?[0-9]+$ ]]; then
+ hours=$OPTARG
+ else
+ err
+ fi
+ ;;
+ *)
+ err
+ ;;
+ esac
+done
+
+shift $((OPTIND -1))
+
+if [ -n "$1" ] && [ -f "$1" ]; then
+ source="$1"
+ ext="${1##*.}"
+else
+ source=$(mktemp)
+ ext="txt"
+ cat > "$source"
+ chmod a+r "$source"
+fi
+
+dest="$(cat /dev/random | tr -dc 'a-zA-Z0-9' | fold -w 4 | head -n 1)-$(date -d "+$hours hours" +%s).$ext"
+
+scp "$source" "root@operationnull.com:/var/www/operationnull/paste/$dest" &&
+ echo "https://operationnull.com/paste/$dest"
diff --git a/guix/kolwynia/home/bdunahu/files/.local/bin/xkeyboard-auto b/guix/kolwynia/home/bdunahu/files/.local/bin/xkeyboard-auto
new file mode 100755
index 0000000..b81ced4
--- /dev/null
+++ b/guix/kolwynia/home/bdunahu/files/.local/bin/xkeyboard-auto
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+/home/bdunahu/.local/bin/xkeyboard-toggle
+while true;
+do
+ if [ -f /tmp/keyboard_plugged ]; then
+ rm /tmp/keyboard_plugged
+ sleep 2
+ /home/bdunahu/.local/bin/xkeyboard-toggle
+ fi
+ sleep 1
+done
diff --git a/guix/kolwynia/home/bdunahu/files/.local/bin/xkeyboard-layout b/guix/kolwynia/home/bdunahu/files/.local/bin/xkeyboard-layout
new file mode 100755
index 0000000..de6f7a2
--- /dev/null
+++ b/guix/kolwynia/home/bdunahu/files/.local/bin/xkeyboard-layout
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+WORKMAN=$(setxkbmap -print | grep "workman")
+echo $WORKMAN
+
+if [ -z WORKMAN ]; then
+ xkbcomp -I$HOME/.xkb ~/.xkb/keymap/standard $DISPLAY &&
+ echo 'Switched to standard layout.'
+else
+ test -f ~/.xkb/symbols/rocket && xkbcomp -I$HOME/.xkb ~/.xkb/keymap/rocket $DISPLAY &&
+ echo 'Switched to workman layout.'
+fi
diff --git a/guix/kolwynia/home/bdunahu/files/.local/bin/xkeyboard-toggle b/guix/kolwynia/home/bdunahu/files/.local/bin/xkeyboard-toggle
new file mode 100755
index 0000000..70f9516
--- /dev/null
+++ b/guix/kolwynia/home/bdunahu/files/.local/bin/xkeyboard-toggle
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+xset r rate 250 70
+xset s 600
+xkbcomp -I$HOME/.xkb ~/.xkb/keymap/standard $DISPLAY
diff --git a/guix/kolwynia/home/bdunahu/files/.local/bin/xrandr-refresh b/guix/kolwynia/home/bdunahu/files/.local/bin/xrandr-refresh
new file mode 100755
index 0000000..c9d55c5
--- /dev/null
+++ b/guix/kolwynia/home/bdunahu/files/.local/bin/xrandr-refresh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+declare -i count=2
+declare -i seconds=1
+
+while ((count)); do
+ xrandr >/dev/null
+ sleep $seconds
+ ((count--))
+done \ No newline at end of file
diff --git a/guix/kolwynia/home/bdunahu/files/.local/bin/xrandr-toggle b/guix/kolwynia/home/bdunahu/files/.local/bin/xrandr-toggle
new file mode 100755
index 0000000..6acff6d
--- /dev/null
+++ b/guix/kolwynia/home/bdunahu/files/.local/bin/xrandr-toggle
@@ -0,0 +1,15 @@
+#!/bin/sh
+intern=eDP-1
+extern=DP-1
+extern2=HDMI-1
+
+if xrandr | grep "$extern disconnected" >/dev/null; then
+ xrandr --output "$extern" --off --output "$intern" --mode 1920x1080 --auto
+# usually, HDMI-1 is a 2560x1440 screen, so cannot be duplicated well
+elif xrandr | grep "$extern2 connected" >/dev/null; then
+ xrandr --output "$extern2" --primary --mode 1920x1080 --auto --same-as "$intern"
+else
+ xrandr --output "$extern" --primary --mode 1920x1080 --auto --same-as "$intern"
+fi
+
+echo "xrandr done!"
diff --git a/guix/kolwynia/home/bdunahu/files/.local/bin/xxinit b/guix/kolwynia/home/bdunahu/files/.local/bin/xxinit
new file mode 100755
index 0000000..1ec9a82
--- /dev/null
+++ b/guix/kolwynia/home/bdunahu/files/.local/bin/xxinit
@@ -0,0 +1,6 @@
+ #!/bin/sh
+
+DIR=/home/bdunahu/.guix-home/profile/
+$DIR/bin/xinit -- $DIR/bin/Xorg :0 vt1 -keeptty \
+ -configdir $DIR/share/X11/xorg.conf.d \
+ -modulepath $DIR/lib/xorg/modules