├── tools ├── ext ├── qutebrowser.sh ├── rldkeynav ├── weather.sh ├── cpuspeed ├── autosuspend.sh ├── transdone ├── speedvid.sh ├── tmuxdd ├── newspod ├── ifinstalled ├── setbg ├── ix ├── img2clip.sh ├── topdf ├── newsup ├── sw ├── qrclip ├── texclear ├── after.sh ├── transadd ├── catdocx ├── getbib ├── check-ip-address ├── cheat ├── rssadd ├── checkup ├── cm ├── gif.sh ├── tts.sh ├── opout ├── ytgrep ├── pomodoro ├── chrome_createpass.sh ├── ytplay ├── vim-anywhere.sh ├── vipe ├── yt2rss.sh ├── dock_monitor ├── cast ├── cl ├── remaps ├── wwb ├── extract ├── qrrecieve ├── refreshbrowser ├── windowshot.sh ├── www ├── shortcuts.sh ├── musstuff ├── psave.sh ├── compiler └── tpb.sh ├── tty ├── altmaps.kmap ├── ttymaps.kmap └── ttysetup.sh ├── altttymaps.kmap ├── fzf ├── wbm ├── fk ├── fuzzpass ├── wifi ├── pkgrm └── pkgsearch ├── i3-wm-scripts ├── popweather ├── unmapedi3 ├── i3torrent ├── updateunmapedi3 ├── mark ├── nextmatch-query-ask ├── paste-primary-if-oneline ├── i3getworkspace.sh ├── unmark ├── i3mpdupdate ├── dropdowncalc ├── popupgrade ├── nextmatch-query-saved ├── i3mail ├── goto ├── forcesplits.sh ├── polybar_launch ├── i3pacman ├── Numlock.sh ├── i3volume ├── dmenuarchwiki ├── i3mpd ├── i3togglesplit.sh ├── i3wifi ├── i3resize ├── i3weather ├── checksplit.sh ├── bottomleft ├── nextmatch ├── center ├── bottomright ├── guidd.sh ├── simpledd.sh ├── vimmappings ├── ddspawn ├── floatingterm.sh ├── nextfind ├── i3-exec └── README.md ├── dmenu ├── dmenupass ├── octave-workspace ├── manlist ├── prompt ├── td-toggle ├── textbook.sh ├── dmenuemoji ├── castcontrol.sh ├── typo ├── ducksearch ├── game-get.sh ├── power_menu.sh ├── stars ├── dmenuumount ├── dmenu_github ├── menu_connection_manager.sh ├── btmenu ├── dmenuhandler ├── displayselect ├── calc.sh ├── menu-killall ├── dmenumount ├── cabl ├── tutorialvids └── dmenu_kdeconnect.sh ├── getres ├── surf ├── edit_screen.sh ├── mypassmenu └── surf_linkselect.sh ├── wip ├── dmenuwifi ├── md2roff.sh ├── vid_post.sh ├── gate.sh ├── malcheck.sh ├── feedcheck.sh └── wifi.sh ├── dwm ├── startdwm.sh ├── launch_once.sh ├── hide.sh ├── unhide.sh ├── autostart.sh ├── rotate_screen ├── togglescheme.sh └── colortheme ├── mblaze ├── mnext ├── mpeek ├── mls ├── msent ├── mopen └── msearch ├── simpleserve ├── .github └── FUNDING.yml ├── funnel ├── README.md └── funnel ├── emenu ├── lorem ├── servlog.sh ├── memesearch.sh ├── balsamiq ├── roficalc.sh ├── toggle-trackpad ├── wac ├── webcam.sh ├── README.md ├── covid19.sh ├── commit-org.sh ├── f ├── feeder ├── open ├── chem.sh ├── pkgls ├── videos └── cleanaudio.sh ├── rec2org ├── rec2tbl ├── jgmenu └── bar ├── mailsync ├── functions └── cl-menu.ros /tools/ext: -------------------------------------------------------------------------------- 1 | extract -------------------------------------------------------------------------------- /tty/altmaps.kmap: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /altttymaps.kmap: -------------------------------------------------------------------------------- 1 | keycode 1 = Caps_Lock 2 | keycode 58 = Escape 3 | -------------------------------------------------------------------------------- /tty/ttymaps.kmap: -------------------------------------------------------------------------------- 1 | keycode 1 = Caps_Lock 2 | keycode 58 = Escape 3 | -------------------------------------------------------------------------------- /fzf/wbm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cat ~/.config/bookmarks | fzf | xargs w3m 4 | -------------------------------------------------------------------------------- /i3-wm-scripts/popweather: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cat ~/.weatherreport && read 3 | -------------------------------------------------------------------------------- /dmenu/dmenupass: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dmenu -P -p "$1" <&- && echo 3 | #vim:ft=sh 4 | -------------------------------------------------------------------------------- /i3-wm-scripts/unmapedi3: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | less ~/.config/i3/unmaped.txt 4 | -------------------------------------------------------------------------------- /tools/qutebrowser.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/sh 2 | qutebrowser --target window "$*" 3 | # vim:ft=sh 4 | -------------------------------------------------------------------------------- /dmenu/octave-workspace: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gavinok/scripts/HEAD/dmenu/octave-workspace -------------------------------------------------------------------------------- /tools/rldkeynav: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # script used to restart keynav 3 | killall keynav 4 | keynav daemonize 5 | -------------------------------------------------------------------------------- /i3-wm-scripts/i3torrent: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # pgrep -x transmission-da > /dev/null 2>&1 || exit 1 3 | echo "[T]" 4 | -------------------------------------------------------------------------------- /tools/weather.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Quickly get the weather in celcius 3 | curl "wttr.in/?m" 4 | read -rn1 5 | 6 | -------------------------------------------------------------------------------- /i3-wm-scripts/updateunmapedi3: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | grep unmaped ~/.config/i3/config > ~/.config/i3/unmaped.txt 4 | -------------------------------------------------------------------------------- /tools/cpuspeed: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cpupower frequency-info -fm | grep -oP '(?<=frequency: )([^ ]+ [^ ]+)' 3 | # vim:ft=sh 4 | -------------------------------------------------------------------------------- /getres: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | xrdb -query | awk "BEGIN {count=0} /^$1:/ {print \$2 ; count++ } END { if( count == 0 ) exit 1 }" 3 | -------------------------------------------------------------------------------- /tools/autosuspend.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | pidof -s xautolock >&/dev/null 3 | if [ $? -ne 0 ]; then 4 | xautolock -time 60 -locker "systemctl suspend" & 5 | fi 6 | -------------------------------------------------------------------------------- /i3-wm-scripts/mark: -------------------------------------------------------------------------------- 1 | #!/bin/sh -ue 2 | name="$(i3-msg -t get_marks | tr -d '[],' | sed -e 's/""/\n/g' | tr -d '"' | dmenu -p mark)" 3 | exec i3-msg mark "$name" 4 | -------------------------------------------------------------------------------- /tools/transdone: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script is ran by transimision when a torrent has completed 4 | 5 | notify-send " $TR_TORRENT_NSME Torrent Done." 6 | -------------------------------------------------------------------------------- /i3-wm-scripts/nextmatch-query-ask: -------------------------------------------------------------------------------- 1 | #!/bin/sh -ue 2 | q=$(dmenu -p /) 3 | here="$(dirname "$0")" 4 | printf %s "$q" >"$here/.query.tmp" 5 | exec "$here/nextmatch" "$q" 6 | -------------------------------------------------------------------------------- /surf/edit_screen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | tmpfile=$(mktemp /tmp/st-edit.XXXXXX.html) 3 | trap 'rm "$tmpfile"' 0 1 15 4 | cat > "$tmpfile" 5 | $TERMINAL -e "$EDITOR" "$tmpfile" 6 | -------------------------------------------------------------------------------- /tools/speedvid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | base=$(basename $1) 4 | ext="${base##*.}" 5 | base="${base%.*}" 6 | 7 | ffmpeg -i $1 -vf "setpts=$2*PTS" -an $base'_sped.'$ext 8 | -------------------------------------------------------------------------------- /tools/tmuxdd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This is the script that i3 runs to either start tmux in 3 | # the dropdown terminal or log into a previous session. 4 | tmux a || tmux 5 | 6 | -------------------------------------------------------------------------------- /i3-wm-scripts/paste-primary-if-oneline: -------------------------------------------------------------------------------- 1 | #!/bin/sh -ue 2 | if [ -z "$(xsel | head -n2 | tail -n+2 | head -n1)" ]; then 3 | xsel | xvkbd -xsendevent -file - 2>/dev/null 4 | fi 5 | -------------------------------------------------------------------------------- /tools/newspod: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Another script because i3 is too dumb to call basic operations right. 3 | # Brings up newsboat, if newsboat is open, opens podboat 4 | newsboat || podboat -a 5 | -------------------------------------------------------------------------------- /i3-wm-scripts/i3getworkspace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | WS=`python3 -c "import json; print(next(filter(lambda w: w['focused'], json.loads('$(i3-msg -t get_workspaces)')))['num'])"` 4 | echo "$WS" 5 | 6 | 7 | -------------------------------------------------------------------------------- /tools/ifinstalled: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # If $1 command is not available, error code and notify. 3 | command -v "$1" >/dev/null || { notify-send "📦 $1 must be installed for this function." && exit 1; } 4 | -------------------------------------------------------------------------------- /wip/dmenuwifi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | nmcli -c no d wifi list | tail -n +2 | sed 's/ \+/ /;s/Infra [0-9]*/ /g;s/WPA. .*$//;s/Mbit\/s[[:space:]]*[0-9]*/Mbit\/s/g;s/Ad-Hoc [0-9]*//g' | dmenu -l 20 -p Networks 4 | -------------------------------------------------------------------------------- /i3-wm-scripts/unmark: -------------------------------------------------------------------------------- 1 | #!/bin/sh -ue 2 | name="$(i3-msg -t get_marks | tr -d '[],' | sed -e 's/""/\n/g' | tr -d '"' | dmenu -p unmark)" 3 | if [ -z "$name" ]; then 4 | exit 1 5 | fi 6 | exec i3-msg unmark "$name" 7 | -------------------------------------------------------------------------------- /dwm/startdwm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Infinitely restart dwm so no programs close 3 | while true; do 4 | # Log stderror to a file 5 | # dwm 2>> /tmp/dwm.log 6 | # No error logging 7 | dwm >/dev/null 2>&1 8 | done 9 | -------------------------------------------------------------------------------- /i3-wm-scripts/i3mpdupdate: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | [ "$(pgrep -x i3mpdupdate | wc -l)" -gt 2 ] && exit 4 | 5 | while : ; do 6 | pgrep -x mpd || exit 7 | mpc idle > /dev/null 8 | pkill -RTMIN+11 i3blocks ; 9 | done 10 | -------------------------------------------------------------------------------- /i3-wm-scripts/dropdowncalc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This script ensures that i3 will spawn a calculator. 3 | # If R is installed, it will run R, otherwise it will run 4 | # Python. 5 | ([ -e /usr/bin/R ] && R -q --no-save) || python -q 6 | -------------------------------------------------------------------------------- /mblaze/mnext: -------------------------------------------------------------------------------- 1 | #!/bin/env sh 2 | DATE=$(date +%Y)-$(($(date +%m) - 1))-01 3 | DATECMP='date > "' 4 | DATEEND='" && ' 5 | IMPORTANCE='((flagged && !replied) || !seen)' 6 | mpick -t "${DATECMP}${DATE}${DATEEND}${IMPORTANCE}" | mscan 7 | -------------------------------------------------------------------------------- /fzf/fk: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # FuzzyKill 4 | # Depends on fzf 5 | ps ux | grep -e "^$(whoami)" | awk '{$1 = ""; $3 = ""; $4 = ""; $5 = ""; $6 = ""; $7 = ""; $8 = ""; $9 = ""; $10 = ""; print $0;}' | fzf | awk '{print $1;}' | xargs kill 6 | -------------------------------------------------------------------------------- /tools/setbg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Sets the background. If given an argument, will set file as background. 3 | [ ! -z "$1" ] && cp "$1" ~/.config/wall.png && notify-send -i "Wallpaper changed." 4 | # xsetroot -grey 5 | xwallpaper --zoom ~/.config/wall.png 6 | -------------------------------------------------------------------------------- /i3-wm-scripts/popupgrade: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf "Beginning upgrade.\\n" 4 | 5 | yay -Syu 6 | pacman -Qu | wc -l > ~/.pacupgrnum 7 | pkill -RTMIN+8 i3blocks 8 | 9 | printf "\\nUpgrade complete.\\nPress to exit window.\\n\\n" 10 | read -r 11 | -------------------------------------------------------------------------------- /simpleserve: -------------------------------------------------------------------------------- 1 | #!/bin/env sh 2 | 3 | PORT=1337 4 | 5 | PID=$(pgrep --full "python -m http.server $PORT") 6 | killall -n "$PID" 2> /dev/null 7 | 8 | [ ! -f "$1" ] && exit 9 | FILE="$1" 10 | 11 | 12 | $BROWSER "localhost:${PORT}/$1" 13 | python -m http.server $PORT & 14 | -------------------------------------------------------------------------------- /dmenu/manlist: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # quickly find and display man page 4 | 5 | # LAUNCER="dmenu -i -l 20 -p " 6 | [ -n "${DISPLAY}" ] && LAUNCER="fzf --prompt " 7 | 8 | Selected="$(man -k . | $LAUNCER "Select Program " | cut -d" " -f1)" 9 | man "$Selected" 10 | #vim:ft=sh 11 | -------------------------------------------------------------------------------- /i3-wm-scripts/nextmatch-query-saved: -------------------------------------------------------------------------------- 1 | #!/bin/sh -ue 2 | here="$(dirname "$0")" 3 | q=$(cat "$here/.query.tmp") || true 4 | echo "q: $q" 5 | if [ -z "$q" ]; then 6 | q=$(dmenu -p '(empty) /') 7 | printf %s "$q" >"$here/.query.tmp" 8 | fi 9 | exec "$here/nextmatch" "$q" 10 | -------------------------------------------------------------------------------- /mblaze/mpeek: -------------------------------------------------------------------------------- 1 | #!/bin/env sh 2 | MAILPATH="$HOME/.local/share/mail" 3 | if [ -n "$*" ]; then 4 | mlist $MAILPATH/$1/INBOX $MAILPATH/$1/SENT/\[Gmail\].Sent\ Mail/| msort -d | mthread 5 | else 6 | mlist ${MAILPATH}/*/INBOX ${MAILPATH}/*/\[Gmail\].Sent\ Mail/ | msort -d | mthread 7 | fi 8 | -------------------------------------------------------------------------------- /tools/ix: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # The original version of this script was wtitten by the guys at 2f30 4 | # upload text to ix.io 5 | 6 | PASTE() { 7 | curl -F 'f:1=<-' ix.io 8 | } 9 | 10 | if test -z "$1"; then 11 | cat - | PASTE 12 | else 13 | cat "$1" | PASTE 14 | fi 15 | -------------------------------------------------------------------------------- /dmenu/prompt: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # A dmenu binary prompt script. 3 | # Gives a dmenu prompt labeled with $1 to perform command $2. 4 | # For example: 5 | # `./prompt "Do you want to shutdown?" "shutdown -h now"` 6 | 7 | [ "$(printf "No\\nYes" | dmenu -i -p "$1" )" = "Yes" ] && $2 8 | #vim:ft=sh 9 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | [Gavinok]: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | [gavinfreeborn]: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | -------------------------------------------------------------------------------- /mblaze/mls: -------------------------------------------------------------------------------- 1 | #!/bin/env sh 2 | MAILPATH="$HOME/.local/share/mail" 3 | if [ -n "$*" ]; then 4 | mlist $MAILPATH/$1/INBOX $MAILPATH/$1/SENT/\[Gmail\].Sent\ Mail/| msort -d | mthread | mseq -S && mscan 5 | else 6 | mlist ${MAILPATH}/*/INBOX ${MAILPATH}/*/\[Gmail\].Sent\ Mail/ | msort -d | mthread | mseq -S && mscan 7 | fi 8 | -------------------------------------------------------------------------------- /dwm/launch_once.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # a simple script for starting a program 4 | # kill it if it is already running 5 | if pgrep -x "$1" ;then 6 | killall "$1" 7 | # for program that dont imediatly close 8 | xdotool windowclose "$(xdotool search --name "$1")" 9 | exit 10 | fi 11 | exec "$1" 12 | #vim:ft=sh 13 | -------------------------------------------------------------------------------- /mblaze/msent: -------------------------------------------------------------------------------- 1 | #!/bin/env sh 2 | MAILPATH="$HOME/.local/share/mail" 3 | if [ -n "$*" ]; then 4 | mlist $MAILPATH/$1/INBOX $MAILPATH/$1/SENT/\[Gmail\].Sent\ Mail/ | msort -d | mthread | mseq -S && mscan 5 | else 6 | mlist ${MAILPATH}/*/INBOX ${MAILPATH}/*/\[Gmail\].Sent\ Mail/ | msort -d | mthread | mseq -S && mscan 7 | fi 8 | 9 | -------------------------------------------------------------------------------- /tools/img2clip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TMPTEXTFILE=$(mktemp XXX.txt) 3 | trap 'rm $TMPTEXTFILE' EXIT TERM HUP 4 | 5 | IMGFILE=$(windowshot.sh c 2> /dev/null ) 6 | echo $IMGFILE 7 | trap 'rm $IMGFILE' EXIT TERM HUP 8 | 9 | tesseract $IMGFILE "${TMPTEXTFILE%.*}" 10 | 11 | TEXT=$(cat $TMPTEXTFILE) 12 | echo "$TEXT" | xclip 13 | -------------------------------------------------------------------------------- /tools/topdf: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # convert documents to pdf using the doc2pdf.net service 4 | # depends: curl 5 | 6 | if test -z "$1"; then 7 | echo usage: $(basename $0) document && exit 1 8 | fi 9 | 10 | SRV=http://www.doc2pdf.net/convert/document.pdf 11 | 12 | curl -F "inputDocument=@$1" $SRV > "${1%.*}.pdf" 13 | -------------------------------------------------------------------------------- /i3-wm-scripts/i3mail: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # i3blocks mail module. 4 | # Displays number of unread mail and an loading icon if updating. 5 | # When clicked, brings up `neomutt`. 6 | 7 | case $BLOCK_BUTTON in 8 | 1) $TERMINAL -e neomutt ;; 9 | esac 10 | 11 | echo "$(du -a ~/.mail/*/INBOX/new/* | sed -n '$=')" $(cat ~/.config/mutt/.dl) 12 | -------------------------------------------------------------------------------- /tools/newsup: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ping -q -t 1 -c 1 `ip r | grep -m 1 default | cut -d ' ' -f 3` >/dev/null || exit 4 | echo "📰 🔃" > ~/.newsup 5 | pkill -RTMIN+6 i3blocks 6 | printf "Loading new RSS entries for newsboat...\\n" 7 | /usr/bin/newsboat -x reload && 8 | printf "Done.\\n" 9 | echo "" > ~/.newsup 10 | pkill -RTMIN+6 i3blocks 11 | -------------------------------------------------------------------------------- /i3-wm-scripts/goto: -------------------------------------------------------------------------------- 1 | #!/bin/sh -ue 2 | # Tool for listing all the i3 windows in dmenu 3 | # 4 | # Usage: 5 | # 6 | # goto [dmenu args] 7 | # 8 | # Example 9 | # 10 | # goto -l 10 -b 11 | # 12 | 13 | name="$(i3-msg -t get_marks | tr -d '[],' | sed -e 's/""/\n/g' | tr -d '"' | dmenu -p jump "$@")" 14 | exec i3-msg "[con_mark=$name]" focus 15 | -------------------------------------------------------------------------------- /tools/sw: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | file="$HOME/.local/share/unhide" 4 | app="$1" 5 | #target="$2" 6 | 7 | tid=$(xdo id) 8 | 9 | 10 | hidecurrent() { 11 | echo $tid+$app >> $file & xdo hide 12 | } 13 | 14 | showlast() { 15 | sid=$(cat $file | grep "$app" | awk -F "+" 'END{print $1}') 16 | xdo show -r $sid 17 | } 18 | 19 | hidecurrent & $@ ; showlast 20 | -------------------------------------------------------------------------------- /dwm/hide.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/sh 2 | # printf "%b,%b" "$(xdotool getwindowname "$(xdotool getwindowfocus)")" "$(xdotool windowunmap "$(xdotool getwindowfocus)")" >> $HOME/hidden 3 | WINDOWID="$(xdotool getwindowfocus)" 4 | # xdotool set_window --classname "float" "$WINDOWID" 5 | xdotool windowunmap "$WINDOWID" 6 | printf "%b@@@%b\\n" "$(xdotool getwindowname "$WINDOWID")" "$WINDOWID" >> "/tmp/hidden" 7 | -------------------------------------------------------------------------------- /fzf/fuzzpass: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | lpath=$(find ~/.password-store/ -name "*.gpg" | \ 3 | sed -r 's,(.*)\.password-store/(.*)\.gpg,\2,' | \ 4 | fzf +m); 5 | [[ -z "$lpath" ]] && exit 6 | pass show -c "$lpath" 7 | truepass=$(pass show "$lpath") 8 | pass=$(echo "$truepass" | awk 'NR!=1') 9 | notify-send "$pass" 10 | echo "$pass" 11 | read -r 12 | pass=$( echo "$truepass" | awk 'NR==1') 13 | clipdel -d "$pass" 14 | -------------------------------------------------------------------------------- /funnel/README.md: -------------------------------------------------------------------------------- 1 | # Simple command queue 2 | This is a simple implementation of a command queuing program written in POSIX sh. 3 | 4 | # Usage 5 | 6 | I have it opening links in my $BROWSER but I plan on converting it over to use any command. 7 | 8 | ``` 9 | funnel 10 | ``` 11 | 12 | This will then add the URL to the browser queue 13 | 14 | 15 | # Requirements 16 | 17 | - core utils 18 | - POSIX complaint sh 19 | -------------------------------------------------------------------------------- /emenu: -------------------------------------------------------------------------------- 1 | #!/bin/dash 2 | PROMPT="PROMPT" 3 | while getopts ':p:' c 4 | do 5 | case $c in 6 | p) PROMPT="$OPTARG" ;; 7 | esac 8 | done 9 | 10 | options="" 11 | while read line 12 | do 13 | options="$options \"$line\"" 14 | done 15 | 16 | result=$(emacsclient -e "(emenu \"$PROMPT \" '($options))" 2> /dev/null) 17 | [ -z "$result" ] && exit 1 # if empty exit 18 | 19 | printf "%s" "$result" | sed 's/"$//; s/^"//' 20 | 21 | -------------------------------------------------------------------------------- /lorem: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "${1}" = "" ] || [ "${2}" = "" ]; then 4 | echo "Usage: loremipsum [p or s] [int] 5 | p for paragraph 6 | s for sentence" 7 | else 8 | case $1 in 9 | p) 10 | curl -s http://metaphorpsum.com/paragraphs/"${2}" && printf "\n" 11 | ;; 12 | s) 13 | curl -s http://metaphorpsum.com/sentences/"${2}" && printf "\n" 14 | ;; 15 | *) 16 | default 17 | ;; 18 | esac 19 | fi 20 | -------------------------------------------------------------------------------- /wip/md2roff.sh: -------------------------------------------------------------------------------- 1 | #!/bin/env sh 2 | sed -E -e 's/^# (.*)/\.NH\n\1\n\.LP\n/g' -e 's/^## (.*)/\.NH\n\1\n\.LP\n/g' -e 's/\*(.*)\*/\\f[I]\1\\f[]/g' $1 | groff -ms -Tpdf -ek | zathura - 3 | #heading 1 ----------^ 4 | #heading 2 -----------------------------------------^ 5 | #italics --------------------------------------------------------------------------------^ 6 | #bold --------------------------------------------------------------------------------^ 7 | -------------------------------------------------------------------------------- /i3-wm-scripts/forcesplits.sh: -------------------------------------------------------------------------------- 1 | j!/bin/bash 2 | 3 | # if [ -f "/tmp/value.dat" ] ; then 4 | # split_checker 5 | # else 6 | # value=0 7 | # echo "[>]" 8 | # i3-msg -q "split h" 9 | # # and save it for next time 10 | # echo "${value}" > /tmp/value.dat 11 | # split_checker 12 | # fi 13 | # value=`cat /tmp/value.dat` 14 | # fi 15 | # if [[ $value == 1 ]]; 16 | # then 17 | # i3-msg -q "split v" 18 | # else 19 | # i3-msg -q "split h" 20 | # fi 21 | -------------------------------------------------------------------------------- /dmenu/td-toggle: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # If transmission-daemon is running, will ask to kill, else will ask to start. 4 | 5 | LAUNCER="emenu -i -p " 6 | 7 | if pgrep -x transmission-da; then 8 | yn=$(printf 'No\nYes\n' | $LAUNCER "Kill transmission-daemon?") 9 | [ "$yn" = "Yes" ] && transmission-remote --exit 10 | else 11 | yn=$(printf 'No\nYes\n' | $LAUNCER "Start transmission daemon?") 12 | [ "$yn" = "Yes" ] && transmission-daemon 13 | fi 14 | #vim:ft=sh 15 | -------------------------------------------------------------------------------- /servlog.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : servlog.sh 6 | # @created : Fri 10 Jan 2020 12:32:16 PM MST 7 | # 8 | # @description : used for lsp debugging 9 | ###################################################################### 10 | 11 | tee in.log | "$*" | tee out.log 12 | 13 | # vim: set tw=78 ts=2 et sw=2 sr: 14 | 15 | -------------------------------------------------------------------------------- /i3-wm-scripts/polybar_launch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Terminate already running bar instances 4 | killall -q polybar 5 | 6 | # Wait until the processes have been shut down 7 | while pgrep -x polybar >/dev/null; do sleep 1; done 8 | 9 | # Launch bar1 and bar2 10 | #polybar example & 11 | 12 | for i in $(polybar -m | awk -F: '{print $1}'); do MONITOR=$i polybar example -c ~/.config/polybar/config & done 13 | feh --bg-scale ~/.config/wall.png 14 | 15 | echo "Bars launched..." 16 | -------------------------------------------------------------------------------- /tools/qrclip: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # quick and dirty way to copy your clipboard into a QR code 3 | 4 | tmpfile="/tmp/QR.png" 5 | clip=$(xclip -selection "primary" -o) 6 | 7 | qrurl() 8 | { 9 | echo "$1" 10 | curl -sS "http://chart.apis.google.com/chart?chs=200x200&cht=qr&chld=H|0&chl=$1" -o "${tmpfile}" 11 | } 12 | 13 | if command -v qrencode >/dev/null ;then 14 | echo "${clip}" | qrencode -s 10 -o "${tmpfile}" 15 | else 16 | qrurl "${clip}" 17 | fi 18 | 19 | xdg-open "${tmpfile}" 20 | -------------------------------------------------------------------------------- /mblaze/mopen: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | [ -z "$LAUNCHER" ] && LAUNCHER="fzf --tac" 3 | if [ $TERM = dumb ] ; then 4 | mshow -t . 5 | read ATTACH 6 | else 7 | ATTACH="$(mshow -t . | $LAUNCHER)" 8 | fi 9 | [ -z "$ATTACH" ] && exit 1 10 | MIME="$(echo "$ATTACH" | cut -f 2 -d ":" | cut -f 2 -d " ")" 11 | ATTACHNUM="$(echo "$ATTACH" | cut -f1 -d':')" 12 | 13 | tmp="$(mktemp '/tmp/mblaze.XXXXXX')" 14 | mshow -O . "$ATTACHNUM" > "$tmp" 15 | case "$MIME" in 16 | *) 17 | xdg-open "$tmp";; 18 | esac 19 | -------------------------------------------------------------------------------- /tools/texclear: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Clears the build files of a LaTeX/XeLaTeX build. 4 | # I have vim run this file whenever I exit a .tex file. 5 | 6 | [[ "$1" == *.tex ]] || exit 7 | 8 | file=$(readlink -f "$1") 9 | dir=$(dirname "$file") 10 | base="${file%.*}" 11 | 12 | find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\.(4tc|xref|tmp|pyc|pyo|fls|vrb|fdb_latexmk|bak|swp|aux|log|synctex\(busy\)|lof|nav|out|snm|toc|bcf|run\.xml|synctex\.gz|blg|bbl)" -delete 13 | # vim:ft=sh 14 | -------------------------------------------------------------------------------- /i3-wm-scripts/i3pacman: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # i3blocks module for pacman upgrades. 4 | # Displays number of upgradeable packages. 5 | # For this to work, have a `pacman -Sy` command run in the background as a 6 | # cronjob every so often as root. This script will then read those packages. 7 | # When clicked, it will run an upgrade via `yay`. (`yay` required, duh.) 8 | 9 | case $BLOCK_BUTTON in 10 | 1) $TERMINAL -e "popupgrade" ;; 11 | esac 12 | 13 | yay -Qu | sed -e '/^Get/d' | wc -l | sed -e "s/^0$//g" 14 | -------------------------------------------------------------------------------- /memesearch.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : memesearch.sh 6 | # @created : Wed 05 Aug 2020 02:14:46 PM 7 | # 8 | # @description : Quick why to get a png of a related topic 9 | ###################################################################### 10 | 11 | xdg-open "https://toppng.com/collection/$*" 12 | 13 | # vim: set tw=78 ts=2 et sw=2 sr: 14 | 15 | -------------------------------------------------------------------------------- /wip/vid_post.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : vid_post.sh 6 | # @created : Thu 04 Feb 2021 02:20:33 PM 7 | # 8 | # @description : 9 | ###################################################################### 10 | 11 | videofile=$1 12 | outfile=MONO${videofile} 13 | ffmpeg -i "$videofile" -ac 1 "${outfile}" 14 | 15 | # vim: set tw=78 ts=2 et sw=2 sr: 16 | 17 | -------------------------------------------------------------------------------- /balsamiq: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : balsamiq.sh 6 | # @created : Sun 14 Jun 2020 02:43:10 PM 7 | # 8 | # @description : quick way to open Balsamiq as a webapp 9 | ###################################################################### 10 | 11 | google-chrome-stable --app="https://balsamiq-wireframes.appspot.com/" 12 | 13 | # vim: set tw=78 ts=2 et sw=2 sr: 14 | -------------------------------------------------------------------------------- /tools/after.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script is used to execute a program after the first specified time and before the second time 3 | pgrep -x $1 && exit 4 | echo "$1" 5 | H=$(date +%k) 6 | echo "$H" 7 | if [[ -n $3 ]]; then 8 | echo $1 is not empty 9 | echo "is it after $2 and before $3?" 10 | if (($2 <= H && H < $3)); then 11 | $1 & 12 | else 13 | echo no 14 | fi 15 | 16 | fi 17 | 18 | if (($2 <= H)); then 19 | if [[ -z $3 ]]; then 20 | echo after $2 21 | $1 & 22 | fi 23 | else 24 | echo "no" 25 | fi 26 | -------------------------------------------------------------------------------- /i3-wm-scripts/Numlock.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | xmodmap -e "keysym y = Tab" 4 | xmodmap -e "keysym u = 7" 5 | xmodmap -e "keysym i = 8" 6 | xmodmap -e "keysym o = 9" 7 | xmodmap -e "keysym p = equal" 8 | xmodmap -e "keysym h = BackSpace" 9 | xmodmap -e "keysym j = 4" 10 | xmodmap -e "keysym k = 5" 11 | xmodmap -e "keysym l = 6" 12 | xmodmap -e "keysym semicolon = plus" 13 | xmodmap -e "keysym n = 1" 14 | xmodmap -e "keysym m = 2" 15 | xmodmap -e "keysym comma = 3" 16 | xmodmap -e "keysym b = 0" 17 | xmodmap -e "keysym period = minus" 18 | -------------------------------------------------------------------------------- /roficalc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : roficalc.sh 6 | # @created : Sat 11 Jan 2020 09:15:22 PM MST 7 | # 8 | # @description : wraper for rofi-calc and xclip 9 | ###################################################################### 10 | 11 | rofi -show calc -modi calc -no-show-match -no-sort -calc-command "echo '{result}' | xclip" 12 | 13 | # vim: set tw=78 ts=2 et sw=2 sr: 14 | -------------------------------------------------------------------------------- /tools/transadd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Mimeapp script for adding torrent to transmission-daemon, but will also start 4 | # the daemon first if not running. 5 | 6 | # Optionally requires my `note` script. The sleep of 3 seconds is because the 7 | # transmission-daemon sometimes fails to take remote requests in its first 8 | # moments. 9 | 10 | pgrep -x transmission-da || (transmission-daemon && notify-send "Starting daemon..." && sleep 3 && pkill -RTMIN+7 i3blocks) 11 | 12 | transmission-remote -a "$@" && notify-send "⛵ Torrent added." 13 | -------------------------------------------------------------------------------- /tools/catdocx: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Print docx files to the terminal 3 | filename="$1" 4 | extension=${filename##*.} 5 | 6 | if [ ${extension} = "doc" ] 7 | then 8 | # Use cat doc for older document formats 9 | catdoc "$filename" 10 | else 11 | # Unzip the docx file, and grab just the text with sed 12 | # This also replaces opening tags with newlines 13 | # The final `sed G` double spaces the output 14 | unzip -p "$filename" | grep --text '/ \ 15 | /g' | sed 's/<[^<]*>//g' | grep -v '^[[:space:]]*$' | sed G 16 | fi 17 | -------------------------------------------------------------------------------- /dwm/unhide.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | tmpfile="/tmp/hidden" 4 | HIDDENWINDOWS=$(wc -l $tmpfile | cut -d " " -f1) 5 | 6 | if [ "$HIDDENWINDOWS" -le "1" ];then 7 | WINDOWID=$(sed 's/@@@/ /g' "$tmpfile" | awk '{print $NF}' ) 8 | else 9 | WINDOWID=$(sed 's/@@@/ /g' "$tmpfile" | dmenu -p "Show" -l "$HIDDENWINDOWS" | awk '{print $NF}' ) 10 | fi 11 | 12 | if [[ -n "$WINDOWID" ]]; then 13 | xdotool windowmap "$WINDOWID" 14 | sed -i '/'"${WINDOWID}"'/d' "$tmpfile" 15 | export WINDOWID= 16 | else 17 | notify-send "No hidden windows" 18 | fi 19 | -------------------------------------------------------------------------------- /i3-wm-scripts/i3volume: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | case $BLOCK_BUTTON in 4 | 1) setsid "$TERMINAL" -e pulsemixer & ;; 5 | 3) pulsemixer --toggle-mute ;; 6 | 4) pulsemixer --change-volume +5 ;; 7 | 5) pulsemixer --change-volume -5 ;; 8 | esac 9 | 10 | [ "$(pulsemixer --get-mute)" = "1" ] && printf "🔇\\n" && exit 11 | 12 | vol=$(pulsemixer --get-volume | awk '{print $1}') 13 | 14 | if [ "$vol" -gt "70" ]; then 15 | icon="🔊" 16 | elif [ "$vol" -lt "30" ]; then 17 | icon="🔈" 18 | else 19 | icon="🔉" 20 | fi 21 | 22 | printf "%s %s%%\\n" "$icon" "$vol" 23 | -------------------------------------------------------------------------------- /tools/getbib: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Give this script a .pdf and it will attempt 4 | # to return a proper .bib citation via doi. 5 | # Internet connection required. 6 | 7 | # Get the doi from metadata, if not possible, get 8 | # doi from pdftotext output, if not possible, exit. 9 | doi=$(pdfinfo "$1" | grep -o doi:.*) || 10 | doi=$(pdftotext "$1" - | grep -o doi.* -m 1) || 11 | exit 1 12 | 13 | # Check crossref.org for the bib citation. 14 | curl -s "http://api.crossref.org/works/$doi/transform/application/x-bibtex" -w "\n" | 15 | sed -e "/^[^\(\t\|@\|}\)]/d" 16 | -------------------------------------------------------------------------------- /i3-wm-scripts/dmenuarchwiki: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Gives a dmenu prompt to search the Arch Wiki in your preferred web browser 4 | # Home goes to the home page of the Arch Wiki 5 | # Anything else, it search it 6 | 7 | # Original idea/script by Github user @Caedis. Minor changes by Luke. 8 | 9 | pgrep -x dmenu && exit 10 | 11 | choice=$(echo "📖" | dmenu -i -p "Type ArchWiki page or search term:") || exit 1 12 | 13 | if [ "$choice" = "📖" ]; then 14 | surf "https://wiki.archlinux.org" 15 | else 16 | surf "https://wiki.archlinux.org/index.php?search=$choice" 17 | fi 18 | -------------------------------------------------------------------------------- /dmenu/textbook.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : textbook.sh 6 | # @created : Sun 12 Jan 2020 01:00:06 AM MST 7 | # 8 | # @description : script for finding textbooks online fast 9 | ###################################################################### 10 | 11 | textbook=$(echo "textbook name" | dmenu -p "textbook") 12 | $BROWSER "http://gen.lib.rus.ec/search.php?req=$textbook" 13 | # vim: set tw=78 ts=2 et sw=2 sr: 14 | -------------------------------------------------------------------------------- /i3-wm-scripts/i3mpd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | filter() { 4 | sed "/^volume:/d" | tac | sed -e "s/\\&/&/g;s/\\[paused\\].*//g;s/\\[playing\\].*//g" | tr -d '\n' | sed -e "s/$/<\\/span>/g" 5 | } 6 | 7 | case $BLOCK_BUTTON in 8 | 1) mpc status | filter && $TERMINAL -e ncmpcpp & disown ;; # right click, pause/unpause 9 | 3) mpc toggle | filter ;; # right click, pause/unpause 10 | 4) mpc prev | filter ;; # scroll up, previous 11 | 5) mpc next | filter ;; # scroll down, next 12 | *) mpc status | filter ;; 13 | esac 14 | -------------------------------------------------------------------------------- /tools/check-ip-address: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # credit to the original auther: 3 | # Nathan Wallace 4 | # https://github.com/nwallace/dotfiles.git 5 | 6 | old_ip="$(grep 'Me:' ~/ip-addresses.note | cut -d ' ' -f 2)" 7 | current_ip="$(curl -s ipv4.icanhazip.com)" 8 | red="$(tput setaf 1)" 9 | green="$(tput setaf 2)" 10 | reset="$(tput sgr0)" 11 | 12 | if [[ "$old_ip" == "$current_ip" ]]; then 13 | echo "${green}✓${reset} IP is still ${green}${current_ip}${reset}" 14 | else 15 | echo -e "${red}✗${reset} IP has changed!\n Was: ${red}${old_ip}${reset}\n Is: ${green}${current_ip}${reset}" 16 | fi 17 | -------------------------------------------------------------------------------- /i3-wm-scripts/i3togglesplit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # if we don't have a file, start at zero 4 | if [ ! -f "/tmp/value.dat" ] ; then 5 | value=0 6 | i3-msg -q "split h" 7 | # otherwise read the value from the file 8 | else 9 | value=`cat /tmp/value.dat` 10 | fi 11 | 12 | if [[ $value == 1 ]]; 13 | then 14 | # notify-send -t 500 -a i3 "🡒 Horizontal" 15 | i3-msg -q "split h" 16 | value=`expr ${value} - 1` 17 | else 18 | # notify-send -t 500 -a i3 "🡓 Vertical" 19 | i3-msg -q "split v" 20 | value=`expr ${value} + 1` 21 | fi 22 | 23 | # and save it for next time 24 | echo "${value}" > /tmp/value.dat 25 | -------------------------------------------------------------------------------- /tools/cheat: -------------------------------------------------------------------------------- 1 | #!/usr/bin/sh 2 | # Quickly search cheat.sh dependint on 3 | # the inserted file type (used in my vimrc) 4 | file=$(readlink -f "$1") 5 | dir=$(dirname "$file") 6 | keyword=$2 7 | cd "$dir" || exit 8 | 9 | ask(){ 10 | curl -s cheat.sh/"$*" | less -R 11 | } 12 | 13 | [ -z "$keyword" ] && keyword=":learn" 14 | case "$file" in 15 | *tex) ask latex/"$keyword";; 16 | *c) ask c/"$keyword";; 17 | *h) ask c/"$keyword";; 18 | *py) ask python/"$keyword";; 19 | *go) ask go/"$keyword";; 20 | *vimrc) ask vim/"$keyword";; 21 | *vim) ask vim/"$keyword";; 22 | *) ask "$*";; 23 | esac 24 | -------------------------------------------------------------------------------- /toggle-trackpad: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : toggle-trackpad.sh 6 | # @created : Wed 09 Dec 2020 11:48:22 AM 7 | # 8 | # @description : toggle on and off Trackpad 9 | ###################################################################### 10 | 11 | if xinput --list-props "Elan Touchpad" | grep -q 'Device Enabled.*1$'; then 12 | xinput disable "Elan Touchpad" 13 | else 14 | xinput enable "Elan Touchpad" 15 | fi 16 | 17 | 18 | # vim: set tw=78 ts=2 et sw=2 sr: 19 | 20 | -------------------------------------------------------------------------------- /tools/rssadd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ! echo "$1" | grep "https*://\S\+\.[A-Za-z]\+\S*" >/dev/null && 3 | notify-send "That doesn't look like a full URL." && exit 4 | RSSFILE="$HOME/.config/newsboat/urls" 5 | if awk '{print $1}' "$RSSFILE" | grep "^$1$" >/dev/null; then 6 | notify-send "You already have this RSS feed." 7 | else 8 | RSSSTRING="$1" 9 | RSSNAME="$(echo "News" | dmenu -p "rss feed name")" 10 | [ -z "$RSSNAME" ] notify-send "Canceled adding rss." && exit 11 | if [ "$RSSNAME" != News ]; then 12 | RSSSTRING="\"~${RSSSTRING} $RSSNAME\"" 13 | fi 14 | echo "$RSSSTRING" >>"$RSSFILE" && notify-send "RSS feed added." 15 | fi 16 | -------------------------------------------------------------------------------- /i3-wm-scripts/i3wifi: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | case $BLOCK_BUTTON in 4 | 1) $TERMINAL -e sudo -A wifi-menu ;; 5 | esac 6 | 7 | INTERFACE="${BLOCK_INSTANCE:-wls1}" 8 | 9 | [[ "$(cat /sys/class/net/$INTERFACE/operstate)" = 'down' ]] && echo 📡 && exit 10 | 11 | QUALITY=$(grep $INTERFACE /proc/net/wireless | awk '{ print int($3 * 100 / 70 - 1) }') 12 | 13 | echo 📶 $QUALITY% 14 | echo 📶 $QUALITY% 15 | 16 | # color 17 | if [[ $QUALITY -ge 80 ]]; then 18 | echo "#00FF00" 19 | elif [[ $QUALITY -lt 40 ]]; then 20 | echo "#FF0000" 21 | elif [[ $QUALITY -lt 60 ]]; then 22 | echo "#FF8000" 23 | elif [[ $QUALITY -lt 80 ]]; then 24 | echo "#FFF600" 25 | fi 26 | -------------------------------------------------------------------------------- /i3-wm-scripts/i3resize: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This script was made by `goferito` on Github. 3 | # Some cleanup by Luke. 4 | 5 | [ -z "$1" ] && echo "No direction provided" && exit 1 6 | distanceStr="2 px or 2 ppt" 7 | 8 | moveChoice() { 9 | i3-msg resize "$1" "$2" "$distanceStr" | grep '"success":true' || \ 10 | i3-msg resize "$3" "$4" "$distanceStr" 11 | } 12 | 13 | case $1 in 14 | up) 15 | moveChoice grow up shrink down 16 | ;; 17 | down) 18 | moveChoice shrink up grow down 19 | ;; 20 | left) 21 | moveChoice shrink right grow left 22 | ;; 23 | right) 24 | moveChoice grow right shrink left 25 | ;; 26 | esac 27 | 28 | -------------------------------------------------------------------------------- /tools/checkup: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Syncs repositories and downloads updates, meant to be run as a cronjob. 3 | 4 | ping -q -c 1 1.1.1.1 >/dev/null || exit 5 | 6 | notify-send "📦 Repository Sync" "Checking for package updates..." 7 | 8 | sudo pacman -Syyuw --noconfirm || notify-send "Error downloading updates. 9 | 10 | Check your internet connection, if pacman is already running, or run update manually to see errors." 11 | pkill -RTMIN+8 i3blocks 12 | 13 | if pacman -Qu | grep -v "\[ignored\]"; then 14 | notify-send "🎁 Repository Sync" "Updates available. Click statusbar icon (📦) for update." 15 | else 16 | notify-send "📦 Repository Sync" "Sync complete. No new packages for update." 17 | fi 18 | -------------------------------------------------------------------------------- /wac: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : wac.sh 6 | # @created : Tue 02 Mar 2021 09:09:05 PM 7 | # 8 | # @description : 9 | ###################################################################### 10 | 11 | WACOMWIN=/tmp/wac 12 | if [ ! -f "$WACOMWIN" ] || grep -v eDP1 "$WACOMWIN"; then 13 | echo eDP1 > "$WACOMWIN" 14 | xsetwacom --set "Wacom Intuos BT S Pen stylus" MapToOutput eDP1 15 | else 16 | echo DP2 > "$WACOMWIN" 17 | xsetwacom --set "Wacom Intuos BT S Pen stylus" MapToOutput DP2 18 | fi 19 | # vim: set tw=78 ts=2 et sw=2 sr: 20 | 21 | 22 | -------------------------------------------------------------------------------- /dmenu/dmenuemoji: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | LAUNCHER=${LAUNCHER:-"dmenu -i -l 20 -fn Monospace-18 "} 4 | # Can be a littl slow 5 | # LAUNCHER="emenu " 6 | # The famous "get a menu of emojis to copy" script. 7 | 8 | # Must have xclip installed to even show menu. 9 | xclip -h >/dev/null || exit 10 | 11 | chosen=$(grep -v "#" ~/.scripts/dmenu/unicode | $LAUNCHER) 12 | 13 | [ "$chosen" != "" ] || exit 14 | 15 | c=$(echo "$chosen" | sed "s/ .*//") 16 | echo "$c" | tr -d '\n' | xclip -selection clipboard 17 | notify-send "'$c' copied to clipboard." & 18 | 19 | hello 20 | 21 | s=$(echo "$chosen" | sed "s/.*; //" | awk '{print $1}') 22 | echo "$s" | tr -d '\n' | xclip 23 | notify-send "'$s' copied to primary." & 24 | -------------------------------------------------------------------------------- /i3-wm-scripts/i3weather: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ### This is only if your location isn't automatically detected, otherwise you can leave it blank. 3 | location="" 4 | 5 | [ "$location" != "" ] && location="$location+" 6 | 7 | [ "$BLOCK_BUTTON" = "1" ] && $TERMINAL -e popweather 8 | 9 | ping -q -w 1 -c 1 "$(ip r | grep default | tail -1 | cut -d ' ' -f 3)" >/dev/null || exit 10 | 11 | curl -s wttr.in/$location > ~/.weatherreport 12 | 13 | printf "%s" "$(sed '16q;d' ~/.weatherreport | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/☔ /g" | tr -d '\n')" 14 | 15 | sed '13q;d' ~/.weatherreport | grep -o "m\\(-\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ❄️",$1 "°","☀️",$2 "°"}' 16 | -------------------------------------------------------------------------------- /i3-wm-scripts/checksplit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | split_checker() 4 | { 5 | while true 6 | do 7 | # if we don't have a file, start at zero 8 | # if [ ! -f "/tmp/value.dat" ] ; then 9 | # value=0 10 | # otherwise read the value from the file 11 | # else 12 | value=`cat /tmp/value.dat` 13 | # fi 14 | if [[ $value == 1 ]]; 15 | then 16 | echo "[V]" 17 | # i3-msg -q "split v" 18 | else 19 | echo "[>]" 20 | # i3-msg -q "split h" 21 | fi 22 | sleep 0.4 23 | done 24 | } 25 | 26 | 27 | if [ -f "/tmp/value.dat" ] ; then 28 | split_checker 29 | else 30 | value=0 31 | echo "[>]" 32 | i3-msg -q "split h" 33 | # and save it for next time 34 | echo "${value}" > /tmp/value.dat 35 | split_checker 36 | fi 37 | -------------------------------------------------------------------------------- /webcam.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : webcam.sh 6 | # @created : Wed 22 Jul 2020 10:47:50 PM 7 | # 8 | # @description : simple webcam display 9 | ###################################################################### 10 | 11 | # droidcam-cli adb 4747 & 12 | # mpv av://v4l2:/dev/video0 --no-osc --profile=low-latency --untimed --geometry=-1920-1080 --autofit=30% --no-resume-playback 13 | 14 | # pkill -f /dev/video || mpv --no-osc --no-input-default-bindings --input-conf=/dev/null --geometry=-0-0 --autofit=30% --title="mpvfloat" /dev/video0 15 | 16 | # vim: set tw=78 ts=2 et sw=2 sr: 17 | 18 | -------------------------------------------------------------------------------- /dmenu/castcontrol.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | res=$(printf "play/pause\\nstop\\nnext\\nvup\\nmute\\nvdown\\nh(<)\\nl(>)\\nopen" | dmenu -l -i -p 'Cast Controls:' ) 4 | 5 | case "$res" in 6 | play/pause) castnow --command space --exit >/dev/null 2>&1 & ;; 7 | stop) castnow --command s --exit >/dev/null 2>&1 & ;; 8 | next) castnow --command n --exit >/dev/null 2>&1 & ;; 9 | vup) castnow --command up --exit >/dev/null 2>&1 & ;; 10 | vdown) castnow --command down --exit >/dev/null 2>&1 & ;; 11 | mute) castnow --command m --exit >/dev/null 2>&1 & ;; 12 | h*) castnow --command left --exit >/dev/null 2>&1 & ;; 13 | l*) castnow --command right --exit >/dev/null 2>&1 & ;; 14 | open) st -g "=30x4-0+0" -e castnow >/dev/null 2>&1 & ;; 15 | *) exit 16 | esac 17 | #vim:ft=sh 18 | -------------------------------------------------------------------------------- /tools/cm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | NUM="${2:-5}" 4 | 5 | # Get the selected sink volume 6 | updatevolume() { statwe -a; } 7 | 8 | # Uncomment the following line to use Pulseaudio. 9 | PIPEWIRE=true 10 | if [ "$PIPEWIRE" ]; then 11 | toggle() { pactl set-sink-mute @DEFAULT_SINK@ toggle; } 12 | up() { pactl set-sink-volume @DEFAULT_SINK@ +"${NUM}"%; } 13 | down() { pactl set-sink-volume @DEFAULT_SINK@ -"${NUM}"%; } 14 | control() { pulsemixer; } 15 | connect() { njconnect; } 16 | else 17 | toggle() { amixer sset Master toggle; } 18 | up() { amixer sset Master "${NUM}"%+; } 19 | down() { amixer sset Master "${NUM}"%-; } 20 | control() { alsamixer; } 21 | fi 22 | 23 | case "$1" in 24 | mute) toggle ;; 25 | up) up ;; 26 | down) down ;; 27 | connect) connect ;; 28 | *) 29 | control 30 | exit 0 31 | ;; 32 | esac 33 | updatevolume 34 | -------------------------------------------------------------------------------- /tools/gif.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # basis for this comes from 3 | # https://github.com/flameshot-org/flameshot/issues/172 4 | [ $# -lt 2 ] && \ 5 | echo 'You have to pass a duration in seconds and a filename: "gif.sh 10 /tmp/record.gif"' && \ 6 | exit 1 7 | 8 | function is-installed() { 9 | if [ ! command -v "$1" ] > /dev/null; then 10 | echo "please install $1 first" 11 | exit 2 12 | fi 13 | } 14 | 15 | is-installed "byzanz-record" 16 | is-installed "slop" 17 | 18 | byzanz-record \ 19 | --cursor \ 20 | --verbose \ 21 | --delay=2 \ 22 | --duration=${1} \ 23 | $(slop -f "--x=%x --y=%y --width=%w --height=%h") \ 24 | "${2}" 25 | -------------------------------------------------------------------------------- /fzf/wifi: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | has() { 4 | local verbose=false 5 | if [[ $1 == '-v' ]]; then 6 | verbose=true 7 | shift 8 | fi 9 | for c in "$@"; do c="${c%% *}" 10 | if ! command -v "$c" &> /dev/null; then 11 | [[ "$verbose" == true ]] && err "$c not found" 12 | return 1 13 | fi 14 | done 15 | } 16 | 17 | err() { 18 | printf '\e[31m%s\e[0m\n' "$*" >&2 19 | } 20 | 21 | die() { 22 | (( $# > 0 )) && err "$*" 23 | exit 1 24 | } 25 | 26 | has -v nmcli fzf || die 27 | 28 | nmcli -d wifi rescan 2> /dev/null 29 | network=$(nmcli --color yes device wifi | fzf --ansi --height=40% --reverse --cycle --inline-info --header-lines=1) 30 | [[ -z "$network" ]] && exit 31 | network=$(sed -r 's/^\s*\*?\s*//; s/\s*(Ad-Hoc|Infra).*//' <<< "$network") 32 | echo "connecting to \"${network}\"..." 33 | nmcli -a device wifi connect "$network" 34 | -------------------------------------------------------------------------------- /tools/tts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Biggest issue with this approach is you need to be online to use it :( 3 | # depends on 4 | # - python-gtts (gtts-cli) 5 | # - ffmpeg (speeding up and play audio ) 6 | 7 | TMPFILE=$(mktemp XXX.mp3) 8 | # TMPFILE2=$(mktemp XXXY.mp3) 9 | trap 'rm $TMPFILE' EXIT TERM HUP 10 | # trap 'rm $TMPFILE2' EXIT TERM HUP 11 | 12 | # # Test for Palse Audio or Default to Alsa 13 | # ps -C pulseaudio 2>&1 >/dev/null 14 | # test [ $? == 0 ] && FLAGS="-D 'pulse'" || FLAGS="" 15 | echo "$*" | piper-tts --model /usr/share/piper-voices/en/en_US/danny/low/en_US-danny-low.onnx -f "$TMPFILE" 16 | mpv "$TMPFILE" 17 | 18 | # gtts-cli "$1" | ffplay -autoexit -nodisp -hide_banner -loglevel quiet -f mp3 -i pipe: -af "atempo=1.33" 19 | # Modified to force every line to be read in one at a time. Seems to 20 | # prevent most of the errors I have faced with this 21 | -------------------------------------------------------------------------------- /surf/mypassmenu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | winid=$(xdotool getactivewindow) 4 | shopt -s nullglob globstar 5 | 6 | typeit=0 7 | if [[ $1 == "--type" ]]; then 8 | typeit=1 9 | shift 10 | fi 11 | 12 | prefix=${PASSWORD_STORE_DIR-~/.password-store} 13 | password_files=( "$prefix"/**/*.gpg ) 14 | password_files=( "${password_files[@]#"$prefix"/}" ) 15 | password_files=( "${password_files[@]%.gpg}" ) 16 | 17 | password=$(printf '%s\n' "${password_files[@]}" | uniq | dmenu -w "$winid" -l 5 "$@" ) 18 | 19 | [[ -n $password ]] || exit 0 20 | 21 | #copy username to clipboard 22 | pass show "$password" | grep login: | sed 's/login: //' | awk 'NR==1' | xclip 23 | if [[ $typeit -eq 0 ]]; then 24 | pass show -c "$password" 2>/dev/null 25 | else 26 | pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } | 27 | xdotool type --clearmodifiers --file - 28 | fi 29 | 30 | #vim:ft=sh 31 | -------------------------------------------------------------------------------- /dmenu/typo: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This is a simple script that utilises dmenu to 4 | # check the spelling of a word using aspell. 5 | # After a selection has been made it will use xclip 6 | # to copy to clipboard. 7 | 8 | LAUNCER="emenu -i -p " 9 | 10 | word=$(echo "?" | $LAUNCER 'spell') 11 | 12 | if [ -n "$word" ] && [ "$word" != "?" ]; then 13 | selection=$(echo "$word" | aspell pipe --suggest | sed -e '1d; s/^[^:]*://g; s/, /\n/g; s/^ //' | $LAUNCER 'copy') 14 | [ -z "$selection" ] && exit 15 | if [ "$selection" = "*" ]; then 16 | printf "%s" "$word" | xclip -selection clipboard 17 | printf "%s" "$word" | xclip -selection primary 18 | else 19 | printf "%s" "$selection" | xclip -selection clipboard 20 | printf "%s" "$selection" | xclip -selection primary 21 | fi 22 | pgrep -x dunst >/dev/null && notify-send "$(xclip -o -selection clipboard) copied to clipboard." 23 | fi 24 | exit 25 | -------------------------------------------------------------------------------- /tools/opout: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # opout: "open output": A general handler for opening a file's intended output. 3 | # I find this useful especially running from vim. 4 | basename="$(echo "$1" | sed 's/\.[^\/.]*$//')" 5 | file=$(readlink -f "$1") 6 | dir=$(dirname "$file") 7 | secdir=$(dirname "$dir") 8 | case "$1" in 9 | *.m[sed]|*.mom|*.tr|*.groff|*.docx|*.doc|*.org|*.ps|*.tex|*.txp) 10 | if [ -f "$basename".pdf ]; then 11 | setsid "$READER" "$basename".pdf >/dev/null 2>&1 & 12 | elif [ -f "$basename".ps ]; then 13 | setsid "$READER" "$basename".ps >/dev/null 2>&1 & 14 | elif [ -f "$basename".html ]; then 15 | setsid "google-chrome-stable" "$basename".html >/dev/null 2>&1 & 16 | fi 17 | ;; 18 | *.pdf) setsid "$READER" "$file" >/dev/null 2>&1 & ;; 19 | *.html) 20 | setsid brave "$basename".html >/dev/null 2>&1 & ;; 21 | *.sent) setsid sent "$1" >/dev/null 2>&1 & ;; 22 | esac 23 | -------------------------------------------------------------------------------- /tools/ytgrep: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Find The Original Project Here 3 | # https://git.2f30.org/scripts/file/ytgrep.html 4 | 5 | #depends: jq 6 | #usage: 7 | # ytgrep [-n nresults] terms... 8 | 9 | KEY="AIzaSyAa5gAarPnuu9zTVjpp6mPyStbY17uuhSE" 10 | NRES=10 11 | 12 | search() { 13 | sstr="" 14 | if [ ${#} -ne 1 ]; then #make a list 15 | for arg in $@; do 16 | sstr=$sstr"$arg|" 17 | done 18 | else 19 | sstr=$1 20 | fi 21 | curl -s -G "https://www.googleapis.com/youtube/v3/search" -d part="snippet" -d q=$sstr -d maxResults=$NRES -d key=$KEY | jq '[.items[] | {"title":.snippet.title, "url": ["https://www.youtube.com/watch?v=" + .id.videoId] }]' - 22 | } 23 | 24 | command -v jq >/dev/null || { 25 | echo jq is not installed 1>&2 26 | exit 1 27 | } 28 | 29 | case $1 in 30 | -n ) NRES=$2; shift 2; search $@ 31 | ;; 32 | * ) search $@ 33 | ;; 34 | esac 35 | -------------------------------------------------------------------------------- /tools/pomodoro: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #pomodoro 3 | recordTomato () { 4 | notify-send "pomodoro" "break" 5 | mpv /usr/share/sounds/freedesktop/stereo/message.oga 6 | exec 3>&1 7 | exec 3>&-; 8 | runBreak 9 | } 10 | 11 | runTomato () { 12 | notify-send "pomodoro" "Start tomato" 13 | mpv /usr/share/sounds/freedesktop/stereo/message.oga 14 | seconds=1500; 15 | date1=$((`date +%s` + seconds)); 16 | while [ "$date1" -ge "$(date +%s)" ]; 17 | do 18 | dialog --infobox "Work for $(date -u --date @$(($date1 - `date +%s` )) +%H:%M:%S)" 10 30 ; sleep 1 19 | done 20 | recordTomato 21 | } 22 | 23 | runBreak () { 24 | seconds=300; 25 | date1=$((`date +%s` + seconds)); 26 | 27 | while [ "$date1" -ge "$(date +%s)" ]; 28 | do 29 | dialog --infobox "Nice work 30 | Now you're on break! 31 | rest for $(date -u --date @$(($date1 - "$(date +%s)" )) +%H:%M:%S)" 0 0 ; sleep 1 32 | done 33 | runTomato 34 | } 35 | 36 | runTomato 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Scripts 2 | 3 | This is a collection of scripts that I often use 4 | 5 | ## Getting Started 6 | 7 | Simply clone this repo and recursivly add it to the `PATH` 8 | 9 | ### Prerequisites 10 | 11 | - dmenu (many scripts can work with fzf instead) 12 | - fzf 13 | - xdotool 14 | - xprop 15 | - jgmenu 16 | - POSIX complient shell 17 | - xclip 18 | - curl 19 | - qrencode (optional) 20 | - TERMINAL (set this environment variable) 21 | - EDITOR (set this environment variable) 22 | - PLUMBER (set this environment variable) 23 | - used to open programs 24 | 25 | ## Authors 26 | 27 | * **Gavin Jaeger-Freeborn** - *Initial work* - [Gavinok](https://github.com/Gavinok) 28 | 29 | ## License 30 | 31 | This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details 32 | 33 | ## Acknowledgments 34 | 35 | * Hat tip to [Luke Smith](https://github.com/LukeSmithxyz) for some of the scripts modified 36 | -------------------------------------------------------------------------------- /i3-wm-scripts/bottomleft: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script move the selected window to the bottom left of the screen. 4 | 5 | current=$(xdotool getwindowfocus) 6 | 7 | type dwmc >/dev/null 2>&1 && dwmc setfloating 8 | 9 | # The window will take up no more than a third of 10 | # the width or height of the screen. 11 | newwidth=$(($(xdotool getdisplaygeometry | awk '{print $2}') / 2)) 12 | newheight=$(($(xdotool getdisplaygeometry | awk '{print $1}') / 2)) 13 | 14 | xdotool windowsize $(xdotool getwindowfocus) $newheight $newwidth 15 | 16 | newsize=$(xdotool getwindowgeometry $(xdotool getwindowfocus) | grep Geometry | sed -e 's/x/ /g' | awk '{print $3}') 17 | 18 | height=$(($(xdotool getdisplaygeometry | awk '{print $2}') - newsize)) 19 | xdotool windowmove $current 0 $height 20 | # i3-msg "[con_id="$current"] focus" 21 | # WS=~/.scripts/i3getworkspace.sh 22 | # echo "$WS" 23 | # i3-msg "[con_id="$current"] move workspace $WS" 24 | -------------------------------------------------------------------------------- /funnel/funnel: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ###################################################################### 3 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 4 | # @file : tslink.sh 5 | # @created : Sat 29 Feb 2020 01:13:37 PM 6 | # 7 | # @description : simple taskspooler using fifo 8 | ###################################################################### 9 | 10 | [ -z "$1" ] && echo please enter a url && exit 11 | 12 | pipename=ts.pipe 13 | pipefile="/tmp/${pipename}" 14 | lockfile="/tmp/ts.lock" 15 | 16 | tsstart() { 17 | touch "${lockfile}" 18 | while read url ; do 19 | open "$url" 20 | done < "${pipefile}" 21 | rm -f "${lockfile}" 22 | notify-send " Tasks Completed" 23 | } 24 | 25 | [ ! -p "${pipefile}" ] && mkfifo "${pipefile}" 26 | 27 | echo "$1" > "${pipefile}" & 28 | 29 | # quit if lockfile already exists 30 | [ -f "${lockfile}" ] && exit 31 | 32 | tsstart & 33 | # vim: set tw=78 ts=2 et sw=2 sr: 34 | -------------------------------------------------------------------------------- /i3-wm-scripts/nextmatch: -------------------------------------------------------------------------------- 1 | #!/bin/python3 2 | import re 3 | import string 4 | import sys 5 | 6 | import common 7 | 8 | def search_window(windows, expr): 9 | flags = re.I 10 | for x in expr: 11 | if x in string.ascii_uppercase: 12 | flags = 0 13 | break 14 | regex = re.compile(expr, re.I) 15 | matches = [] 16 | for (wm_class, name), L in windows.items(): 17 | print(wm_class) 18 | if regex.match(wm_class) or regex.match(name): 19 | matches.extend(L) 20 | return matches 21 | 22 | def main(args): 23 | if len(args) != 1: 24 | return "usage: nextmatch [TEXT]" 25 | current, windows = common.get_named_windows() 26 | matches = search_window(windows, args[0]) 27 | print(matches) 28 | if matches: 29 | common.focus_window(common.cycle_selected(current, matches)) 30 | 31 | if __name__ == "__main__": 32 | sys.exit(main(sys.argv[1:])) 33 | -------------------------------------------------------------------------------- /i3-wm-scripts/center: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script move the selected window to the bottom left of the screen. 4 | 5 | current=$(xdotool getwindowfocus) 6 | 7 | # The window will take up no more than a third of 8 | # the width or height of the screen. 9 | newwidth=$(($(xdotool getdisplaygeometry | awk '{print $2}') / 2)) 10 | newheight=$(($(xdotool getdisplaygeometry | awk '{print $1}') / 2)) 11 | 12 | xdotool windowsize $(xdotool getwindowfocus) $newheight $newwidth 13 | 14 | newsize=$(xdotool getwindowgeometry $(xdotool getwindowfocus) | grep Geometry | sed -e 's/x/ /g' | awk '{print $3}') 15 | 16 | height=$(($(xdotool getdisplaygeometry | awk '{print $2}') - newsize)) 17 | width=$(($(xdotool getdisplaygeometry | awk '{print $1}') - newsize)) 18 | xdotool windowmove $current 0 $height 19 | # i3-msg "[con_id="$current"] focus" 20 | # WS=~/.scripts/i3getworkspace.sh 21 | # echo "$WS" 22 | # i3-msg "[con_id="$current"] move workspace $WS" 23 | -------------------------------------------------------------------------------- /covid19.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : covid19.sh 6 | # @created : Tue 24 Mar 2020 09:29:35 PM 7 | # 8 | # @description : Simple script to get the death percentage for COVED-19 9 | # every hour 10 | ###################################################################### 11 | 12 | country=Canada 13 | 14 | stats=$(curl -s "https://corona-stats.online/${country}/?source=2&format=json" | jq '.data[]') 15 | deaths=$(echo "${stats}" | jq '.deaths') 16 | cases=$(echo "${stats}" | jq '.cases') 17 | deathrate=''$(echo "(${deaths}" / "${cases}) * 100" | bc -l | cut -c -3)'%' 18 | deathrate=$(printf "😷 Cases: %s 19 | 💀 Deaths: %s 20 | 21 | %s 💀/😷 in Canada 22 | form COVID-19" "${cases}" "${deaths}" "${deathrate}") 23 | notify-send "${deathrate}" 24 | 25 | # vim: set tw=78 ts=2 et sw=2 sr: 26 | -------------------------------------------------------------------------------- /commit-org.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Customize this path to your org files directory 4 | ORG_DIR="$HOME/.local/Dropbox/Documents/org" 5 | DEBOUNCE_SECONDS=10 6 | LAST_RUN=0 7 | 8 | cd "$ORG_DIR" || { 9 | echo "Directory not found: $ORG_DIR" 10 | exit 1 11 | } 12 | 13 | # Add all changes 14 | git add . 15 | 16 | # Use a timestamp as the commit message 17 | COMMIT_MSG="Auto-commit: $(date '+%Y-%m-%d %H:%M:%S')" 18 | 19 | inotifywait -m -r -e close_write,create,delete,move "$ORG_DIR" --exclude ".git/**" | 20 | while read -r directory events filename; do 21 | # Only commit if there are changes 22 | NOW=$(date +%s) 23 | git add . 24 | sleep 1 25 | if ((NOW - LAST_RUN >= DEBOUNCE_SECONDS)) && ! git diff --cached --quiet; then 26 | git commit -m "$COMMIT_MSG" 27 | git pull --rebase # in case of remote changes 28 | git push 29 | echo "Changes committed and pushed." 30 | LAST_RUN=$NOW 31 | else 32 | echo "No changes to commit." 33 | fi 34 | done 35 | -------------------------------------------------------------------------------- /wip/gate.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : gate.sh 6 | # @created : Tue 26 Jan 2021 11:08:19 AM 7 | # 8 | # @description : apply a noise gate to a video 9 | ###################################################################### 10 | # TODO: needs some work 11 | ADDED_TEXT=POST 12 | infile="$1" 13 | tmpaudio=tmp.wav 14 | tmpaudio2=tmp2.wav 15 | outfile="${ADDED_TEXT}${infile}" 16 | soundprofile="${HOME}/noise_profile_file" 17 | minvol=-50 18 | [ -f "$soundprofile" ] || soundprofile="$2" 19 | 20 | ffmpeg -i "$infile" -vn -ac 1 -f wav "${tmpaudio}" 21 | sox "${tmpaudio}" "${tmpaudio2}" \ 22 | noisered "$soundprofile" 0.21 \ 23 | compand .1,.2 -inf,-50.1,-inf,${minvol},${minvol} 0 -90 .1 24 | ffmpeg -i "$infile" -i "${tmpaudio2}" -c:v copy -map 0:v:0 -map 1:a:0 "${outfile}" 25 | ffplay -i "${outfile}" 26 | # vim: set tw=78 ts=2 et sw=2 sr: 27 | 28 | -------------------------------------------------------------------------------- /dmenu/ducksearch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Gives a dmenu prompt to search DuckDuckGo. 4 | # Without input, will open DuckDuckGo.com. 5 | # Anything else, it search it.h 6 | [ -z "$LAUNCHER" ] && LAUNCHER="dmenu -l 5 -i -p " 7 | [ -z "${DISPLAY}" ] && LAUNCHER="fzf --prompt " 8 | [ "${XDG_SESSION_TYPE}" = "wayland" ] && LAUNCHER="wmenu -l 5 -i -p " 9 | 10 | localBROWSER="$BROWSER " 11 | [ -n "$*" ] && localBROWSER="$*" 12 | [ -z "${DISPLAY}" ] && localBROWSER="xdg-open " 13 | 14 | if [ -f ~/.config/bookmarks ]; then 15 | choice=$( (echo "🦆" && cat ~/.config/bookmarks) | $LAUNCHER "Search:") || exit 1 16 | else 17 | choice=$(echo "🦆" | $LAUNCHER -i -p "Search DuckDuckGo:") || exit 1 18 | fi 19 | 20 | case "$choice" in 21 | *🦆*) 22 | $localBROWSER"https://duckduckgo.com" 23 | exit 24 | ;; 25 | http*) 26 | $localBROWSER"$(echo $choice | awk '{print $1}')" 27 | exit 28 | ;; 29 | *) 30 | $localBROWSER"https://duckduckgo.com/?q=$choice" 31 | exit 32 | ;; 33 | esac 34 | #vim:ft=sh 35 | -------------------------------------------------------------------------------- /i3-wm-scripts/bottomright: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script move the selected window to the bottom left of the screen. 4 | current=$(xdotool getwindowfocus) 5 | 6 | type dwmc >/dev/null 2>&1 && dwmc setfloating 7 | 8 | # The window will take up no more than a third of 9 | # the width or height of the screen. 10 | newwidth=$(($(xdotool getdisplaygeometry | awk '{print $2}') / 2)) 11 | newheight=$(($(xdotool getdisplaygeometry | awk '{print $1}') / 2)) 12 | 13 | xdotool windowsize "$(xdotool getwindowfocus)" $newheight $newwidth 14 | 15 | newsize=$(xdotool getwindowgeometry "$(xdotool getwindowfocus)" | grep Geometry | sed -e 's/x/ /g' | awk '{print $3}') 16 | newwidth=$(xdotool getwindowgeometry "$(xdotool getwindowfocus)" | grep Geometry | grep -o " [0-9]*") 17 | 18 | vertical=$(($(xdotool getdisplaygeometry | awk '{print $2}') - newsize)) 19 | horizontal=$(($(xdotool getdisplaygeometry | awk '{print $1}') - newwidth)) 20 | 21 | xdotool windowmove "$current" $horizontal $vertical 22 | # i3-msg "[con_id="$current"] focus" 23 | -------------------------------------------------------------------------------- /tools/chrome_createpass.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # a script for converting Chrome Passwords.csv to pass 3 | # files that can, its still a work in progress 4 | # currently it is functional enough to use 5 | FILE="$HOME/Documents/Chrome Passwords.csv" 6 | PREFORMAT=$(tail -n +2 "$FILE" | sed '/http/!d' | sed '/^,android/d'| \ 7 | sed 's/,/\n/g' | sed '/^http/d' | sed 'n;N;s/^/user:/') 8 | 9 | echo "$PREFORMAT" > /tmp/chromepasstemp0.txt 10 | numlines=$(wc -l < "/tmp/chromepasstemp0.txt") 11 | numrepeats=$(( "$numlines" / 3)) 12 | numrepeats=$(( "$numrepeats" - 1)) 13 | echo "$numlines" 14 | for i in $(seq "$numrepeats") 15 | do 16 | passname=$(awk 'NR==1' "/tmp/chromepasstemp0.txt") 17 | pass=$(awk 'NR==3' "/tmp/chromepasstemp0.txt") 18 | user=$(awk 'NR==2' "/tmp/chromepasstemp0.txt") 19 | printf "%s\n%s" "$pass" "$user" | pass add -m "$passname" 20 | echo "$user"; 21 | awk 'NR!=1 && NR!=2 && NR!=3' "/tmp/chromepasstemp0.txt" > /tmp/chromepasstemp1.txt 22 | cat /tmp/chromepasstemp1.txt > /tmp/chromepasstemp0.txt 23 | done 24 | -------------------------------------------------------------------------------- /wip/malcheck.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : malcheck.sh 6 | # @created : Thu 09 Jan 2020 03:25:47 PM MST 7 | # 8 | # @description : check the number of watched episodes of an anime using fzf 9 | # and curl. 10 | ###################################################################### 11 | 12 | #=== FUNCTION ====================================================== 13 | # NAME: format 14 | # DESCRIPTION: formats json output 15 | #===================================================================== 16 | format() { 17 | echo "$*" | python -m json.tool 18 | } 19 | 20 | listtitle() { 21 | jq '.anime[] | .title' 22 | } 23 | 24 | 25 | watching=$(curl -s https://api.jikan.moe/v3/user/gswag/animelist/watching | 26 | jq '.anime[] | .title, .watched_episodes, .total_episodes') 27 | 28 | echo $watching 29 | 30 | # echo $watching 31 | 32 | # vim: set tw=78 ts=2 et sw=2 sr: 33 | 34 | -------------------------------------------------------------------------------- /dmenu/game-get.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : textbook.sh 6 | # @created : Sun 12 Jan 2020 01:00:06 AM MST 7 | # 8 | # @description : script for finding textbooks online fast 9 | ###################################################################### 10 | 11 | gamename=$(echo '🎮' | dmenu -p 'Game Name') 12 | page=$(curl 'https://www.gamestorrents.nu/?s=final+fantasy') 13 | system=$(printf 'psp\nnds\nps3\nxbox360\npc\nps2\nwii\nmac' | dmenu -l 8 -p 'Game system' ) 14 | echo $system 15 | gamelist=$(echo $page | grep 'https://www.gamestorrents.nu' | grep -v '' -f 3 | sed 's/<\/a//g' | dmenu -l 5) 18 | www "$(echo $gamelist | grep -F "$game" | cut -d '"' -f 2)" 19 | $BROWSER "https://www.gamestorrents.nu/?s=$gamename" 20 | # vim: set tw=78 ts=2 et sw=2 sr: 21 | -------------------------------------------------------------------------------- /f: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : f.sh 6 | # @created : Fri 17 Jan 2020 09:35:29 AM MST 7 | # 8 | # @description : fzf shortcuts 9 | ###################################################################### 10 | 11 | fzedit(){ 12 | file=$(find "$@" -not -path "*/\.nnn*" -not -path "*/\.git*" -type f -print | fzf --bind "ctrl-o:execute-silent(setsid xdg-open {}&)") 13 | [ -e "$file" ] && ${EDITOR:-vi} "$file" 14 | } 15 | 16 | # TODO: automate adding these 17 | f() { 18 | case "$*" in 19 | d) 20 | fzedit ~/Documents/ 21 | ;; 22 | D) 23 | fzedit ~/Downloads/ 24 | ;; 25 | v) 26 | fzedit ~/.vim/ 27 | ;; 28 | p) 29 | fzedit ~/Programming/ 30 | ;; 31 | w) 32 | fzedit ~/.local/Dropbox/DropsyncFiles/vimwiki/ 33 | ;; 34 | m) 35 | fzedit ~/.config/nnn/mounts/ 36 | ;; 37 | s) 38 | fzedit ~/.scripts/ ~/.config/ 39 | ;; 40 | *) 41 | fzedit . 42 | ;; 43 | esac 44 | } 45 | 46 | f "$*" 47 | # vim: set tw=78 ts=2 et sw=2 sr: 48 | -------------------------------------------------------------------------------- /tty/ttysetup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ "$TERM" = "linux" ]; then 3 | # echo -en "\e]P0232323" #black 4 | # echo -en "\e]P82B2B2B" #darkgrey 5 | # echo -en "\e]P1D75F5F" #darkred 6 | # echo -en "\e]P9E33636" #red 7 | # echo -en "\e]P287AF5F" #darkgreen 8 | # echo -en "\e]PA98E34D" #green 9 | # echo -en "\e]P3D7AF87" #brown 10 | # echo -en "\e]PBFFD75F" #yellow 11 | # echo -en "\e]P48787AF" #darkblue 12 | # echo -en "\e]PC7373C9" #blue 13 | # echo -en "\e]P5BD53A5" #darkmagenta 14 | # echo -en "\e]PDD633B2" #magenta 15 | # echo -en "\e]P65FAFAF" #darkcyan 16 | # echo -en "\e]PE44C9C9" #cyan 17 | # echo -en "\e]P7E5E5E5" #lightgrey 18 | # echo -en "\e]PFFFFFFF" #white 19 | # clear #for background artifacting 20 | _SEDCMD='s/.*\*color\([0-9]\{1,\}\).*#\([0-9a-fA-F]\{6\}\).*/\1 \2/p' 21 | for i in $(sed -n "$_SEDCMD" $HOME/.Xresources | awk '$1 < 16 {printf "\\e]P%X%s", $1, $2}'); do 22 | echo -en "$i" 23 | done 24 | clear 25 | # Switch escape and caps if tty: 26 | sudo -n loadkeys ~/.scripts/tty/ttymaps.kmap 2>/dev/null 27 | fi 28 | 29 | -------------------------------------------------------------------------------- /feeder: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : feeder.sh 6 | # @created : Mon 29 Jun 2020 11:32:51 AM 7 | # 8 | # @description : A simple rss reader using dmenu and sfeed 9 | ###################################################################### 10 | 11 | # check sfeed is installed 12 | command -v "sfeed" >/dev/null || { notify-send "📦 sfeed must be installed for this function." && exit 1; } 13 | # check dmenu is installed 14 | command -v "dmenu" >/dev/null || { notify-send "📦 dmenu must be installed for this function." && exit 1; } 15 | 16 | # find alternative apps if it is installed on your system 17 | find_alt() { for i;do command -v "${i}" >/dev/null && { echo "${i}"; return 0;};done;return 1; } 18 | export PLUMBER=$(find_alt cabl $OPENER) 19 | 20 | url=$(sfeed_plain "$HOME/.sfeed/feeds/"* | dmenu -l 35 -i | \ 21 | sed -n 's@^.* \([a-zA-Z]*://\)\(.*\)$@\1\2@p') 22 | test -n "${url}" && $PLUMBER "${url}" 23 | 24 | # vim: set tw=78 ts=2 et sw=2 sr: 25 | -------------------------------------------------------------------------------- /tools/ytplay: -------------------------------------------------------------------------------- 1 | #!/usr/bin/sh 2 | 3 | # script they plays youtube videos that opens a youtube video in 4 | # the best available quality up to 480p since more then that 5 | # is bloat 6 | 7 | notify-send "Playing video" 8 | # try to run video in lower format 9 | allcpus_enabled=$(cat /sys/devices/system/cpu/cpu1/online) 10 | charging_state=$(cat /sys/class/power_supply/BAT0/status) 11 | 12 | if [ "$allcpus_enabled" -eq 0 ]; then 13 | # 360p if not all cores are enabled 14 | setsid mpv --force-window=immediate --really-quiet\ 15 | --ytdl-format="bestvideo[height<=?360]+bestaudio/best" "$*" >/dev/null 2>&1 && 16 | exit 17 | elif [ "$charging_state" = 'Charging' ]; then 18 | # Default to 720p if charging 19 | setsid mpv --force-window=immediate --really-quiet\ 20 | --ytdl-format="bestvideo[height<=?720]+bestaudio/best" "$*" >/dev/null 2>&1 && 21 | exit 22 | else 23 | # Default to 480p 24 | setsid mpv --force-window=immediate --really-quiet\ 25 | --ytdl-format="bestvideo[height<=?480]+bestaudio/best" "$*" >/dev/null 2>&1 && 26 | exit 27 | fi 28 | 29 | # video cannot me loaded 30 | notify-send "Failed to play Video" 31 | #vim:ft=sh 32 | -------------------------------------------------------------------------------- /i3-wm-scripts/guidd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This script simplifies dropdown windows in i3. 3 | # Shows/hides a scratchpad of a given name, if it doesn't exist, creates it. 4 | # Usage: 5 | # argument 1: script to run in dropdown window 6 | # all other args are interpreted as options for your terminal 7 | # My usage: 8 | # ddpawn 9 | # bindsym $mod+u exec --no-startup-id ddspawn tmuxdd 10 | # Will hide/show window running the `tmuxdd` script when I press mod+u in i3 11 | # bindsym $mod+a exec --no-startup-id ddspawn dropdowncalc -f mono:pixelsize=24 12 | # Similar to above but with `dropdowncalc` and the other args are interpretated as for my terminal emulator (to increase font) 13 | 14 | 15 | [ -z "$1" ] && exit 16 | 17 | if xwininfo -tree -root | grep "(\"$1\" "; 18 | then 19 | echo "Window detected." 20 | else 21 | echo "Window not detected... spawning." 22 | i3 "exec --no-startup-id $1" && i3 "[instance=\"$1\"] scratchpad show; [instance=\"$1\"] move position center" 23 | sleep .25 # This sleep is my laziness, will fix later (needed for immediate appearance after spawn). 24 | fi 25 | i3 "[instance=\"$1\"] scratchpad show; [instance=\"$1\"] move position center" 26 | 27 | 28 | -------------------------------------------------------------------------------- /wip/feedcheck.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : feedcheck.sh 6 | # @created : Mon 11 Jan 2021 08:07:36 PM 7 | # 8 | # @description : check rss feed 9 | ###################################################################### 10 | 11 | CACHEDIR="$XDG_CACHE_HOME/sfeed" 12 | mkdir -p "$CACHEDIR" 13 | UNREAD_CACHE="$CACHEDIR/unread_sfeed" 14 | READ_CACHE="$CACHEDIR/read_sfeed" 15 | TMPFILE=/tmp/sfeed_nodup 16 | FEEDDIR="$HOME/.sfeed/feeds" 17 | awkcmd='NR==FNR { 18 | a[$0]++ 19 | next 20 | } 21 | 22 | ! ($0 in a) { 23 | print 24 | }' 25 | update_cache() 26 | { 27 | sfeed_plain $FEEDDIR/* | grep '^N' >> "$UNREAD_CACHE" 28 | awk '!a[$0]++' "$UNREAD_CACHE" > "$TMPFILE" 29 | selected=$(awk "$awkcmd" "$READ_CACHE" "$TMPFILE" | dmenu -l 10) 30 | test -n "$selected" && echo "$selected" >> "$READ_CACHE" 31 | url=$(echo "$selected" | sed -n 's@^.* \([a-zA-Z]*://\)\(.*\)$@\1\2@p') 32 | test -n "$url" && $BROWSER "$url" 33 | rm "$TMPFILE" 34 | } 35 | 36 | update_cache 37 | # vim: set tw=78 ts=2 et sw=2 sr: 38 | 39 | -------------------------------------------------------------------------------- /i3-wm-scripts/simpledd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This script simplifies dropdown windows in i3. 3 | # Shows/hides a scratchpad of a given name, if it doesn't exist, creates it. 4 | # Usage: 5 | # argument 1: script to run in dropdown window 6 | # all other args are interpreted as options for your terminal 7 | # My usage: 8 | # ddpawn 9 | # bindsym $mod+u exec --no-startup-id ddspawn tmuxdd 10 | # Will hide/show window running the `tmuxdd` script when I press mod+u in i3 11 | # bindsym $mod+a exec --no-startup-id ddspawn dropdowncalc -f mono:pixelsize=24 12 | # Similar to above but with `dropdowncalc` and the other args are interpretated as for my terminal emulator (to increase font) 13 | 14 | 15 | [ -z "$1" ] && exit 16 | 17 | if xwininfo -tree -root | grep "(\"$1\" "; 18 | then 19 | echo "Window detected." 20 | else 21 | echo "Window not detected... spawning." 22 | i3 "exec --no-startup-id $TERMINAL -n $1 -e $1" && i3 "[instance=\"$1\"] scratchpad show; [instance=\"$1\"] move position center" 23 | sleep .25 # This sleep is my laziness, will fix later (needed for immediate appearance after spawn). 24 | fi 25 | i3 "[instance=\"$1\"] scratchpad show; [instance=\"$1\"] move position center" 26 | 27 | -------------------------------------------------------------------------------- /dmenu/power_menu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Simple dmenu based program that utilizes systemd 3 | 4 | [ -z "$LAUNCHER" ] && LAUNCHER="dmenu -l 5 -i -p " 5 | 6 | # ensure that no packages are being installed 7 | # check for pacman and yay 8 | [ -f /var/lib/pacman/db.lck ] && notify-send --urgency=critical "❕[ERROR] /var/lib/pacman/db.lck exists pacman in use" && exit 2 9 | 10 | progcheck() { 11 | pgrep -x "${1}" >/dev/null && notify-send --urgency=critical "❕[ERROR] $1 in use" && exit 1 12 | } 13 | 14 | 15 | res=$(printf 'shutdown\nreboot\nsleep\nhibernate\nkill X' | $LAUNCHER 'Power Menu:') 16 | 17 | # check for running programs 18 | progcheck pip 19 | progcheck pacman 20 | progcheck yay 21 | progcheck apt 22 | progcheck yarn 23 | progcheck npm 24 | progcheck rustc 25 | progcheck brew 26 | progcheck cargo 27 | progcheck rclone 28 | progcheck rsync 29 | progcheck blender 30 | 31 | case "${res}" in 32 | "reboot") 33 | systemctl reboot 34 | ;; 35 | "shutdown") 36 | systemctl poweroff 37 | ;; 38 | "sleep") 39 | systemctl suspend 40 | ;; 41 | "hibernate") 42 | systemctl hibernate 43 | ;; 44 | "kill X") 45 | killall Xorg 46 | ;; 47 | *) 48 | exit 1 49 | ;; 50 | esac 51 | exit 0 52 | #vim:ft=sh 53 | -------------------------------------------------------------------------------- /i3-wm-scripts/vimmappings: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Increase key speed via a rate change 4 | xset r rate 200 50 5 | # Map the caps lock key to super... 6 | setxkbmap -layout us -variant altgr-intl -option caps:ctrl_modifier 7 | #Map both shift Keys to capslock 8 | setxkbmap -option "shift:both_capslock" 9 | # If you don't want a us international keyboard, rather whatever keyboard 10 | # you set in your installation, comment out the above line and uncomment 11 | # the one below. 12 | 13 | #h 14 | xmodmap -e "keycode 43 = Left" 15 | #j 16 | xmodmap -e "keycode 44 = Down" 17 | #k 18 | xmodmap -e "keycode 45 = Up" 19 | #l 20 | xmodmap -e "keycode 46 = Right" 21 | #x 22 | xmodmap -e "keycode 53 = Delete" 23 | #d 24 | xmodmap -e "keycode 40 = BackSpace" 25 | #s 26 | xmodmap -e "keycode 39 = Delete" 27 | 28 | spare_modifier="Hyper_L" 29 | 30 | xmodmap -e "keycode 65 = $spare_modifier" 31 | # Map space to an unused keycode (to keep it around for xcape to 32 | # use). 33 | xmodmap -e "keycode any = space" 34 | 35 | # But when it is pressed only once, treat it as escape. 36 | killall xcape ; xcape -e 'Caps_Lock=Escape' 37 | 38 | xcape -e "$spare_modifier=space" 39 | 40 | xcape -e 'Shift_R=Escape' 41 | 42 | 43 | -------------------------------------------------------------------------------- /open: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : open.sh 6 | # @created : Tue 21 Jan 2020 02:54:56 PM MST 7 | # 8 | # @description : Simple command for opening files in a cli setting 9 | ###################################################################### 10 | OPENER="xdg-open" 11 | file=$(readlink -f "$1") 12 | dir=$(dirname "$file") 13 | base="${file%.*}" 14 | 15 | # define a custom 'open' command 16 | # This command is called when current file is not a directory. You may want to 17 | # use either file extensions and/or mime types here. Below uses an editor for 18 | # text files and a file opener for the rest. 19 | case $base in 20 | *\.blend) 21 | blender "$file" 22 | ;; 23 | *\.xopp) 24 | xournalpp "$file" 25 | ;; 26 | esac 27 | 28 | case $(file --mime-type "$*" -b) in 29 | # follow symlinks 30 | inode/symlink) $0 "$(readlink "$*")" && exit;; 31 | # open text files with vim 32 | text/*) ${EDITOR:-vi} "$*";; 33 | *) for f in "$@"; do setsid "${OPENER}" "${f}" > /dev/null 2> /dev/null & done;; 34 | esac 35 | # vim: set tw=78 ts=2 et sw=2 sr: 36 | -------------------------------------------------------------------------------- /dmenu/stars: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : stars.sh 6 | # @created : Mon 21 Dec 2020 02:18:19 PM 7 | # 8 | # @description : script that uses dmenu to open stared github projects if none 9 | # are selected the users own repos are searched 10 | ###################################################################### 11 | 12 | # TODO: Add the ability to clone the repo instead of opening in browser 13 | # If this is used then fzf is probably the better choice since it would 14 | # be called from the commandline. 15 | LAUNCER="dmenu -l 10 -p" 16 | LAUNCER="emenu -p" 17 | # your github username here 18 | USER="gavinok" 19 | select_repo() { 20 | curl -s "$1" | awk '/full_name/ {print $2}' | sed 's/[",]//g' | emenu -p 'Select Repo:' 21 | } 22 | 23 | PROJECT=$(select_repo "https://api.github.com/users/$USER/starred") 24 | [ -z "$PROJECT" ] && PROJECT=$(select_repo "https://api.github.com/users/$USER/repos?per_page=1000") 25 | [ -z "$PROJECT" ] && exit 1 26 | $BROWSER "https://github.com/$PROJECT" 27 | 28 | # vim: set tw=78 ts=2 et sw=2 sr: 29 | -------------------------------------------------------------------------------- /i3-wm-scripts/ddspawn: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script simplifies dropdown windows in i3. 4 | # Shows/hides a scratchpad of a given name, if it doesn't exist, creates it. 5 | # Usage: 6 | # argument 1: script to run in dropdown window 7 | # all other args are interpreted as options for your terminal 8 | # My usage: 9 | # ddpawn 10 | # bindsym $mod+u exec --no-startup-id ddspawn tmuxdd 11 | # Will hide/show window running the `tmuxdd` script when I press mod+u in i3 12 | # bindsym $mod+a exec --no-startup-id ddspawn dropdowncalc -f mono:pixelsize=24 13 | # Similar to above but with `dropdowncalc` and the other args are interpretated as for my terminal emulator (to increase font) 14 | 15 | 16 | [ -z "$1" ] && exit 17 | 18 | if xwininfo -tree -root | grep "(\"$1\" "; 19 | then 20 | echo "Window detected." 21 | else 22 | echo "Window not detected... spawning." 23 | i3 "exec --no-startup-id $TERMINAL -n $1 $(echo "$@" | cut -d ' ' -f2-) -e $1" && i3 "[instance=\"$1\"] scratchpad show; [instance=\"$1\"] move position center" 24 | sleep .25 # This sleep is my laziness, will fix later (needed for immediate appearance after spawn). 25 | fi 26 | i3 "[instance=\"$1\"] scratchpad show; [instance=\"$1\"] move position center" 27 | -------------------------------------------------------------------------------- /chem.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : chem.sh 6 | # @created : Thu 01 Oct 2020 07:09:09 PM 7 | # 8 | # @description : A script that utilizes fzf, groff, and recutils 9 | # To get information on a element in the periodic table. 10 | ###################################################################### 11 | 12 | fmt="A:box \"\fB{{Symbol}}\fP\" \"{{Name}}\" \"{{AtomicMass}}\" \"{{ElectronConfiguration}}\" wid 3 ht 4 13 | B:box invis \"{{AtomicNumber}}\" at (A.w.x + 0.5, A.e.y) 14 | C:box \"{{OxidationStates}}\" invis at ((A.e.x - 0.5), (A.n.y - 0.3))" 15 | 16 | # Replace with where ever you placed the included chem.rec file 17 | CHEMREC=$HOME/chem.rec 18 | 19 | SYMBOL=$(recsel -C "$CHEMREC" -P "Symbol,Name" | fzf --preview \ 20 | "recsel -e ' ( Symbol = \"{}\" ) || ( Name = \"{}\" ) ' $CHEMREC") 21 | 22 | format(){ 23 | echo .PS 24 | recsel -e " ( Symbol = '$SYMBOL' ) || ( Name = '$SYMBOL' ) " "$CHEMREC" | recfmt "$fmt" 25 | printf '\n.PE' 26 | } 27 | 28 | 29 | format | pic -Tascii | nroff | sed -e '/^$/d' 30 | # vim: set tw=78 ts=2 et sw=2 sr: 31 | -------------------------------------------------------------------------------- /tools/vim-anywhere.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | winid=$(xprop -root _NET_ACTIVE_WINDOW | sed 's/.*[[:space:]]//') 3 | TEMPFILE=/tmp/VimFloat 4 | while getopts ":c" o; do case "$o" in 5 | c) clip="1" ;; #output to clip 6 | *) printf "Invalid option: -%s\\n" "$o" && exit ;; 7 | esac done 8 | # Extract the output into variables 9 | geom=$(xdotool getwindowgeometry "$(xdotool getactivewindow)" ) 10 | local=$(echo "$geom" | awk NR==2 | cut -d: -f 2 | cut -d\( -f 1) 11 | dimentions=$(echo "$geom" | awk NR==3 | cut -d: -f 2 | cut -d\( -f 1 | cut -d, -f1) 12 | x=$(echo "$local" | cut -d, -f1); 13 | y=$(echo "$local" | cut -d, -f2); 14 | w=$(echo "$dimentions" | cut -dx -f1) 15 | h=$(echo "$dimentions" | cut -dx -f2) 16 | > $TEMPFILE 17 | st -t 'vim-anywhere' -n 'popup' -e "$EDITOR" -c 'startinsert' $TEMPFILE 18 | xsel -i -b < $TEMPFILE 19 | if [ -z $clip ] ;then 20 | text=$(xsel -o) 21 | layout=$(setxkbmap -query | awk '/^layout:/{ print $2 }') 22 | setxkbmap -layout us 23 | #move mouse to center of window 24 | xdotool mousemove $((x + w/2)) $((y + h/2)) 25 | xdotool type --clearmodifiers "$text" 26 | setxkbmap -layout "$layout" 27 | #uses my remaps script to remap capslock back to ctrl and escape 28 | remaps 29 | fi 30 | 31 | -------------------------------------------------------------------------------- /tools/vipe: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # vipe(1) - Pipe in and out of $EDITOR 5 | # 6 | # (c) 2014 Julian Gruber . 7 | # MIT licensed. 8 | # 9 | # Example: 10 | # 11 | # $ echo foo | vipe | gist 12 | # $ vipe | gist 13 | # 14 | # This is a lightweight bash only version. For the original impementation in 15 | # python, check https://github.com/madx/moreutils/blob/master/vipe 16 | # 17 | # This is an adaptation of the original bash implementation found here 18 | # https://github.com/juliangruber/vipe/blob/master/vipe.sh 19 | # 20 | 21 | # version 22 | 23 | VERSION="0.1.0" 24 | 25 | # usage 26 | 27 | if [ ${1} ]; then 28 | case "${1}" in 29 | "-h") 30 | echo "usage: vipe [-hV]" 31 | exit 0 ;; 32 | "-V") 33 | echo "$VERSION" 34 | exit 0 ;; 35 | *) 36 | echo "unknown option: \"${1}\"" 37 | echo "usage: vipe [-hV]" 38 | exit 1 39 | esac 40 | fi 41 | 42 | # temp file 43 | 44 | t=/tmp/vipe.$$.txt 45 | touch $t 46 | 47 | # read from stdin 48 | 49 | if [ ! -t 0 ]; then 50 | cat > $t 51 | fi 52 | 53 | # spawn editor with stdio connected 54 | 55 | ${EDITOR} $t < /dev/tty > /dev/tty || exit $? 56 | 57 | # write to stdout 58 | 59 | cat $t 60 | 61 | # cleanup 62 | 63 | rm $t 64 | 65 | -------------------------------------------------------------------------------- /tools/yt2rss.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | clip() { 4 | echo "${1}" 5 | command -v xsel >/dev/null && echo "${1}" | xsel -i 6 | command -v xclip >/dev/null && echo "${1}" | xclip -i 7 | } 8 | 9 | # The channel ID prefix URL for RSS: 10 | channelprefix='https://www.youtube.com/feeds/videos.xml?channel_id=' 11 | # The username prefix URL for RSS: 12 | userprefix='https://www.youtube.com/feeds/videos.xml?user=' 13 | # The playlist prefix URL for RSS: 14 | playlistprefix='https://www.youtube.com/feeds/videos.xml?playlist_id=' 15 | if [ $(echo "$*" | grep 'https://www.youtube.com/user/') ]; then 16 | user=$(echo "$*" | cut -d/ -f5) 17 | rssfeed="$userprefix$user" 18 | clip "${rssfeed}" 19 | fi 20 | if [ $(echo "$*" | grep 'https://www.youtube.com/channel/') ]; then 21 | id=$(echo "${*}" | cut -d/ -f5) 22 | rssfeed="$channelprefix$id" 23 | clip "${rssfeed}" 24 | fi 25 | if [ $(echo "${*}" | grep 'https://www.youtube.com/watch') ]; then 26 | id=$(echo "${*}" | cut -d= -f3) 27 | rssfeed="$playlistprefix$id" 28 | clip "${rssfeed}" 29 | fi 30 | # https://www.youtube.com/channel/UC2eYFnH61tmytImy1mTYvhA 31 | # https://www.youtube.com/user/ChrisWereDigital 32 | # https://www.youtube.com/watch?v=UWpf4ZSAHBo&list=PL-p5XmQHB_JRlxgcaj-WxkAylXFuE0gyk 33 | # curl "$*" 34 | -------------------------------------------------------------------------------- /tools/dock_monitor: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # intern=eDP-1 3 | intern=eDP1 4 | monitors=$(xrandr | awk "/ connected/ { if (\$1 != \"$intern\") print \$1;}") 5 | left=$(echo $monitors | cut -d' ' -f1) 6 | right=$(echo $monitors | cut -d' ' -f2) 7 | # 'DP2 8 | # DP-2 9 | # HDMI2' 10 | echo $left 11 | _mappings() { 12 | remaps 2>/dev/null & 13 | } 14 | 15 | _highdpi() { 16 | xrandr --dpi 220 17 | } 18 | 19 | _if_monitor_connected() { 20 | if [ "$(echo ${monitors} | wc -l)" = "2" ]; then 21 | echo path 1 22 | xrandr --output "$left" --auto 23 | xrandr --output "$right" --auto 24 | 25 | xrandr --output "$intern" --primary --auto --output "$left" --left-of "$intern" --auto --output "$right" --right-of "$intern" --auto 26 | elif [ "$(echo ${monitors} | wc -l)" = "1" ]; then 27 | echo left is $left and internal is $intern 28 | xrandr --output "$intern" --primary --auto --output "$left" --auto --left-of "$intern" 29 | fi 30 | } 31 | 32 | _if_disconnected() { 33 | xrandr | grep "$monitor disconnected" && 34 | xrandr --output "$monitor" --off --output "$intern" --auto 35 | } 36 | _if_monitor_connected 37 | 38 | _if_disconnected 39 | 40 | device=$(uname -n) 41 | [ "$device" = "sp4" ] && _highdpi 42 | setbg & 43 | _mappings 44 | # vim:ft=sh 45 | -------------------------------------------------------------------------------- /i3-wm-scripts/floatingterm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #!/bin/sh 4 | 5 | # This script simplifies dropdown windows in i3. 6 | # Shows/hides a scratchpad of a given name, if it doesn't exist, creates it. 7 | # Usage: 8 | # argument name: script to run in dropdown window 9 | # all other args are interpreted as options for your terminal 10 | # My usage: 11 | # ddpawn 12 | # bindsym $mod+u exec --no-startup-id ddspawn tmuxdd 13 | # Will hide/show window running the `tmuxdd` script when I press mod+u in i3 14 | # bindsym $mod+a exec --no-startup-id ddspawn dropdowncalc -f mono:pixelsize=24 15 | # Similar to above but with `dropdowncalc` and the other args are interpretated as for my terminal emulator (to increase font) 16 | 17 | 18 | name=$RANDOM 19 | 20 | [ -z "$name" ] && exit 21 | 22 | if xwininfo -tree -root | grep "(\"$name\" "; 23 | then 24 | echo "Window detected." 25 | else 26 | echo "Window not detected... spawning." 27 | i3 "[instance=\"$name\"] floating enable; [instance=\"$name\"] move position center" && i3 "exec --no-startup-id $TERMINAL -n $name" 28 | #move position 29 | sleep .25 # This sleep is my laziness, will fix later (needed for immediate appearance after spawn). 30 | fi 31 | i3 "[instance=\"$name\"] floating enable; [instance=\"$name\"] move position center" 32 | 33 | -------------------------------------------------------------------------------- /tools/cast: -------------------------------------------------------------------------------- 1 | #!/usr/bin/sh 2 | # uses castthis for different formats 3 | [ -z "$1" ] && { exit; } 4 | 5 | # TODO: add subtitile support 6 | 7 | pkill node 8 | # pgrep will only find *node* and wont find *castnow* 9 | # ps aux | castnow | grep -v grep && killall node 10 | 11 | # This has moved from castnow to catt 12 | # https://github.com/skorokithakis/catt 13 | 14 | castnow_yt() { 15 | tmpdir=$(mktemp -d) 16 | file_to_cast=${tmpdir}/cast 17 | program_=$(command -v castnow) 18 | if [ "${program_}" = "" ]; then 19 | notify-send "castnow can't be found..." 20 | exit 1 21 | fi 22 | 23 | # kill any running instance of castnow 24 | pkill -f "${program_}" 25 | # setsid castnow ./"$1" --quiet >/dev/null 2>&1 & 26 | youtube-dl -qo - "$1" > "${file_to_cast}" & 27 | ytdl_pid=$! 28 | 29 | tail -F "${file_to_cast}" | ${program_} - 30 | # cleanup remaining background process and file on disk 31 | kill ${ytdl_pid} 32 | rm -rf "${tmpdir}" 33 | } 34 | 35 | case "$1" in 36 | # *mkv | *avi) 37 | # setsid catt cast "$1" >/dev/null 2>&1 & 38 | # ;; 39 | *youtube.com* | *youtu.be*) #limit the video quality 40 | # castnow_yt $1 41 | setsid catt cast "$1" & 42 | ;; 43 | *) 44 | setsid catt cast ./"$1" >/dev/null 2>&1 & 45 | ;; 46 | esac 47 | notify-send " casting video" 48 | -------------------------------------------------------------------------------- /tools/cl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A general backlight interface 4 | notifybrightness() { 5 | # BRIGHTNESS=$(bright) 6 | # dunstify -t 500 -r 325 "Light: $BRIGHTNESS" 7 | # xsetroot -name "Light[$BRIGHTNESS]" 8 | statwe -b 9 | } 10 | backlight() { 11 | file=/sys/class/backlight/intel_backlight/brightness 12 | current=$(cat $file) 13 | max=$(cat /sys/class/backlight/intel_backlight/max_brightness) 14 | new="$current" 15 | if [ "$1" = "-inc" ] 16 | then 17 | new=$(echo "current + (1000 * $2)" | bc) 18 | fi 19 | if [ "$1" = "-dec" ] 20 | then 21 | new=$(echo "current - (1000 * $2)" | bc) 22 | fi 23 | echo "$new" | tee "$file" 24 | } 25 | 26 | [ -z "$2" ] && num="2" || num="$2" 27 | 28 | case "$1" in 29 | u*) 30 | # backlight -inc "$num" 31 | xbacklight -inc "$num" 32 | notifybrightness 33 | ;; #change the default audio sync 34 | d*) 35 | # backlight -dec "$num" 36 | xbacklight -dec "$num" 37 | notifybrightness 38 | ;; #change the default audio sync 39 | *) cat < /dev/null | sed 's/.*file:\/\/\(.*S\)].*/\1/' | msort -d | mseq -S 2> /dev/null && mscan 13 | 14 | # Taken from mblaze contrib 15 | #!/bin/sh 16 | 17 | MBLAZE=${MBLAZE:-$HOME/.mblaze} 18 | engine=$(mhdr -h search-engine "$MBLAZE/profile") 19 | 20 | while getopts nmx opt; do 21 | case $opt in 22 | n) 23 | engine=notmuch 24 | ;; 25 | m) 26 | engine=mu 27 | ;; 28 | x) 29 | engine=mairix 30 | ;; 31 | '?') 32 | printf "Usage: %s: [-n | -m | -x] query\n" "$0" 1>&2 33 | exit 1 34 | ;; 35 | esac 36 | done 37 | shift $(($OPTIND - 1)) 38 | / 39 | [ -z "$engine" ] && engine=mu 40 | 41 | case $engine in 42 | notmuch) 43 | exec notmuch search --output=files "$@" | msort -d | mseq -S 44 | ;; 45 | mu) 46 | exec mu find --fields l "$@" | msort -d | mseq -S && mscan 47 | ;; 48 | mairix) 49 | if [ "$#" -eq 0 ]; then 50 | printf "Usage: %s -x query\n" "$0" 1>&2 51 | exit 1 52 | fi 53 | exec mairix -r "$@" | msort -d | mseq -S 54 | ;; 55 | *) 56 | echo "Unsupported search engine: $engine" 57 | exit 1 58 | ;; 59 | esac -------------------------------------------------------------------------------- /tools/remaps: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Increase key speed via a rate change 4 | # Map the caps lock key to super... 5 | # setxkbmap -layout us -variant altgr-intl -option caps:ctrl_modifier 6 | 7 | # setxkbmap -layout us -variant altgr-intl -option caps:escape 8 | # setxkbmap -layout us -variant altgr-intl -option caps:escape 9 | # If you don't want a us international keyboard, rather whatever keyboard 10 | # you set in your installation, comment out the above line and uncomment 11 | # the one below. 12 | # xmodmap -e "keycode 66 = Control_L" 13 | ## xmodmap -e "keycode 66 = Escape" 14 | # xmodmap -e "keycode 108 = Alt_L" 15 | # xmodmap -e "keycode 168 = space" 16 | ## xmodmap -e "keycode 108 = Super_R" 17 | ## xmodmap -e "keysym 135 = Super_L" 18 | # xmodmap -e "keysym Print = Super_R" # map printscreen to super to fix issues with x390's annoying layout 19 | # But when it is pressed only once, treat it as escape. 20 | # killall xcape ; xcape -t 250 -e 'Caps_Lock=Escape' 21 | # killall xcape ; xcape -t 250 -e 'Control_L=Escape' 22 | # xcape -t 330 -e "Hyper_L=space" 23 | xsetwacom --set "Wacom Intuos BT S Pad pad" Button 1 "key PgDn" 24 | xsetwacom --set "Wacom Intuos BT S Pad pad" Button 2 "key PgUp" 25 | # xsetwacom --set "Wacom Intuos BT S Pad pad" Button 1 "key +super z -super" 26 | 27 | sudo killall kmonad 28 | sudo kmonad ~/.config/kmonad.kbd 29 | sleep 6 && xset r rate 200 50 30 | -------------------------------------------------------------------------------- /dwm/autostart.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dock_monitor 3 | scheme=$(cat ~/.config/colorschemes/current) 4 | # if [ "$scheme" = "dark" ];then 5 | picom & 6 | flashfocus & 7 | # fi 8 | # unclutter & 9 | clipmenud & 10 | # sleep 2 && wl-paste --watch cliphist store & 11 | # DAY:NIGHT LAT:LON 12 | redshift -t 6500:2500 -l 60:-135 & 13 | # pulsemixer --set-volume 50 & 14 | xbacklight -set 30 & 15 | autosuspend.sh & 16 | # sudo rkill block bluetooth & 17 | dunst & 18 | # echo 'auto' | sudo tee '/sys/bus/usb/devices/4-1/power/control' & 19 | # disable Ethernet 20 | # sudo ip link set enp0s25 down & 21 | # sudo powertop --auto-tune & 22 | # sudo wpa_supplicant -B -i wls1 -c /etc/wpa_supplicant.conf && sudo dhclient wls1 && notify-send "successfully connected" 23 | if [ -e /usr/lib/kdeconnectd ]; then 24 | setsid /usr/lib/kdeconnectd & 25 | fi 26 | 27 | statwe & 28 | blueman-applet & 29 | dbus-update-activation-environment & 30 | # startlemon.sh | lemonbar -f "monospace" -f "Symbols Nerd Font-10" & 31 | # xbindkeys & 32 | remaps 2>/dev/null & 33 | # setsid syncthing --no-browser & 34 | device=$(uname -n) 35 | # xinput disable "Elan Touchpad" 36 | [ "$device" = "sp4" ] && exit 37 | # psave.sh & 38 | # covid19.sh & 39 | # remind -z -k'notify-send 🦄\ [REMINDER]:\ %s" &' "${DOTREMINDERS}" & 40 | # xinput set-prop 'Elan TrackPoint' 'Coordinate Transformation Matrix' \ 41 | # 9.0 0.0 0.0 0.0 9.0 0.0 0.0 0.0 1.0 42 | -------------------------------------------------------------------------------- /tools/wwb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : wwb.sh 6 | # @created : Tue 24 Nov 2020 12:32:43 PM 7 | # 8 | # @description : A simple implementation of wwb I made 9 | # @requires: 10 | # deroff 11 | # proselint 12 | # GNU diction 13 | # write-good 14 | ###################################################################### 15 | 16 | # TODO: format the output of the programs for easy parsing in vim 17 | 18 | file=$(readlink -f "$1") 19 | dir=$(dirname "$file") 20 | base="${file%.*}" 21 | cleanfile="$file.clean" 22 | 23 | CLEANLINTERCMD(){ 24 | sed -e 's/\.clean//' 25 | } 26 | 27 | cd "$dir" || exit 28 | 29 | # deroff comes from http://www.moria.de/~michael/deroff/ 30 | deroff "$file" | sed -e 's/^\..\+//' > "$cleanfile" 31 | 32 | grep -Hn "[−’]" "$cleanfile" | CLEANLINTERCMD 33 | writegood --parse "$cleanfile" | CLEANLINTERCMD 34 | proselint "$cleanfile" | CLEANLINTERCMD 35 | diction --suggest --beginner "$cleanfile" | CLEANLINTERCMD 36 | rm "$cleanfile" 37 | 38 | # vim: set tw=78 ts=2 et sw=2 sr: 39 | -------------------------------------------------------------------------------- /pkgls: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : test.sh 6 | # @created : Sat 11 Apr 2020 10:39:14 AM 7 | # 8 | # @description : sort by package size and print the selected package 9 | ###################################################################### 10 | 11 | func_ls() { 12 | # list all packages on local system sorted by their installed size using "expac" and "sort". 13 | # expac -H M -Q "%12m - \e[1m%n\e[0m %v" displays size, name, and version number 14 | # "sort -n -r" sorts list by number (with which every element begins). 15 | # ATTENTION: (i do not know why but) using quotes (" symbols) around $( comm ...) breaks expac 16 | expac -H M -Q "%12m - \e[1m%n\e[0m" $(yay -Qq | sort) | sort -n -r | fzf -i --multi --exact --no-sort --ansi --reverse --bind=right:half-page-down,left:half-page-up --margin=4%,1%,1%,1% --info=inline --no-unicode --preview ' 17 | echo -e "\e[1mInstalled package info: \e[0m" 18 | yay -Qi {4} --color always 19 | ' "$(if (($(tput cols) >= 125)); then echo "--preview-window=right:60%:wrap"; else echo "--preview-window=bottom:60%:wrap"; fi)" --header="Navigate with PageUp / PageDown. ESC to quit." --prompt='Enter string to filter list > ' | awk -F ' - ' '{print $2}' 20 | 21 | } 22 | func_ls 23 | 24 | # vim: set tw=78 ts=2 et sw=2 sr: 25 | -------------------------------------------------------------------------------- /tools/extract: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # A general, all-purpose extraction script. 3 | # 4 | # Default behavior: Extract archive into new directory 5 | # Behavior with `-c` option: Extract contents into current directory 6 | 7 | while getopts "hc" o; do case "${o}" in 8 | c) extracthere="True" ;; 9 | *) printf 'Options:\n -c: Extract archive into current directory rather than a new one.\n' && exit ;; 10 | esac done 11 | 12 | if [ -z "$extracthere" ]; then 13 | archive="$(readlink -f "$*")" && 14 | directory=${archive%.*} && 15 | mkdir -p "$directory" && 16 | cd "$directory" || exit 17 | else 18 | archive="$(readlink -f "$(echo "$*" | cut -d' ' -f2)")" 19 | fi 20 | 21 | [ "$archive" = "" ] && printf 'Give archive to extract as argument.\n' && exit 22 | 23 | if [ -f "$archive" ]; then 24 | case "$archive" in 25 | *.tar.bz2 | *.tar.xz | *.tbz2) tar xvjf "$archive" ;; 26 | *.tar.gz | *.tgz) tar xvzf "$archive" ;; 27 | *.lzma) unlzma "$archive" ;; 28 | *.bz2) bunzip2 "$archive" ;; 29 | *.rar) unrar x -ad "$archive" ;; 30 | *.gz) gunzip "$archive" ;; 31 | *.tar) tar xvf "$archive" ;; 32 | *.zip | *.jar | *.war) unzip "$archive" ;; 33 | *.Z) uncompress "$archive" ;; 34 | *.7z) 7z x "$archive" ;; 35 | *.xz) unxz "$archive" ;; 36 | *.exe) cabextract "$archive" ;; 37 | *.ace) unace x "$archive" ;; 38 | *) printf "extract: '%s' - unknown archive method\\n" "$archive" ;; 39 | esac 40 | else 41 | printf 'File "%s" not found.\n' "$archive" 42 | fi 43 | -------------------------------------------------------------------------------- /dwm/rotate_screen: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # touch "/tmp/rotate" 3 | if [ ! -f "/tmp/rotate" ];then 4 | touch "/tmp/rotate" 5 | echo 0 > "/tmp/rotate" 6 | else 7 | lastmod=$(stat --printf="%X\n" /tmp/rotate) 8 | timenow=$(date +%s) 9 | timelim=$(( lastmod + 1 )) 10 | echo $timelim 11 | echo $lastmod 12 | [ $timelim -gt $timenow ] && exit 13 | touch /tmp/rotate 14 | fi 15 | if grep 0 /tmp/rotate ; then 16 | xrandr --output LVDS1 --rotate inverted 17 | xsetwacom set "Wacom Serial Penabled 1FG Touchscreen Pen stylus" Rotate half 18 | xsetwacom set "Wacom Serial Penabled 1FG Touchscreen Finger touch" Rotate half 19 | xsetwacom set "Wacom Serial Penabled 1FG Touchscreen Pen eraser" Rotate half 20 | echo "1" >/tmp/rotate 21 | else 22 | xrandr --output LVDS1 --rotate normal 23 | xsetwacom set "Wacom Serial Penabled 1FG Touchscreen Pen stylus" Rotate none 24 | xsetwacom set "Wacom Serial Penabled 1FG Touchscreen Finger touch" Rotate none 25 | xsetwacom set "Wacom Serial Penabled 1FG Touchscreen Pen eraser" Rotate none 26 | echo "0" >/tmp/rotate 27 | fi 28 | #sideways 29 | # xrandr --output LVDS1 --rotate left 30 | # xsetwacom set "Wacom Serial Penabled 1FG Touchscreen Pen stylus" Rotate ccw 31 | # xsetwacom set "Wacom Serial Penabled 1FG Touchscreen Finger touch" Rotate ccw 32 | # xsetwacom set "Wacom Serial Penabled 1FG Touchscreen Pen eraser" Rotate ccw 33 | dock_monitor 34 | #vim:ft=sh 35 | -------------------------------------------------------------------------------- /videos/cleanaudio.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : cleanaudio.sh 6 | # @created : Wed 26 Aug 2020 11:03:44 AM 7 | # 8 | # @description : remove background hissing from audio 9 | # @requires : sox and ffmpeg 10 | ###################################################################### 11 | 12 | [ ! -f "$1" ] && exit 13 | OGVIDEOFILE="$1" 14 | 15 | # This Is Used For Removing Background Noise 16 | # generate it by finding a section of your video that 17 | # has *only* background noise. then remove it using ffmpeg 18 | # like so: 19 | # ffmpeg -i AUDIOFILE.mp3 -ss 00:00:18 -t 00:00:20 noisesample.wav 20 | # Then create the profile using this command: 21 | # sox noisesample.wav -n noiseprof noise_profile_file 22 | # This can be exported in your bashrc 23 | [ -f "$SOUNDPROFILE" ] || SOUNDPROFILE="$2" 24 | 25 | [ ! -f "$SOUNDPROFILE" ] && exit 26 | 27 | # Remove Audio From Video 28 | ffmpeg -i "$OGVIDEOFILE" -vn -ac 2 -ar 44100 -ab 320k -f mp3 AUDIOFILE.mp3 29 | 30 | # Remove Background Noise 31 | sox AUDIOFILE.mp3 fixedAUDIOFILE.mp3 noisered $SOUNDPROFILE 0.25 32 | 33 | # Join Audio And Video 34 | ffmpeg -i "$OGVIDEOFILE" -i fixedAUDIOFILE.mp3 -c:v copy -map 0:v:0 -map 1:a:0 "${OGVIDEOFILE}NEW.mp4" 35 | 36 | rm fixedAUDIOFILE.mp3 37 | 38 | notify-send "${OGVIDEOFILE}NEW.mp4 has been created" 39 | 40 | # vim: set tw=78 ts=2 et sw=2 sr: 41 | -------------------------------------------------------------------------------- /dmenu/dmenuumount: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # A dmenu prompt to unmount drives. 3 | # Provides you with mounted partitions, select one to unmount. 4 | # Drives mounted at /, /boot and /home will not be options to unmount. 5 | 6 | unmountusb() { 7 | [ -z "$drives" ] && exit 8 | chosen=$(echo "$drives" | dmenu -i -p "Unmount which drive?" | awk '{print $1}') 9 | [ -z "$chosen" ] && exit 10 | sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted." 11 | } 12 | 13 | unmountandroid() { \ 14 | chosen=$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?") 15 | [ -z "$chosen" ] && exit 16 | sudo -A umount -l "$chosen" && notify-send "🤖 Android unmounting" "$chosen unmounted." 17 | } 18 | 19 | asktype() { \ 20 | case "$(printf "USB\\nAndroid" | dmenu -i -p "Unmount a USB drive or Android device?")" in 21 | USB) unmountusb ;; 22 | Android) unmountandroid ;; 23 | esac 24 | } 25 | 26 | drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$2=="part"&&$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}') 27 | 28 | if ! grep simple-mtpfs /etc/mtab; then 29 | [ -z "$drives" ] && notify-send "No drives to unmount." && exit 30 | notify-send "Unmountable USB drive detected." 31 | unmountusb 32 | else 33 | if [ -z "$drives" ] 34 | then 35 | notify-send "Unmountable Android device detected." 36 | unmountandroid 37 | else 38 | notify-send "Unmountable USB drive(s) and Android device(s) detected." 39 | asktype 40 | fi 41 | fi 42 | -------------------------------------------------------------------------------- /tools/qrrecieve: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : qrrecieve.sh 6 | # @created : Sat 18 Jul 2020 10:56:00 PM 7 | # 8 | # @description : Send text or files from your phone to your computer using a 9 | # qr code 10 | ###################################################################### 11 | 12 | # Requires: 13 | # oneshot 14 | # curl or qrencode 15 | 16 | port=6967 17 | tmpdir="/tmp/qrrecieve" 18 | tmpqr="/tmp/QR.png" 19 | timeout="30s" 20 | 21 | add="http://$(ip ad | grep 'inet ' | awk 'NR > 1 {print $2}' | cut -d'/' -f1):$port" 22 | 23 | 24 | # TODO: finish optional google qrcode <19-07-20 Gavin Jaeger-Freeborn> 25 | _qrurl() 26 | { 27 | curl -sS "http://chart.apis.google.com/chart?chs=200x200&cht=qr&chld=H|0&chl=$1" -o "${tmpqr}" 28 | } 29 | 30 | _shout() 31 | { 32 | echo "$*" 33 | notify-send "$*" 34 | exit 1 35 | } 36 | 37 | uploadtype="--upload-input" 38 | [ "$1" = "-f" ] && uploadtype="--upload-file" 39 | [ "$1" = "-h" ] && _help 40 | 41 | if command -v qrencode >/dev/null ;then 42 | echo "${add}" | qrencode -s 10 -o "${tmpqr}" 43 | else 44 | _qrurl "${add}" 45 | fi 46 | 47 | # Check if port is in use 48 | lsof -i -P | grep ".*:$port.*" && _shout "port $port is in use" 49 | 50 | xdg-open "${tmpqr}" & 51 | 52 | 53 | oneshot --timeout "$timeout" --port $port $uploadtype 54 | 55 | # vim: set tw=78 ts=2 et sw=2 sr: 56 | -------------------------------------------------------------------------------- /i3-wm-scripts/nextfind: -------------------------------------------------------------------------------- 1 | #!/bin/python3 2 | 3 | import os 4 | import re 5 | import subprocess 6 | import sys 7 | 8 | import common 9 | 10 | def iter_plus(it, extra): 11 | yield from it 12 | yield extra 13 | def joinlines(L): 14 | return "\n".join(iter_plus(L, "")) 15 | 16 | def select_window(windows, dmenu_args): 17 | """return (dmenu-output, list of IDs) for the selected option""" 18 | windows = sorted(windows.items(), key=lambda x: tuple(map(str.lower, x[0]))) 19 | options = [] 20 | for (wm_class, title), L in windows: 21 | mult = "" 22 | if len(L) > 1: 23 | mult = " x{}".format(len(L)) 24 | display = "({}{}) {}".format(wm_class, mult, title) 25 | options.append((display, L)) 26 | try: 27 | ret = subprocess.check_output(["dmenu"] + dmenu_args, input=joinlines(x for x, _ in options).encode("UTF-8")) 28 | except subprocess.CalledProcessError as e: 29 | sys.exit(e.returncode) 30 | ret = ret.decode("UTF-8").strip() 31 | selected = next(v for k, v in options if k == ret) 32 | return ret, selected 33 | 34 | def main(args): 35 | current, windows = common.get_named_windows() 36 | if not windows: 37 | return 38 | query, selected = select_window(windows, args) 39 | common.focus_window(common.cycle_selected(current, selected)) 40 | with open(os.path.dirname(__file__) + "/.query.tmp", "w") as f: 41 | f.write("^" + re.escape(query.partition(") ")[2]) + "$") 42 | 43 | if __name__ == "__main__": 44 | sys.exit(main(sys.argv[1:])) 45 | -------------------------------------------------------------------------------- /tools/refreshbrowser: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : test.sh 6 | # @created : Wed 25 Mar 2020 05:49:29 PM 7 | # 8 | # @description : simple xdotool script used to reload browsers 9 | ###################################################################### 10 | 11 | browserclass='google-chrome' 12 | 13 | #=== FUNCTION ====================================================== 14 | # NAME: moveto 15 | # DESCRIPTION: move to the center of the specified window id 16 | #===================================================================== 17 | moveto() { 18 | geom=$(xdotool getwindowgeometry "${1}") 19 | local=$(echo "${geom}" | awk NR==2 | cut -d: -f 2 | cut -d\( -f 1) 20 | dimentions=$(echo "${geom}" | awk NR==3 | cut -d: -f 2 | cut -d\( -f 1 | cut -d, -f1) 21 | x=$(echo "${local}" | cut -d, -f1) 22 | y=$(echo "${local}" | cut -d, -f2) 23 | w=$(echo "${dimentions}" | cut -dx -f1) 24 | h=$(echo "${dimentions}" | cut -dx -f2) 25 | 26 | xdotool mousemove $((x + w / 2)) $((y + h / 2)) 27 | } 28 | 29 | # Save the current window 30 | cwid=$(xdotool getwindowfocus) 31 | # Find the browser window 32 | twid=$(xdotool search --onlyvisible --class "${browserclass}") 33 | [ -z "${twid}" ] && notify-send 'failed to determine browser window' && exit 34 | [ -z "${cwid}" ] && notify-send 'failed to determine current window' && exit 35 | 36 | moveto "${twid}" 37 | 38 | xdotool key F5 39 | 40 | moveto "${cwid}" 41 | 42 | # vim: set tw=78 ts=2 et sw=2 sr: 43 | -------------------------------------------------------------------------------- /rec2org: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : rec2org.sh 6 | # @created : Wed 23 Sep 2020 11:19:30 AM 7 | # 8 | # @description : 9 | ###################################################################### 10 | 11 | ORGTEMPLATE="* {{State}} {{Name}} :{{Class}}: 12 | SCHEDULED: <{{Scheduled}}> 13 | DEADLINE: <{{Deadline}}> {{Desc}} 14 | 15 | " 16 | 17 | DATE=$(date) 18 | 19 | RECORGFILE="${HOME}/Documents/org/rec.org" 20 | 21 | RECFILE="${HOME}/schedule.rec" 22 | 23 | formatDates() 24 | { 25 | # recsel -s '' -e "Scheduled >> \"${DATE}\"|| Deadline >> \"${DATE}\" || State = 'TODO'" ${HOME}/schedule.rec | 26 | 27 | # Check that the file is properly formatted 28 | recfix --check "${RECFILE}" || exit 1 29 | 30 | # Process one line at a time. 31 | recsel "${RECFILE}" | 32 | while IFS=': ' read -r key val 33 | do 34 | # multi line 35 | if [ "$key" = '+' ];then 36 | printf "%s %s\n" "$key" "$val" 37 | continue 38 | fi 39 | 40 | # End of an entry 41 | [ -z "$key" ] && echo "" && continue 42 | 43 | # date 44 | if [ "$key" = 'Scheduled' ] || [ "$key" = 'Deadline' ] ; then 45 | val="$(date +'%Y-%m-%d %a %H:%M' --date "$val")" 46 | fi 47 | 48 | printf "%s: %s\n" "$key" "$val" 49 | done 50 | 51 | } 52 | 53 | formatDates | 54 | recfmt "$ORGTEMPLATE" | 55 | sed -E -e '/(DEADLINE: <>|SCHEDULED: <>)/d' -e 's/::$//g' > $RECORGFILE 56 | 57 | # vim: set tw=78 ts=2 et sw=2 sr: 58 | 59 | -------------------------------------------------------------------------------- /rec2tbl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : todotemp.sh 6 | # @created : Tue 22 Sep 2020 04:56:58 PM 7 | # 8 | # @description : 9 | ###################################################################### 10 | 11 | DATE=$(date) 12 | RECFILE='schedule.rec' 13 | STATEFMT='{{State = "TODO" ? "\m[R]\fB" & "TODO" & "\fR\m[]" : "\m[G]\fB" & State & "\fR\m[]" }}' 14 | 15 | formatDates() 16 | { 17 | # Process one line at a time. 18 | recsel -e "Scheduled >> \"$DATE\"|| Deadline >> \"$DATE\"" --sort 'Scheduled' ${RECFILE} | 19 | while IFS=': ' read -r key val 20 | do 21 | 22 | [ -z "$key" ] && echo "" && continue 23 | if [ "$key" = 'Scheduled' ] || [ "$key" = 'Deadline' ] ; then 24 | val="in $((($(date +%s --date "$val")-$(date +%s))/(3600*24))) days" 25 | fi 26 | printf "%s: %s\n" "$key" "$val" 27 | done 28 | } 29 | 30 | todos() { 31 | recsel -e "State = 'TODO' && (Scheduled == '' && Deadline == '' ) " ${RECFILE} 32 | } 33 | groffout(){ 34 | 35 | cat << EOF 36 | .defcolor R rgb 1 0 0 37 | .defcolor B rgb 0 0 1 38 | .defcolor G rgb 0 1 0 39 | .TS 40 | tab(;); 41 | c|c|c|c|c. 42 | \\fBStatus;Name;Class;Deadline;Scheduled\\fR 43 | _ 44 | EOF 45 | todos | recfmt "${STATEFMT};{{Name}};{{Class}};\m[R]{{Deadline}}\m[];\m[B]{{Scheduled}}\m[] 46 | " 47 | echo '_' 48 | formatDates | recfmt "${STATEFMT};{{Name}};{{Class}};\m[R]{{Deadline}}\m[];\m[B]{{Scheduled}}\m[] 49 | " 50 | cat << EOF 51 | .TE 52 | EOF 53 | 54 | } 55 | 56 | groffout | groff -ms -t -Tpdf | zathura - 57 | # vim: set tw=78 ts=2 et sw=2 sr: 58 | -------------------------------------------------------------------------------- /dmenu/dmenu_github: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # ----------------------------------------------------------------------------- 4 | # Info: 5 | # author: Miroslav Vidovic 6 | # file: github-repos.sh 7 | # created: 04.04.2017.-09:18:34 8 | # revision: --- 9 | # version: 1.0 10 | # ----------------------------------------------------------------------------- 11 | # Requirements: 12 | # rofi, git 13 | # Description: 14 | # Display all repositories connected with a GitHub user account in rofi and 15 | # clone the selected repository. 16 | # Usage: 17 | # github-repos.sh 18 | # ----------------------------------------------------------------------------- 19 | # Script: 20 | 21 | # GitHub username 22 | USER="gavinok" 23 | 24 | # GitHub user account URL 25 | URL="https://github.com/${USER}/" 26 | 27 | # Clone a repository into the current directory 28 | clone_repository(){ 29 | local repository=$1 30 | if [ -z "${repository}" ]; then 31 | echo "ERROR: You need to enter the name of the repository you wish to clone." 32 | else 33 | git clone "${URL}${repository}" 34 | fi 35 | } 36 | 37 | # Get all the repositories for the user with curl and GitHub API and filter only 38 | # the repository name from the output with sed substitution 39 | all_my_repositories_short_name(){ 40 | curl -s "https://api.github.com/users/${USER}/repos?per_page=1000" | grep -o 'git@[^"]*' |\ 41 | sed "s/git@github.com:${USER}\///g" 42 | } 43 | 44 | # Rofi dmenu 45 | rofi_dmenu(){ 46 | dmenu -p "Select a repository >" -l 10 47 | } 48 | 49 | main(){ 50 | repository=$(all_my_repositories_short_name | rofi_dmenu ) 51 | clone_repository "${repository}" 52 | } 53 | 54 | main 55 | 56 | exit 0 57 | -------------------------------------------------------------------------------- /fzf/pkgrm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Lists and removes packages, optionally sorts by size. 3 | # depends on pacman 4 | # credit to original creator: 5 | # Daniel Gray 6 | # https://github.com/DanielFGray/fzf-scripts 7 | declare by_size 8 | 9 | has() { 10 | local verbose=0 11 | if [[ $1 = '-v' ]]; then 12 | verbose=1 13 | shift 14 | fi 15 | for c; do c="${c%% *}" 16 | if ! command -v "$c" &> /dev/null; then 17 | (( "$verbose" > 0 )) && err "$c not found" 18 | return 1 19 | fi 20 | done 21 | } 22 | 23 | err() { 24 | printf "\e[31m%s\e[0m\n" "$*" >&2 25 | } 26 | 27 | die() { 28 | (( $# > 0 )) && err "$*" 29 | exit 1 30 | } 31 | 32 | select_from() { 33 | local o c cmd OPTARG OPTIND 34 | cmd='command -v' 35 | while getopts 'c:' o; do 36 | case "$o" in 37 | c) cmd="$OPTARG" ;; 38 | esac 39 | done 40 | shift "$((OPTIND-1))" 41 | for c; do 42 | if $cmd "${c%% *}" &> /dev/null; then 43 | echo "$c" 44 | return 0 45 | fi 46 | done 47 | return 1 48 | } 49 | 50 | has -v fzf expac || die 51 | 52 | fzf() { 53 | command fzf -e --multi --no-hscroll --inline-info --cycle --bind='Ctrl-a:toggle-all' "$@" 54 | } 55 | 56 | case $1 in 57 | -s|--size) by_size=1; shift; 58 | esac 59 | 60 | if (( $# > 0 )); then 61 | sudo pacman -Rcusn "$@" 62 | exit 63 | fi 64 | 65 | preview=$(select_from pacaur pacman) 66 | 67 | if (( by_size )); then 68 | mapfile -t pkgs < <(expac -H M '%m\t%n' | sort -hr | fzf +s --preview="$preview --color=always -Si {3}" -q '!^lib ' | cut -f2) 69 | else 70 | mapfile -t pkgs < <(expac '%n' | fzf +s --preview="$preview --color=always -Si {1}" -q '!^lib ' | cut -d' ' -f1) 71 | fi 72 | 73 | (( ${#pkgs[@]} > 0 )) && sudo pacman -Rcusn "${pkgs[@]}" 74 | -------------------------------------------------------------------------------- /dmenu/menu_connection_manager.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # initial configuration 4 | # sudo pacman --noconfirm -S bluez-utils pulseaudio-bluetooth pulseaudio-alsa blueman 5 | # sudo ln -vsf ${PWD}/etc/bluetooth/main.conf /etc/bluetooth/main.conf 6 | # sudo systemctl start bluetooth.service 7 | # sudo systemctl enable bluetooth.service 8 | 9 | # Requires: 10 | # blueman 11 | # bluez-utils 12 | # networkmanager_dmenu (https://github.com/firecat53/networkmanager-dmenu) 13 | # btmenu (https://github.com/cdown/btmenu) 14 | 15 | [ "$(cat /sys/class/net/w*/operstate)" = 'down' ] && wifiicon="📡" 16 | [ -z "${wifiicon+var}" ] && wifiicon=$(grep "^\s*w" /proc/net/wireless | awk '{ print "📶", int($3 * 100 / 70) "%" }') 17 | # WIFI=$(printf "%s " "$wifiicon" && nmcli connection show --active | sed '1d' | awk '{print $1}') 18 | 19 | WIFI=$(printf "%s %s" "${wifiicon}" "$(cat /sys/class/net/w*/operstate | sed "s/down/❎/;s/up/🌐/")") 20 | 21 | if [ -n "${WIFI}" ]; then 22 | choice=$(printf 'Bluetooth\nNetwork' | dmenu -i -p "${WIFI}") 23 | else 24 | choice=$(printf 'Bluetooth\nNetwork' | dmenu -i -p 'Connect:') 25 | fi 26 | 27 | if [ "${choice}" = "Bluetooth" ]; then 28 | sudo rkill unblock bluetooth 29 | 30 | # start blueman-applet if needed 31 | blueman-applet & 32 | # [ -z "$(pgrep blueman)" ] && blueman-applet & 33 | 34 | choice2=$(printf 'Connect\nNew\nManage\nDisable' | dmenu -i -p 'Bluetooth:') 35 | [ "${choice2}" = 'Connect' ] && btmenu 36 | [ "${choice2}" = 'New' ] && $TERMINAL bluetoothctl 37 | [ "${choice2}" = 'Manage' ] && $TERMINAL bluetoothctl 38 | [ "${choice2}" = 'Disable' ] && sudo rkill block bluetooth 39 | 40 | # since bluman-applet is nolonger needed to maintain connections 41 | fi 42 | if [ "${choice}" = "Network" ]; then 43 | networkmanager_dmenu 44 | fi 45 | #vim:ft=sh 46 | -------------------------------------------------------------------------------- /tools/windowshot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #=============================================================================== 3 | # FILE: windowshot.sh 4 | # 5 | # DESCRIPTION: Takes a screanshot using imagemagic and xprop 6 | # 7 | # AUTHOR: Gavin Jaeger-Freeborn gavinfreeborn@gmail.com 8 | # CREATED: Thu 28 Nov 2019 12:28:36 PM MST 9 | # VERSION: 1.0 10 | #=============================================================================== 11 | 12 | # This is bound to Shift+PrintScreen by default, requires maim. It lets you 13 | # choose the kind of screenshot to take, including copying the image or even 14 | # highlighting an area to copy. scrotcucks on suicidewatch right now. 15 | 16 | print_date() { 17 | date '+%F_%T' | sed -e 's/:/-/g' 18 | } 19 | 20 | SCREENSHOTDIR="${HOME}/Pictures/ScreenShots" 21 | SCREENSHOTNAME="${SCREENSHOTDIR}/$(print_date).png" 22 | 23 | note() { 24 | notify-send "screenshot name ${SCREENSHOTNAME}" 25 | } 26 | 27 | mkdir -p "${SCREENSHOTDIR}" 28 | 29 | _end() 30 | { 31 | note 32 | xdg-open "${SCREENSHOTNAME}" 33 | echo "${SCREENSHOTNAME}" 34 | exit 0 35 | } 36 | 37 | region() { 38 | killall unclutter 39 | import "${SCREENSHOTNAME}" 40 | setsid unclutter & 41 | _end 42 | } 43 | window() 44 | { 45 | import -window "$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')" "${SCREENSHOTNAME}" 46 | _end 47 | } 48 | root() 49 | { 50 | import -window root "${SCREENSHOTNAME}" 51 | _end 52 | } 53 | 54 | # Default Prompt For Selection 55 | prompter(){ 56 | case "$(printf 'a selected area\ncurrent window\nfull screen' | dmenu -l 6 -i -p 'Screenshot which area?')" in 57 | "a selected area") region ;; 58 | "current window") window ;; 59 | "full screen") root ;; 60 | *) exit ;; 61 | esac 62 | _end 63 | } 64 | 65 | while getopts cwr: o; do 66 | case "$o" in 67 | c) region;; 68 | w) window ;; 69 | r) root ;; 70 | \?) printf 'Invalid option: -%s\n' "${o}" && exit ;; 71 | esac 72 | done 73 | prompter 74 | -------------------------------------------------------------------------------- /i3-wm-scripts/i3-exec: -------------------------------------------------------------------------------- 1 | #!/bin/sh -ue 2 | # i3-exec COMMAND [ARG].. 3 | # 4 | # Tell i3 to start a command. The environment and other process state is inherited from i3, not i3-exec. 5 | # 6 | # The command is *not* a shell command, and thus redirections, globs, or other shell features will not work. If you want that, run "i3-msg exec". If you want your head to explode instead, run "i3-exec sh -c 'command'". 7 | # 8 | # Options: 9 | # --startup-id command uses $DESKTOP_STARTUP_ID 10 | 11 | fatal() { 12 | printf %s\\n "$(basename "$0"): $2" >&2 13 | exit $1 14 | } 15 | 16 | startup_id=--no-startup-id 17 | handle_option() { 18 | case "$1" in 19 | startup-id) [ $# = 1 ] || fatal 64 "unexpected --$1 value" 20 | startup_id= ;; 21 | no-startup-id) [ $# = 1 ] || fatal 64 "unexpected --$1 value" 22 | startup_id=--no-startup-id ;; 23 | *) fatal 64 "unknown option: $1" ;; 24 | esac 25 | } 26 | while [ $# -gt 0 ]; do 27 | case "$1" in 28 | --) 29 | shift 30 | break;; 31 | --*=*) 32 | x="${1#--}" 33 | handle_option "${x%%=*}" "${x#*=}" 34 | shift;; 35 | --*) 36 | handle_option "${1#--}" 37 | shift;; 38 | -?*) 39 | if [ ${#1} = 2 ]; then 40 | handle_option "${1#-}" 41 | else 42 | v="${1#??}" 43 | x="${1%"$v"}" 44 | handle_option "${x#-}" "$v" 45 | fi 46 | shift;; 47 | *) 48 | break;; 49 | esac 50 | done 51 | 52 | if [ $# = 0 ]; then 53 | fatal 64 'missing command' 54 | fi 55 | 56 | i3_exec_quote() { 57 | # for sh, wrap in single quotes with escaped existing single quote 58 | # for i3, escape double quotes 59 | printf %s "$1"x | sed "s/'/'\\\\''/g; 1s/^/'/; \$s/x\$/'/; s/\"/\\\\\"/g" 60 | } 61 | 62 | cmd=exec 63 | for arg; do 64 | cmd="$cmd $(i3_exec_quote "$arg")" 65 | done 66 | 67 | exec i3-msg -q "exec $startup_id \"cd $(i3_exec_quote "$PWD") && $cmd\"" 68 | -------------------------------------------------------------------------------- /surf/surf_linkselect.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env dash 2 | # 3 | # surf_linkselect.sh: 4 | # Usage: 5 | # curl somesite.com | surf_linkselect [SURFWINDOWID] [PROMPT] 6 | # 7 | # Description: 8 | # Given an HTML body as STDIN, extracts links via xmllint & provides list 9 | # to dmenu with each link paired with its associated content. Selected 10 | # link is then normalized based on the passed surf window's URI and the 11 | # result is printed to STDOUT. 12 | # 13 | # Dependencies: 14 | # xmllint, awk, dmenu, dash 15 | 16 | dump_links_with_titles() { 17 | awk '{ 18 | input = $0; 19 | 20 | $0 = input; 21 | gsub("<[^>]*>", ""); 22 | gsub(/[ ]+/, " "); 23 | $1 = $1; 24 | title = ($0 == "" ? "None" : $0); 25 | 26 | $0 = input; 27 | match($0, /\<[ ]*[aA][^>]* [hH][rR][eE][fF]=["]([^"]+)["]/, linkextract); 28 | $0 = linkextract[1]; 29 | gsub("[ ]", "%20"); 30 | link = $0; 31 | 32 | print title ": " link; 33 | }' 34 | } 35 | 36 | link_normalize() { 37 | URI=$1 38 | # URI=$( echo "$1" | sed 's/^\/\//https:\/\//') 39 | # notify-send $URI; 40 | awk -v uri="$URI" '{ 41 | if ($0 ~ /^https?:\/\// || $0 ~ /^\/\/.+$/) { 42 | print $0; 43 | } else if ($0 ~/^#/) { 44 | gsub(/[#?][^#?]+/, "", uri); 45 | print uri $0; 46 | } else if ($0 ~/^\//) { 47 | split(uri, uri_parts, "/"); 48 | print uri_parts[3] $0; 49 | } else { 50 | gsub(/[#][^#]+/, "", uri); 51 | uri_parts_size = split(uri, uri_parts, "/"); 52 | delete uri_parts[uri_parts_size]; 53 | for (v in uri_parts) { 54 | uri_pagestripped = uri_pagestripped uri_parts[v] "/" 55 | } 56 | print uri_pagestripped $0; 57 | } 58 | }' 59 | } 60 | 61 | link_select() { 62 | SURF_WINDOW=$1 63 | DMENU_PROMPT=$2 64 | tr -d '\n\r' | 65 | xmllint --html --xpath "//a" - | 66 | dump_links_with_titles | 67 | sort | 68 | uniq | 69 | dmenu -p "$DMENU_PROMPT" -l 10 -i -w "$SURF_WINDOW" | 70 | awk -F' ' '{print $NF}' | 71 | # sed 's/^\/\//https:\/\//' | 72 | link_normalize "$(xprop -id "$SURF_WINDOW" _SURF_URI | cut -d '"' -f 2)" 73 | } 74 | 75 | link_select "$1" "$2" 76 | -------------------------------------------------------------------------------- /dmenu/btmenu: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | _bluetoothctl() { 4 | LC_ALL=C timeout 30 bluetoothctl 5 | } 6 | 7 | mode=connect 8 | 9 | # Name -> MAC 10 | declare -A DEVICES 11 | while read -r _ mac name; do 12 | DEVICES["$name"]=$mac 13 | done < <(echo "devices" | _bluetoothctl | awk '$1 == "Device"') 14 | 15 | notify() { 16 | local msg 17 | local is_error 18 | 19 | msg=${1?BUG: no message} 20 | is_error=${2:-0} 21 | 22 | if command -v notify-send >/dev/null 2>&1; then 23 | notify-send "btmenu" "$msg" # TODO: escaping 24 | fi 25 | 26 | if (( is_error )); then 27 | printf 'ERROR: %s\n' "$msg" >&2 28 | else 29 | printf '%s\n' "$msg" 30 | fi 31 | } 32 | 33 | execute_mode() { 34 | local mode 35 | local name 36 | local mac 37 | local preposition 38 | local expected_to_connect 39 | local retries 40 | 41 | mode=${1?BUG: missing mode} 42 | retries=15 43 | 44 | case $mode in 45 | connect) 46 | preposition=to 47 | expected_to_connect=yes 48 | ;; 49 | disconnect) 50 | preposition=from 51 | expected_to_connect=no 52 | ;; 53 | esac 54 | 55 | if ! (( ${#DEVICES[@]} )); then 56 | notify "No devices found. Are they registered with D-Bus?" 1 57 | return 2 58 | fi 59 | 60 | name=$(printf '%s\n' "${!DEVICES[@]}" | dmenu -p "btmenu" "${dmenu_args[@]}") 61 | [[ $name ]] || return 62 | mac=${DEVICES["$name"]} 63 | 64 | notify "Attempting to $mode $preposition $name" 65 | 66 | while (( retries-- )); do 67 | printf 'power on\n%s %s\n' "$mode" "$mac" | _bluetoothctl 68 | if printf 'info %s\n' "$mac" | 69 | _bluetoothctl | 70 | grep -Pq '^[\t ]+Connected: '"$expected_to_connect"; then 71 | notify "${mode^}ed $preposition $name" 72 | return 0 73 | fi 74 | sleep 1 75 | done 76 | 77 | ret="$?" 78 | notify "Failed to $mode $preposition $name" 1 79 | return "$ret" 80 | } 81 | 82 | i=2 83 | 84 | for arg do 85 | if [[ $arg == :: ]]; then 86 | dmenu_args=( "${@:$i}" ) 87 | break 88 | fi 89 | 90 | case "$arg" in 91 | -d) mode=disconnect ;; 92 | esac 93 | 94 | (( i++ )) 95 | done 96 | 97 | execute_mode "$mode" 98 | -------------------------------------------------------------------------------- /i3-wm-scripts/README.md: -------------------------------------------------------------------------------- 1 | i3-wm-scripts 2 | ============= 3 | 4 | i3 Window Manager Scripts 5 | 6 | These are python scripts that read/write to i3 using i3-msg. By using regular expressions it is possible to 7 | search for windows with particular names and jump to them. 8 | 9 | Dependencies: i3, i3-msg (distributed with i3), dmenu 10 | 11 | There are 4 scripts: nextmatch, nextfind, goto, mark 12 | 13 | ### nextmatch 14 | 15 | Syntax: nextmatch \ 16 | 17 | This script takes one regular expression input e.g. '(fire|chrom)' and searches for that name in the list of 18 | available windows. If there is a match then it jumps to the match. If you are already at a match it goes to the 19 | next match (or stays if there is only one) 20 | 21 | Example Binding: 22 | ``` 23 | bindsym $mod+q exec python ~/bin/nextmatch vim # cycle through vim sessions 24 | bindsym $mod+w exec python ~/bin/nextmatch '(chromium|firefox)' # cycle through browsers using regex 25 | ``` 26 | ### nextfind 27 | 28 | Syntax: nextfind 29 | 30 | This script works similarly to the previous but takes no arguments and instead 31 | provides a dmenu list of arguments. If you select one a window that is active 32 | and there are multiple with the same name then it jumps to the next one, 33 | otherwise it stays at the current. 34 | 35 | Example Binding: 36 | ``` 37 | bindsym $mod+e exec python ~/bin/nextfind # use dmenu to select an open window 38 | ``` 39 | 40 | ### mark/goto/unmark 41 | These scripts mark and jump to a specified script. I rarely use them, 42 | because I prefer the other two, but they can be useful if you are jumping to a 43 | lot of windows with the same name (like terminals). Basically you can mark the 44 | current window by calling mark (or binding it them using the key-combination). 45 | Then you can get a list of marked windows (similar to nextfind, but only 46 | with marked windows included) to jumpt to. 47 | 48 | Example bindings: 49 | ``` 50 | bindsym $mod+Shift+grave exec ~/bin/unmark # unmark the current window 51 | bindsym $mod+grave exec ~/bin/mark # mark the current window 52 | bindsym $mod+Tab exec exec ~/bin/goto # get dmenu of marked windows 53 | ``` 54 | 55 | ### Install 56 | To install just put the scripts in your path, or bind the scripts in you config 57 | file. I installed mine in ~/bin/, then made the bindings in my config file. 58 | 59 | -------------------------------------------------------------------------------- /wip/wifi.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : wifi.sh 6 | # @created : Tue 14 Apr 2020 12:45:32 PM 7 | # 8 | # @description : script to connect to wifi 9 | ###################################################################### 10 | 11 | # TODO: setup wpa_cli events fo connected and disconnected 12 | # https://wiki.archlinux.org/index.php/Wpa_supplicant#wpa_cli_action_script 13 | 14 | #get the name of the wifi device 15 | DEVICE=$(iw dev | awk '/Interface/ {print $2}') 16 | 17 | if [ $(echo $DEVICE | wc -l) -gt 1 ]; then 18 | DEVICE=$(echo $DEVICE | dmenu -p 'select device') 19 | fi 20 | 21 | # check if wifi is connected 22 | echo "check if device is enabled" 23 | if ! ip link show "${device}" | grep 'up' ; then 24 | echo "device is not enabled" 25 | # turn connection on 26 | sudo ip link set "${DEVICE}" up || notify "set ${DEVICE} to UP" 27 | fi 28 | 29 | # check if already connected 30 | echo "check if already connected" 31 | if iw "${DEVICE}" link | grep 'Connected to .*' ; then 32 | notify-send "wifi is already connected" 33 | exit 34 | fi 35 | 36 | # get the avalilable networks 37 | echo "get the avalilable networks" 38 | WIFI=$(sudo iw wls1 scan |awk '/ssid: [^[:space:]]+.*/ {print $2}' | dmenu -p "Select Network") 39 | 40 | # TODO: select a network 41 | # WIFI= 42 | 43 | # Connect to WPA/WPA2 WiFi network 44 | # XXX: not sure if this works 45 | echo "add passphrase to wpa_supplicant" 46 | wpa_passphrase "${WIFI}" |sudo tee -a /etc/wpa_supplicant.conf 47 | 48 | # -B means run wpa_supplicant in the background. 49 | # -D specifies the wireless driver. wext is the generic driver. 50 | # nl80211 is the current standard, but not all wireless 51 | # chip's modules support it 52 | # -c specifies the path for the configuration file. 53 | sudo wpa_supplicant -B -D wext -i "${DEVICE}" -c /etc/wpa_supplicant.conf 54 | 55 | iw "${DEVICE}" link 56 | 57 | # use dhclient to get ip address 58 | sudo dhclient "${DEVICE}" 59 | 60 | IPADDR=$(ip addr show wls1 | awk '/inet.*wls1/ {print $2}') 61 | 62 | # TODO: add routing 63 | # sudo ip route add default via 192.168.0.255 dev wls1 64 | 65 | # check that default has been set 66 | ip route show | grep 'default' 67 | # vim: set tw=78 ts=2 et sw=2 sr: 68 | -------------------------------------------------------------------------------- /tools/www: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Feed script a url. 4 | # If an image, it will view in sxiv, 5 | # if a video or gif, it will view in mpv 6 | # if a music file or pdf, it will download, 7 | # otherwise it opens link in browser. 8 | # cant use environmental variables 9 | # If no url given. Opens browser. For using script as $BROWSER. 10 | 11 | OS="$(uname -o)" # this is for use with termux 12 | if [ "${OS}" = 'Android' ]; then 13 | [ -z "$1" ] && { 14 | xdg-open "https://duckduckgo.com" 15 | exit 16 | } 17 | xdg-open "$1" 18 | exit 19 | fi 20 | notify-send "$1" 21 | 22 | [ -z "${TRUEBROWSER}" ] && TRUEBROWSER="qutebrowser" 23 | 24 | [ -z "$1" ] && { 25 | ${TRUEBROWSER} "https://duckduckgo.com" 26 | exit 27 | } 28 | 29 | case "$1" in 30 | *\.mkv | *\.webm | *\.mp4 | *\.gif | *hooktube.com* | *v.redd.it* | *view_video*) 31 | exec mpv --really-quiet --force-window=immediate "$1" >/dev/null 2>&1 32 | notify-send "Playing Video" 33 | ;; 34 | *\.png | *\.jpg | *\.jpe | *\.jpeg) 35 | curl -sL "$1" >"/tmp/$(echo "$1" | sed "s/.*\///")" && 36 | exec xdg-open "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 37 | ;; 38 | *\.ps) 39 | curl -sL "$1" >"/tmp/$(echo "$1" | sed "s/.*\///")" && ps2pdf "/tmp/$(echo "$1" | sed "s/.*\///")" && 40 | exec "${READER}" "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 41 | ;; 42 | *\.pdf) 43 | curl -sL "$1" >"/tmp/$(echo "$1" | sed "s/.*\///")" && exec "${READER}" "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 44 | ;; 45 | *\.mp3 | *\.m4a | *\.ogg | *\.flac | *\.opus | *\.mp3?source | *soundcloud*) 46 | exec "${TERMINAL}" -n "mp3" -e mpv --video=no "$1" >/dev/null 2>&1 47 | ;; 48 | *\.diff | *\.m[msd] | *\.tr | *\.txt | *\.[ch] | *\.cpp | *\.hs | *\.py | *\.sh | *raw*) 49 | if ! echo "$1" | grep "github\.com"; then 50 | curl -sL "$1" >"/tmp/$(echo "$1" | sed "s/.*\///")" && exec xdg-open "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 51 | else 52 | exec "${TRUEBROWSER}" "$1" >/dev/null 2>&1 53 | fi 54 | ;; 55 | *\.torrent | *\.magnet) 56 | exec transadd "$1" 57 | ;; 58 | mailto*) 59 | exec emacs "$1" 60 | ;; 61 | *youtube.com/watch* | *youtube.com/playlist* | *youtu.be*) #limit the video quality 62 | exec mpv "$1" 63 | ;; 64 | *) 65 | exec "${TRUEBROWSER}" "$1" >/dev/null 2>&1 66 | ;; 67 | esac 68 | -------------------------------------------------------------------------------- /dmenu/dmenuhandler: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Feed this script a link and it will give dmenu 3 | # some choice programs to use to open it. 4 | # TODO 5 | # 1. Check if a program is installed before offering the option 6 | 7 | Ifinstalled() { 8 | command -v "$1" >/dev/null || { notify-send "📦 $1 must be installed for this function." && exit 1; } 9 | } 10 | 11 | torrent(){ 12 | Ifinstalled transadd && transadd "${1}" && exit 13 | Ifinstalled aria2c && aria2c "${1}" && exit 14 | notify-send "No Torrent Program installed" 15 | } 16 | 17 | youtube(){ 18 | notify-send "downloading video" 19 | setsid youtube-dl --add-metadata -i -o "$HOME/Downloads/%(title)s.%(ext)s" "${1}" \ 20 | && notify-send "finished download" && exit 21 | notify-send "failed downloading" 22 | } 23 | 24 | clone(){ 25 | 26 | repo=$(echo "$1" | cut -d# -f1) 27 | repo=${repo}.git 28 | notify-send "cloning repository ${repo}" 29 | git -C "$HOME/Downloads/" clone "${repo}" \ 30 | && notify-send "finished cloning" && exit 31 | notify-send "failed cloning" 32 | } 33 | 34 | raw(){ 35 | 36 | notify-send "downloading page" 37 | wget -P "$HOME/Downloads/" "${1}" \ 38 | && notify-send "finished downloading" && exit 39 | notify-send "failed cloning" 40 | } 41 | 42 | downloader (){ 43 | case "$1" in 44 | *magnet:*|*torrent*) 45 | torrent "${1}";; 46 | *youtube.com/watch* | *youtube.com/playlist*|*youtu.be*) 47 | youtube "${1}" ;; 48 | *github.com*|*gitlab.com*) 49 | clone "${1}" ;; 50 | *) 51 | raw "${1}" ;; 52 | esac 53 | notify-send "failed downloading" 54 | exit 55 | } 56 | 57 | x="$(printf "chrome\\nbrowser\\nmpv\\ndownload\\nkdeconnect\\nQR\\nyt\\ncast" | dmenu -i -p "Open link with what program?")" 58 | case "${x}" in 59 | chrome) 60 | setsid brave "$1" >/dev/null 2>&1 & ;; 61 | browser) 62 | setsid "$TRUEBROWSER $1" >/dev/null 2>&1 & ;; 63 | cast) 64 | setsid cast "$1" 2>&1 ;; 65 | QR) 66 | qrencode "$1" -s 10 -o /tmp/QR.png "$1" 67 | xdg-open /tmp/QR.png >/dev/null 2>&1 &;; 68 | mpv) 69 | notify-send "playing video" && mpv "$1" >/dev/null 2>&1 70 | notify-send "failed to play video" ;; 71 | kdeconnect) 72 | kdeconnect-handler "$1" >/dev/null 2>&1 &;; 73 | yt) 74 | ytplay "$1" >/dev/null 2>&1 || notify-send "failed to play video" ;; 75 | download) 76 | downloader "$1" ;; 77 | *) 78 | exit 1;; 79 | esac 80 | #vim:ft=sh 81 | -------------------------------------------------------------------------------- /tools/shortcuts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Output locations. Unactivated progs should go to /dev/null. 3 | # Credit yo the original creator: 4 | # Luck Smith 5 | # https://github.com/LukeSmithxyz/voidrice 6 | shell_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/shortcutrc" 7 | ranger_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/ranger/shortcuts.conf" 8 | qute_shortcuts="/dev/null" 9 | fish_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/fish/shortcuts.fish" 10 | vifm_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/vifm/vifmshortcuts" 11 | vim_shortcuts="$HOME/.vim/vimshortcuts.vim" 12 | 13 | # Remove, prepare files 14 | rm -f "$ranger_shortcuts" "$qute_shortcuts" 2>/dev/null 15 | printf "# vim: filetype=sh\\n" > "$fish_shortcuts" 16 | printf "# vim: filetype=sh\\n" > "$shell_shortcuts" 17 | printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts" 18 | printf "\" vim: filetype=vim\\n" > "$vim_shortcuts" 19 | 20 | # Format the `bmdirs` file in the correct syntax and sent it to all three configs. 21 | sed "s/\s*#.*$//;/^\s*$/d" "$HOME/.config/bmdirs" | tee >(awk '{print "alias " $1"=\"cd "$2" && ls -a\" "}' >> "$shell_shortcuts") \ 22 | >(awk '{print "abbr", $1, "\"cd " $2 "; and ls -a\""}' >> "$fish_shortcuts") \ 23 | >(awk '{print "map g" $1, ":cd", $2 "\nmap t" $1, ":cd", $2 "\nmap M" $1, ":cd", $2 ":mo\nmap Y" $1, ":cd", $2 ":co" }' >> "$vifm_shortcuts") \ 24 | >(awk '{print "config.bind(\";"$1"\", \"set downloads.location.directory "$2" ;; hint links download\")"}' >> "$qute_shortcuts") \ 25 | >(awk '{print "nmap g" $1, ":e", $2 "" }' >> "$vim_shortcuts") \ 26 | | awk '{print "map g"$1" cd "$2"\nmap t"$1" tab_new "$2"\nmap m"$1" shell mv -v %s "$2"\nmap Y"$1" shell cp -rv %s "$2}' >> "$ranger_shortcuts" 27 | 28 | # Format the `configs` file in the correct syntax and sent it to both configs. 29 | sed "s/\s*#.*$//;/^\s*$/d" "$HOME/.config/bmfiles" | tee >(awk '{print "alias "$1"=\"${EDITOR:-vi} $(readlink "$2"||echo "$2")\" "}' >> "$shell_shortcuts") \ 30 | >(awk '{print "abbr", $1, "\"$EDITOR $(readlink "$2")\""}' >> "$fish_shortcuts") \ 31 | >(awk '{print "map", $1, ":e", $2 "" }' >> "$vifm_shortcuts") \ 32 | >(awk '{print "nmap "$1, ":e =resolve(expand(\"",$2"\"))"}' >> "$vim_shortcuts") \ 33 | >(awk '{print "nmap "$1, ":e =resolve(expand(\"",$2"\"))"}' >> "$vim_shortcuts") \ 34 | | awk '{print "map "$1" shell $EDITOR "$2}' >> "$ranger_shortcuts" 35 | -------------------------------------------------------------------------------- /dmenu/displayselect: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A UI for detecting and selecting all displays. 4 | # Probes xrandr for connected displays and lets user select one to use. 5 | # User may also select "manual selection" which opens arandr. 6 | # I plan on adding a routine from multi-monitor setups later. 7 | 8 | twoscreen() { # If multi-monitor is selected and there are two screens. 9 | primary=$(echo "$screens" | dmenu -i -p "asdf") 10 | secondary=$(echo "$screens" | grep -v "$primary") 11 | direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?") 12 | xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto 13 | } 14 | 15 | morescreen() { # If multi-monitor is selected and there are more than two screens. 16 | primary=$(echo "$screens" | dmenu -i -p "asdf") 17 | secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:") 18 | direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?") 19 | tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:") 20 | xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto 21 | } 22 | 23 | multimon() { # Multi-monitor handler. 24 | case "$(echo "$screens" | wc -l)" in 25 | 1) xrandr $(echo "$allposs" | awk '{print "--output", $1, "--auto"}' | tr '\n' ' ') ;; 26 | 2) twoscreen ;; 27 | *) morescreen ;; 28 | esac ;} 29 | 30 | # Get all possible displays 31 | allposs=$(xrandr -q | grep "connected") 32 | 33 | # Get all connected screens. 34 | screens=$(echo "$allposs" | grep " connected" | awk '{print $1}') 35 | 36 | # Get user choice including multi-monitor and manual selection: 37 | chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") && 38 | case "$chosen" in 39 | "manual selection") arandr ; exit ;; 40 | "multi-monitor") multimon ;; 41 | *) xrandr --output "$chosen" --auto $(echo "$screens" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; 42 | esac 43 | 44 | # Fix feh background if screen size/arangement has changed. 45 | feh --bg-scale "$HOME/.config/wall.png" 46 | # Polybar users will want to uncomment this line, which reactivates polybar on all new displays: 47 | #polybar_launch 48 | # Re-remap keys if keyboard added (for laptop bases) 49 | remaps 50 | #vim:ft=sh 51 | -------------------------------------------------------------------------------- /dmenu/calc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # https://github.com/onespaceman/menu-calc 4 | # Calculator for use with rofi/dmenu(2) 5 | # Copying to the clipboard requires xclip 6 | 7 | usage() { 8 | echo "$(tput bold)menu-calc$(tput sgr0)" 9 | echo "A calculator for Rofi/dmenu(2)" 10 | echo 11 | echo "$(tput bold)Usage:$(tput sgr0)" 12 | echo " = 4+2" 13 | echo " = (4+2)/(4+3)" 14 | echo " = 4^2" 15 | echo " = sqrt(4)" 16 | echo " = c(2)" 17 | echo 18 | echo "$(tput bold)Force Rofi/dmenu(2):$(tput sgr0)" 19 | echo "By default, if rofi exists, it will be used. To force menu-calc to" 20 | echo "use one or the other, use the --dmenu argument" 21 | echo 22 | echo " = --dmenu=" 23 | echo 24 | echo "$(tput bold)Passing arguments to Rofi/dmenu(2):$(tput sgr0)" 25 | echo "Any parameters after ' -- ' will be passed to Rofi/dmenu(2)." 26 | echo 27 | echo " = -- " 28 | echo 29 | echo "The answer can be copied to the clipboard and used for further calculations inside (or outside) Rofi/dmenu." 30 | echo 31 | echo "If launched outside of Rofi/dmenu the expression may need quotation marks." 32 | exit 33 | } 34 | 35 | # Process CLI parameters 36 | for var in "$@" 37 | do 38 | case $var in 39 | -h|--help) usage ;; 40 | -d=*|--dmenu=*) 41 | menu=$(echo $var | cut -d'=' -f 2); 42 | ;; 43 | esac 44 | done 45 | 46 | # Grab the answer 47 | answer=$(echo "$1" | bc -l | sed '/\./ s/\.\{0,1\}0\{1,\}$//') 48 | 49 | # Path to menu application 50 | if [ ! -n "${menu+1}" ]; then 51 | if [[ -n $(command -v rofi) ]]; then 52 | menu=$(command -v dmenu) 53 | else 54 | echo >&2 "Rofi or dmenu not found" 55 | exit 56 | fi 57 | fi 58 | 59 | # If using rofi, add the necessary parameters 60 | if [[ $menu == "rofi" || $menu == $(command -v rofi) ]]; then 61 | menu="$menu -dmenu -lines 3" 62 | elif [[ $menu == "dmenu" || $menu == $(command -v dmenu) ]]; then 63 | menu="$menu ""$DMENU_OPTIONS" 64 | fi 65 | 66 | # Determine args to pass to dmenu/rofi 67 | while [[ $# -gt 0 && $1 != "--" ]]; do 68 | shift 69 | done 70 | [[ $1 == "--" ]] && shift 71 | 72 | action=$(echo -e "Copy to clipboard\nClear\nClose" | $menu "$@" -p "= $answer") 73 | 74 | case $action in 75 | "Clear") $0 "--dmenu=$menu" "--" "$@" ;; 76 | "Copy to clipboard") echo -n "$answer" | xclip -selection clipboard ;; 77 | "Close") ;; 78 | "") ;; 79 | *) $0 "$answer $action" "--dmenu=$menu" "--" "$@" ;; 80 | esac 81 | -------------------------------------------------------------------------------- /dmenu/menu-killall: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #description: dmenu for killall 3 | #usage: dmenu-killall is best suited for launching from a shortcut 4 | 5 | #example: dmenu-killall 6 | #a gui menu appears asking for which app to kill 7 | 8 | progname="$(expr "${0}" : '.*/\([^/]*\)')" 9 | [ -z "$LAUNCHER" ] && LAUNCHER="dmenu -l 5 -i -p " 10 | #variables are impractical to save complex cmds because of shell expantion 11 | #therefore functions are required: http://mywiki.wooledge.org/BashFAQ/050 12 | DMENU() { $LAUNCHER 'Kill'; } 13 | #looks better on xft powered dmenu: 14 | #https://bugs.launchpad.net/ubuntu/+source/suckless-tools/+bug/1093745 15 | 16 | _usage() { 17 | printf "%s\\n" "Usage: ${progname} [PATTERN]" 18 | printf "%s\\n" "Dmenu window selector for i3-wm." 19 | printf "%s\\n" 20 | printf "%s\\n" " -h, --help show this message and exit" 21 | } 22 | 23 | _die() { 24 | [ -n "${1}" ] && _die_msg="${1}" || exit 1 25 | printf "%b%b\\n" "${_die_msg}" ", press to exit" | DMENU 26 | exit 1 27 | } 28 | 29 | _notify() { 30 | [ -z "${1}" ] && return 1 31 | kill -9 $(pgrep notify-osd) >/dev/null 2>&1 32 | if ! DISPLAY=${DISPLAY:-:0} notify-send -t 1000 "${1}" "${2}"; then 33 | if command -v "gxmessage" 2>/dev/null; then 34 | font="Monaco 9" 35 | DISPLAY=${DISPLAY:-:0} gxmessage "${font:+-fn "$font"}" "${1}" "ok" 36 | elif command -v "xmessage" 2>/dev/null; then 37 | font="fixed" 38 | DISPLAY=${DISPLAY:-:0} xmessage "${font:+-fn "$font"}" "${1}" "ok" 39 | fi 40 | fi 41 | } 42 | 43 | _get_process_names() { 44 | printf "%s\\n" "$(command ps xo command= | sed \ 45 | -e "s: .*::; s:.*/::; s/:$//;" \ 46 | -e "s:^\[.*\]$::" -e "/^$/d" \ 47 | -e "s:^$::")" | sort | uniq 48 | } 49 | 50 | if [ ! -t 0 ]; then 51 | #add input comming from pipe or file to $@ 52 | set -- "${@}" $(cat) 53 | fi 54 | 55 | for arg in "${@}"; do #parse options 56 | case "${arg}" in 57 | -h|--help) _usage && exit ;; 58 | esac 59 | done 60 | 61 | if [ -z "${1}" ]; then 62 | if ! command -v "dmenu" >/dev/null 2>&1 && ! command -v "emenu" >/dev/null 2>&1 ; then 63 | printf "%s\\n" "${progname}: install 'dmenu' to run this program" >&2 64 | exit 1 65 | fi 66 | process_name="$(_get_process_names | DMENU)" 67 | else 68 | process_name="$(_get_process_names | grep -i "${@}" 2>/dev/null | head -1 )" 69 | fi 70 | 71 | if [ -z "${process_name}" ]; then 72 | _die 73 | else 74 | error_msg="$(kill -9 $(pgrep -x "${process_name}") 2>&1 1>/dev/null)" 75 | if [ X"${?}" != X"0" ]; then 76 | _notify "Error" "${error_msg}" 77 | exit 1 78 | fi 79 | fi 80 | #vim:ft=sh 81 | -------------------------------------------------------------------------------- /tools/musstuff: -------------------------------------------------------------------------------- 1 | These are some old lines from the i3 config. 2 | 3 | I now use the lmc script to change volume and music tracks, which makes i3blocks integration better. 4 | 5 | I deleted the alternative lines for audio commands from the i3 config. 6 | Still, since they're a good reference for people who use ALSA, or people who use music players besides mpd, I've kept them in this file. 7 | 8 | You can replace the commands in the lmc script to get the setup you want. I might have the script autodecide the command later on. 9 | 10 | #FOR ALSA/AMIXER 11 | #set $inc --no-startup-id amixer sset Master 2%+ 12 | #set $biginc --no-startup-id amixer sset Master 5%+ 13 | #set $dec --no-startup-id amixer sset Master 2%- 14 | #set $bigdec --no-startup-id amixer sset Master 5%- 15 | #set $mute --no-startup-id amixer sset Master toggle 16 | #set $truemute --no-startup-id amixer sset Master mute 17 | 18 | ##For spotify 19 | #set $music spotify 20 | #set $pause dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause 21 | #set $trupause dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause 22 | #set $play dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play 23 | #set $next dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next 24 | #set $prev dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous 25 | #set $lilfor dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Seek 26 | #set $bigfor dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Seek( 27 | 28 | # For moc: 29 | #set $music --no-startup-id st -e mocp 30 | #set $pause --no-startup-id mocp -G 31 | #set $truepause --no-startup-id mocp -P 32 | #set $next --no-startup-id mocp -f 33 | #set $prev --no-startup-id mocp -r 34 | #set $lilfor --no-startup-id mocp -k 10 35 | #set $bigfor --no-startup-id mocp -k 120 36 | #set $lilbak --no-startup-id mocp -k -10 37 | #set $bigbak --no-startup-id mocp -k -120 38 | #set $beg --no-startup-id mocp -j 0% 39 | 40 | # For cmus: 41 | #set $music --no-startup-id st -e cmus 42 | #set $pause --no-startup-id cmus-remote -u 43 | #set $next --no-startup-id cmus-remote -n 44 | #set $prev --no-startup-id cmus-remote -r 45 | #set $lilfor --no-startup-id cmus-remote -k +10 46 | #set $bigfor --no-startup-id cmus-remote -k +120 47 | #set $lilbak --no-startup-id cmus-remote -k -10 48 | #set $bigbak --no-startup-id cmus-remote -k -120 49 | #set $beg --no-startup-id cmus-remote -k 00:00:00 50 | -------------------------------------------------------------------------------- /dmenu/dmenumount: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #=============================================================================== 3 | # FILE: dmenumount 4 | # 5 | # ORIGINAL AUTHOR: Luke Smith 6 | # AUTHOR: Gavin Jaeger-Freeborn gavinfreeborn@gmail.com 7 | #=============================================================================== 8 | 9 | # Gives a dmenu prompt to mount unmounted drives and Android phones. If 10 | # they're in /etc/fstab, they'll be mounted automatically. Otherwise, you'll 11 | # be prompted to give a mountpoint from already existsing directories. If you 12 | # input a novel directory, it will prompt you to create that directory. 13 | 14 | getmount() { \ 15 | [ -z "$chosen" ] && exit 1 16 | # shellcheck disable=SC2086 17 | mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")" || exit 1 18 | [ "$mp" = "" ] && exit 1 19 | if [ ! -d "$mp" ]; then 20 | mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") || exit 1 21 | [ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp") 22 | fi 23 | } 24 | 25 | mountusb() { \ 26 | chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?")" || exit 1 27 | chosen="$(echo "$chosen" | awk '{print $1}')" 28 | sudo -A mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0 29 | alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not ( -path *%s -prune ) ",$3}') 30 | getmount "/mnt /media /mount /home -maxdepth 5 -type d $alreadymounted" 31 | partitiontype="$(lsblk -no "fstype" "$chosen")" 32 | case "$partitiontype" in 33 | "vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;; 34 | *) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp";; 35 | esac 36 | notify-send "💻 USB mounting" "$chosen mounted to $mp." 37 | } 38 | 39 | mountandroid() { \ 40 | chosen="$(echo "$anddrives" | dmenu -i -p "Which Android device?")" || exit 1 41 | chosen="$(echo "$chosen" | cut -d : -f 1)" 42 | getmount "$HOME -maxdepth 3 -type d" 43 | simple-mtpfs --device "$chosen" "$mp" 44 | echo "OK" | dmenu -i -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1 45 | simple-mtpfs --device "$chosen" "$mp" 46 | notify-send "🤖 Android Mounting" "Android device mounted to $mp." 47 | } 48 | 49 | asktype() { \ 50 | choice="$(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?")" || exit 1 51 | case $choice in 52 | USB) mountusb ;; 53 | Android) mountandroid ;; 54 | esac 55 | } 56 | 57 | anddrives=$(simple-mtpfs -l 2>/dev/null) 58 | usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | awk '$2=="part"&&$4==""{printf "%s (%s)\n",$1,$3}')" 59 | 60 | if [ -z "$usbdrives" ]; then 61 | [ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit 62 | echo "Android device(s) detected." 63 | mountandroid 64 | else 65 | if [ -z "$anddrives" ]; then 66 | echo "USB drive(s) detected." 67 | mountusb 68 | else 69 | echo "Mountable USB drive(s) and Android device(s) detected." 70 | asktype 71 | fi 72 | fi 73 | -------------------------------------------------------------------------------- /jgmenu/bar: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env sh 2 | #=============================================================================== 3 | # FILE: bar 4 | # 5 | # DESCRIPTION: Custom Rightclick Menu 6 | # DEPENDANCIES: 7 | # - xwininfo 8 | # - xdotool 9 | # - xkill 10 | # ENV VARS: 11 | # - TERMINAL 12 | # - BROWSER 13 | # 14 | # AUTHOR: Gavin Jaeger-Freeborn gavinfreeborn@gmail.com 15 | # CREATED: Wed 20 May 2020 10:15:25 AM 16 | # VERSION: 1.0 17 | #=============================================================================== 18 | 19 | # file to store hidden windows 20 | tmpfile="/tmp/hidden" 21 | 22 | # default options for men 23 | opts=$(printf 'Resize\nspawn, ^pipe(jgmenu_run pmenu)\nKill\nHide\n') 24 | 25 | # check the number of hidden windows 26 | hiddenwindows=$(wc -l "${tmpfile}" | cut -d " " -f1) 27 | 28 | # add option to show windows if some exist 29 | [ "${hiddenwindows}" -ge "1" ] && opts=$(printf '%s\nShow\n' "${opts}") 30 | 31 | get_id_interactive() { 32 | xwininfo | grep 'Window id: ' | awk '{print $4}' 33 | } 34 | 35 | spawn() { 36 | prog=$(printf 'Term\nBrowser\nVol\n' | jgmenu --no-spawn --simple) 37 | [ -z "${prog}" ] && exit 38 | case "${prog}" in 39 | Term) 40 | setsid "${TERMINAL}" & 41 | ;; 42 | Browser) 43 | setsid "${BROWSER}" "https://duckduckgo.com" & 44 | ;; 45 | Vol) 46 | setsid st -e pulsemixer & 47 | ;; 48 | *) 49 | notify-send "error prog not found" 50 | exit 51 | ;; 52 | esac 53 | } 54 | 55 | killclient() { 56 | command -v xkill >/dev/null && xkill && exit 0 57 | id=$(get_id_interactive) 58 | [ -z "${id}" ] && exit 59 | # fall back to xdotool to kill window 60 | xdotool windowkill "${id}" 61 | } 62 | 63 | hideclient(){ 64 | id=$(get_id_interactive) 65 | 66 | [ -z "${id}" ] && exit 67 | xdotool windowunmap "${id}" 68 | printf "%b@@@%b\\n" "$(xwininfo -id "${id}" | grep 'Window id: ' | cut -d'"' -f 2)" "${id}" >> "${tmpfile}" 69 | } 70 | 71 | showclient(){ 72 | # implementation of unhide.sh using jgmenu 73 | if [ "${hiddenwindows}" -le "1" ]; then 74 | windowid=$(sed 's/@@@/ /g' "${tmpfile}" | awk '{print $NF}') 75 | else 76 | windowid=$(sed 's/@@@/ /g' "${tmpfile}" | jgmenu --no-spawn --simple | awk '{print $NF}') 77 | echo "${windowid}" 78 | fi 79 | 80 | if [ -n "${windowid}" ]; then 81 | xdotool windowmap "${windowid}" 82 | sed -i '/'${windowid}'/d' "${tmpfile}" 83 | export windowid= 84 | else 85 | notify-send "No hidden windows" 86 | fi 87 | } 88 | 89 | 90 | func=$(printf '%s\n' "${opts}" | jgmenu --no-spawn --simple) 91 | [ -z "${func}" ] && exit 92 | case ${func} in 93 | Resize) 94 | id=$(get_id_interactive) 95 | [ -z "${id}" ] && exit 96 | geo=$(slop -n) 97 | [ -z "${geo}" ] && exit 98 | xsize=$(echo "${geo}" | cut -dx -f1) 99 | echo "${xsize}" 100 | ysize=$(echo "${geo}" | cut -dx -f2 | cut -d+ -f1) 101 | echo "${ysize}" 102 | xlocal=$(echo "${geo}" | cut -d+ -f2) 103 | echo "${xlocal}" 104 | ylocal=$(echo "${geo}" | cut -d+ -f3) 105 | echo "${ylocal}" 106 | xdotool windowsize "${id}" "${xsize}" "${ysize}" 107 | xdotool windowmove "${id}" "${xlocal}" "${ylocal}" 108 | exit 109 | ;; 110 | Spawn) 111 | spawn 112 | ;; 113 | Kill) 114 | killclient 115 | ;; 116 | Hide) 117 | hideclient 118 | ;; 119 | Show) 120 | showclient 121 | ;; 122 | *) setsid "${func}" ;; 123 | esac 124 | exit 125 | #vim:ft=sh 126 | -------------------------------------------------------------------------------- /mailsync: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Sync mail and give notification if there is new mail. 3 | 4 | export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 5 | DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus 6 | export DBUS_SESSION_BUS_ADDRESS 7 | export DISPLAY=:0.0 8 | [ -d "$HOME/.local/share/password-store" ] && export PASSWORD_STORE_DIR="$HOME/.local/share/password-store" 9 | 10 | # Settings are different for MacOS (Darwin) systems. 11 | if [ "$(uname)" = "Darwin" ]; then 12 | notify() { osascript -e ": $*" && sleep 2; } 13 | mailnotify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2; } 14 | elif [ -n "$DISPLAY" ]; then 15 | notify() { notify-send --app-name="mutt-wizard" "" "$*"; } 16 | mailnotify() { notify-send --app-name="mutt-wizard" "" "📬 $2 new mail(s) in \`$1\` account."; } 17 | else 18 | notify() { echo " $*"; } 19 | mailnotify() { echo "" "📬 $2 new mail(s) in \`$1\` account."; } 20 | fi 21 | 22 | # Run only if user logged in (prevent cron errors) 23 | pgrep -u "${USER:=$LOGNAME}" >/dev/null || { 24 | notify "$USER not logged in; sync will not run." 25 | exit 26 | } 27 | # Run only if not already running in other instance 28 | pgrep -x mbsync >/dev/null && { 29 | notify "mbsync is already running." 30 | exit 31 | } 32 | 33 | # Checks for internet connection and set notification script. 34 | ping -q -c 1 1.1.1.1 >/dev/null || { 35 | notify "No internet connection detected." 36 | exit 37 | } 38 | command -v notify-send >/dev/null || notify 'Note that `libnotify` or `libnotify-send` should be installed for pop-up mail notifications with this script.' 39 | 40 | # Check account for new mail. Notify if there is new content. 41 | syncandnotify() { 42 | acc="$(echo "$account" | sed "s/.*\///")" 43 | mbsync "$acc" 44 | new=$(find "$HOME/.local/share/mail/$acc/INBOX/new/" "$HOME/.local/share/mail/$acc/Inbox/new/" "$HOME/.local/share/mail/$acc/inbox/new/" -type f -newer "$HOME/.config/mutt/.mailsynclastrun" 2>/dev/null) 45 | newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) 46 | if [ "$newcount" -gt "0" ]; then 47 | mailnotify "$acc" "$newcount" & 48 | for file in $new; do 49 | # Extract subject and sender from mail. 50 | from=$(awk '/^From: / && ++n ==1,/^\<.*\>:/' "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | awk '{ $1=""; if (NF>=3)$NF=""; print $0 }' | sed 's/^[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//') 51 | subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: / && ++i == 2' "$file" | head -n-1 | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | sed 's/^Subject: //' | sed 's/^{[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//' | tr -d '\n') 52 | notify " $from:" "$subject" & 53 | done 54 | fi 55 | } 56 | 57 | # Sync accounts passed as argument or all. 58 | if [ "$#" -eq "0" ]; then 59 | accounts="$(awk '/^Channel/ {print $2}' "$HOME/.mbsyncrc")" 60 | else 61 | accounts=$* 62 | fi 63 | 64 | echo " 🔃" >/tmp/imapsyncicon_"$USER" 65 | (pkill -RTMIN+12 "${STATUSBAR:?}" >/dev/null 2>&1) 2>/dev/null 66 | 67 | # Startup davmail for use with outlook accounts 68 | if ! pgrep -f davmail.jar >/dev/null; then 69 | echo "starting davmail" 70 | setsid --fork davmail -notray "$HOME/.davmail.properties" & 71 | sleep 5 72 | fi 73 | 74 | # Parallelize multiple accounts 75 | for account in $accounts; do 76 | syncandnotify & 77 | done 78 | 79 | wait 80 | rm -f /tmp/imapsyncicon_"$USER" 81 | (pkill -RTMIN+12 "${STATUSBAR:?}" >/dev/null 2>&1) 2>/dev/null 82 | 83 | mu index 2>/dev/null 84 | 85 | # notmuch new 2>/dev/null 86 | 87 | # recollindex 88 | 89 | #Create a touch file that indicates the time of the last run of mailsync 90 | touch "$HOME/.config/mutt/.mailsynclastrun" 91 | notify "Mail Syncronized" 92 | -------------------------------------------------------------------------------- /dwm/togglescheme.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | scheme=$(cat ~/.config/colorschemes/current) 4 | if [ "$scheme" = "dark" ];then 5 | scheme="light" 6 | else 7 | scheme="dark" 8 | fi 9 | 10 | #Xresources 11 | cp ~/.config/colorschemes/xresources/$scheme ~/.config/colorschemes/xresources/current 12 | xrdb ~/.Xresources 13 | 14 | #Xresources 15 | cp ~/.config/colorschemes/xresources/$scheme ~/.config/colorschemes/xresources/current 16 | xrdb ~/.Xresources 17 | 18 | export BACKGROUND=$(getres '*.background') 19 | export FOREGROUND=$(getres '*.foreground') 20 | export BANNER=$(getres '*.banner') 21 | export ALT=$(getres '*.alt') 22 | 23 | # envsubst settings 24 | export FONT='monospace' 25 | export FONTSIZE='10' 26 | 27 | #dunst 28 | envsubst < ~/.config/colorschemes/dunst/dunstrc.template > ~/.config/dunst/dunstrc 29 | killall dunst 30 | setsid dunst & 31 | 32 | #jgmenu 33 | envsubst < ~/.config/colorschemes/jgmenu/jgmenurc.template > ~/.config/jgmenu/jgmenurc 34 | 35 | #wall 36 | cp ~/.config/colorschemes/wall/$scheme.png ~/.config/wall.png 37 | setbg 38 | 39 | #vifm 40 | cp ~/.config/colorschemes/vifm/$scheme.vifm ~/.config/vifm/colors/current.vifm 41 | 42 | #vim and bash and newsboat 43 | if [ $scheme = "dark" ]; then 44 | #vimrc 45 | sed -i 's/acme/spaceway/g' ~/.vimrc 46 | #bashrc 47 | sed -i "s/TEXTCOLOR=30m/TEXTCOLOR=37m/g" ~/.bashrc 48 | sed -i "s/PATHCOLOR=30m/PATHCOLOR=34m/g" ~/.bashrc 49 | sed -i "s/PROMPTCOLOR=30m/PROMPTCOLOR=35m/g" ~/.bashrc 50 | sed -i "s/SCHEME=light/SCHEME=dark/g" ~/.bashrc 51 | #zsh 52 | sed -i 's/#PROMPT/PROMPT/g' ~/.zshrc 53 | sed -i 's/PROMPT.*#light/#\0/g' ~/.zshrc 54 | sed -i "s/SCHEME=light/SCHEME=dark/g" ~/.zshrc 55 | #newsboat 56 | sed -i "s/black/color15/g" ~/.config/newsboat/config 57 | sed -i "s/color info black default bold/color info red default bold/g" ~/.config/newsboat/config 58 | sed -i "s/color listnormal_unread blue default bold/color listnormal_unread white default bold/g" ~/.config/newsboat/config 59 | #ranger 60 | sed -i "s/bwlight/solarized/g" ~/.config/ranger/rc.conf 61 | #rtv 62 | sed -i "s/mytheme2/mytheme1/g" ~/.config/rtv/rtv.cfg 63 | #compton 64 | setsid picom & 65 | setsid flashfocus & 66 | #mutt 67 | sed -i "s\source ~/.config/colorschemes/mutt/light\\g" ~/.config/mutt/muttrc 68 | 69 | else 70 | #vimrc 71 | sed -i 's/spaceway/acme/g' ~/.vimrc 72 | #bashrc 73 | sed -i "s/TEXTCOLOR=37m/TEXTCOLOR=30m/g" ~/.bashrc 74 | sed -i "s/PATHCOLOR=34m/PATHCOLOR=30m/g" ~/.bashrc 75 | sed -i "s/PROMPTCOLOR=35m/PROMPTCOLOR=30m/g" ~/.bashrc 76 | sed -i "s/SCHEME=dark/SCHEME=light/g" ~/.bashrc 77 | #zsh 78 | sed -i 's/#PROMPT/PROMPT/g' ~/.zshrc 79 | sed -i 's/PROMPT.*#dark/#\0/g' ~/.zshrc 80 | sed -i "s/SCHEME=light/SCHEME=dark/g" ~/.zshrc 81 | #newsboat 82 | sed -i "s/color15/black/g" ~/.config/newsboat/config 83 | sed -i "s/white/black/g" ~/.config/newsboat/config 84 | sed -i "s/color info red default bold/color info black default bold/g" ~/.config/newsboat/config 85 | sed -i "s/color listnormal_unread black default bold/color listnormal_unread black default bold/g" ~/.config/newsboat/config 86 | 87 | #ranger 88 | sed -i "s/solarized/bwlight/g" ~/.config/ranger/rc.conf 89 | #rtv 90 | sed -i "s/mytheme1/mytheme2/g" ~/.config/rtv/rtv.cfg 91 | #ducksearch 92 | sed -i "s/kae=d/kae=-1/g" ~/.scripts/dmenu/ducksearch 93 | #compton 94 | killall picom 95 | killall flashfocus 96 | #mutt 97 | echo 'source ~/.config/colorschemes/mutt/light' ~/.config/mutt/muttrc 98 | fi 99 | 100 | #dwm 101 | # cp ~/.config/colorschemes/dwm/$scheme.h ~/.config/colorschemes/dwm/current.h 102 | # cd ~/.config/dwm/ || exit 103 | # sudo make clean install 104 | # killall dwm 105 | 106 | #dmenu 107 | if [ -f "~/.config/colorschemes/dmenu/$scheme.h" ] ; then 108 | cp ~/.config/colorschemes/dmenu/$scheme.h ~/.config/colorschemes/dmenu/current.h 109 | cd ~/.config/dmenu/ || exit 110 | sudo make clean install 111 | fi 112 | 113 | #surf 114 | # cp ~/.config/colorschemes/surf/$scheme.h ~/.config/colorschemes/surf/current.h 115 | # cd ~/.config/surf/ || exit 116 | # sudo make clean install 117 | 118 | #update scheme 119 | echo $scheme > ~/.config/colorschemes/current 120 | notify-send "Scheme set to $scheme" 121 | -------------------------------------------------------------------------------- /functions: -------------------------------------------------------------------------------- 1 | # -*- mode: sh -*- 2 | 3 | # make plan9 walk available on all systems 4 | walk() { 5 | if command -v walk >/dev/null 2>&1; then 6 | /usr/local/bin/walk $@ 7 | elif command -v fd >/dev/null 2>&1; then 8 | fd -c never . 9 | else 10 | find . 11 | fi 12 | } 13 | 14 | # Calculator 15 | calc() { echo "scale=5;$*" | bc -l; } 16 | 17 | r() { 18 | local dst="$(command vifm --choose-dir - ".")" 19 | if [ -z "$dst" ]; then 20 | echo 'Directory picking cancelled/failed' 21 | return 1 22 | fi 23 | cd "$dst" 24 | } 25 | 26 | # f() { 27 | # fff "$@" 28 | # cd "$(cat "${XDG_CACHE_HOME:=${HOME}/.cache}/fff/.fff_d")" 29 | # } 30 | 31 | #dirsize - finds directory sizes and lists them for the current directory 32 | dirsize() { 33 | du -shx -- * .[a-zA-Z0-9_]* 2>/dev/null | grep -E '^ *[0-9.]*[MG]' | sort -n >/tmp/list 34 | grep -E '^ *[0-9.]*M' /tmp/list 35 | grep -E '^ *[0-9.]*G' /tmp/list 36 | rm /tmp/list 37 | } 38 | 39 | #myip - finds your current IP if your connected to the internet 40 | myip() { 41 | lynx -dump -hiddenlinks=ignore -nolist http://checkip.dyndns.org:8245/ | awk '{ print $4 }' | sed '/^$/d; s/^[ ]*//g; s/[ ]*$//g' 42 | } 43 | 44 | # define a word 45 | define() { curl -s "dict://dict.org/d:$1" | grep -v '^[0-9]'; } 46 | 47 | man() { /bin/man $@ || awman "$@"; } 48 | 49 | # Create a shell function as a wrapper 50 | viminfo() { ${EDITOR:-vi} -R -M -c "Info $1 $2" +only; } 51 | # Alias info to our new function 52 | # alias info=viminfo 53 | 54 | notegrep() { ${EDITOR:-vi} -c "NGrep $*"; } 55 | 56 | fn() { ${EDITOR:-vim} $(rg -n '.*' "$HOME/Documents/org/" | fzf --layout=reverse --height 50% --ansi | sed -E 's/(.*):([0-9]+):.*/\1 +\2/g'); } 57 | 58 | fr() { ${EDITOR:-vim} $(rg -n '.*' "$HOME/.config/remind/" | fzf --layout=reverse --height 50% --ansi | sed -E 's/(.*):([0-9]+):.*/\1 +\2/g'); } 59 | 60 | cpuspeed() { cpupower frequency-info -fm | grep -oP '(?<=frequency: )([^ ]+ [^ ]+)'; } 61 | 62 | powernow() { echo "scale=5;$(cat /sys/class/power_supply/BAT0/power_now)/1000000" | bc -l; } 63 | 64 | onecpu() { echo 0 | sudo tee /sys/devices/system/cpu/cpu*/online; } 65 | 66 | allcpu() { echo 1 | sudo tee /sys/devices/system/cpu/cpu*/online; } 67 | 68 | # may remove if I never end up using it 69 | 70 | fzjq() { 71 | echo '' | fzf --print-query --preview "jq {q} \"$*\"" 72 | } 73 | 74 | fzrec() { 75 | echo '' | fzf --print-query --preview "recsel {q} $*" 76 | } 77 | 78 | fzndb() { 79 | echo '' | fzf --print-query --preview "ndbquery -f $* atomicnumber {q}" 80 | } 81 | 82 | fzawk() { 83 | echo '' | fzf --layout=reverse --height 50% --print-query --preview 'echo "a\nb\nc\nd" | awk {q}' 84 | } 85 | 86 | fzR() { 87 | echo '' | fzf --layout=reverse --height 50% --print-query --preview 'R -s -e {q}' 88 | 89 | } 90 | 91 | sk() { 92 | screenkey --no-systray -t 2 -p fixed -g '420x61+3300+54' 93 | } 94 | 95 | pdfappend() { 96 | gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dAutoRotatePages=/None -dAutoFilterColorImages=false -dAutoFilterGrayImages=false -dColorImageFilter=/FlateEncode -dGrayImageFilter=/FlateEncode -dDownsampleMonoImages=false -dDownsampleGrayImages=false -sOutputFile=fileAll.pdf $* && 97 | echo "created fileAll.pdf" 98 | } 99 | 100 | pdfshrink() { 101 | gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=shrunken.pdf $* 102 | echo "created shrunken.pdf" 103 | } 104 | 105 | 9start() { 106 | qemu-system-x86_64 -cpu host -enable-kvm -m 1024 \ 107 | -net nic,model=virtio,macaddr=52:54:00:00:EE:03 -net user \ 108 | -device virtio-scsi-pci,id=scsi \ 109 | -drive if=none,id=vd0,file=/home/gavinok/9front.qcow2.img \ 110 | -device scsi-hd,drive=vd0 111 | } 112 | 113 | pokeemacs() { 114 | pkill -SIGUSR2 emacs 115 | } 116 | 117 | getDockerHost() { 118 | ( 119 | if [[ $(uname) == "Linux" ]] ; then 120 | dockerHostAddress=$(docker run --rm --net=host eclipse/che-ip) 121 | else 122 | dockerHostAddress=host.docker.internal 123 | fi 124 | echo ${DOCKERHOST:-${APPLICATION_URL:-${dockerHostAddress}}} 125 | ) 126 | } 127 | 128 | #vim:ft=sh 129 | -------------------------------------------------------------------------------- /fzf/pkgsearch: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Searches repos and installs multiple packages. 3 | # Currently works with Debian, Ubuntu and Arch, and 4 | # experimental support for Fedora and Void. 5 | # credit to original creator: 6 | # Daniel Gray 7 | # https://github.com/DanielFGray/fzf-scripts 8 | declare -r esc=$'\033' 9 | declare -r c_reset="${esc}[0m" 10 | declare -r c_red="${esc}[31m" 11 | declare -r c_green="${esc}[32m" 12 | declare -r c_blue="${esc}[34m" 13 | declare distro 14 | declare preview_pos='right:hidden' 15 | 16 | usage() { 17 | LESS=-FEXR less <&2 28 | } 29 | 30 | die() { 31 | exit 1 32 | } 33 | 34 | has() { 35 | local verbose=0 36 | if [[ $1 = '-v' ]]; then 37 | verbose=1 38 | shift 39 | fi 40 | for c; do c="${c%% *}" 41 | if ! command -v "$c" &> /dev/null; then 42 | (( "$verbose" > 0 )) && err "$c not found" 43 | return 1 44 | fi 45 | done 46 | } 47 | 48 | select_from() { 49 | local cmd='command -v' 50 | for a; do 51 | case "$a" in 52 | -c) 53 | cmd="$2" 54 | shift 2 55 | ;; 56 | esac 57 | done 58 | for c; do 59 | if $cmd "${c%% *}" &> /dev/null; then 60 | echo "$c" 61 | return 0 62 | fi 63 | done 64 | return 1 65 | } 66 | 67 | fzf() { 68 | command fzf -e +s --multi --cycle --ansi \ 69 | --bind='Ctrl-X:toggle-preview' \ 70 | --no-hscroll --inline-info \ 71 | --header='tab to select multiple packages, Ctrl-X for more info on a package' "$@" 72 | } 73 | 74 | install() { 75 | local pkgs count 76 | mapfile -t pkgs 77 | (( ${#pkgs} > 0 )) || exit 78 | count="${#pkgs[@]} package" 79 | (( ${#pkgs[@]} > 1 )) && count+='s' 80 | printf "installing %s: %s\n" "$count" "${pkgs[*]}" 81 | $1 "${pkgs[@]}" < /dev/tty 82 | } 83 | 84 | debian() { 85 | fzf --preview='apt-cache show {1}' \ 86 | --query="$1" \ 87 | < <(apt-cache search '.*' | sort | 88 | sed -u -r "s|^([^ ]+)|${c_green}\1${c_reset}|") | 89 | cut -d' ' -f1 | 90 | install "sudo $(select_from 'apt' 'aptitude' 'apt-get') install" 91 | } 92 | 93 | arch() { 94 | local search packages 95 | search='pacman' 96 | [[ -n "$1" ]] && search=$(select_from 'pacaur' 'trizen' 'yaourt' 'packer' 'apacman' 'pacman') 97 | packages=$(fzf --preview="$search -Si {2}" \ 98 | < <( $search -Ss "$1" | 99 | gawk '{ 100 | getline descr; 101 | sub(/ */,"", descr); 102 | repo = blue "[" gensub(/\/.*/, "", 1) "]" reset; 103 | name = green gensub(/.*\//, "", 1, $1) reset; 104 | info = gensub(/[^ ]* /, "", 1); 105 | print repo, name, info, descr; 106 | }' blue="$c_blue" green="$c_green" reset="$c_reset" 107 | ) | cut -d' ' -f2) 108 | [[ "$search" = "pacman" ]] && search="sudo pacman" 109 | install "$search -S" <<< "$packages" 110 | } 111 | 112 | void() { 113 | local package_list packagename='{ sub(/-[^\-]*$/, "", $2); print $2 }' 114 | package_list=$(xbps-query -Rs '' | sort) 115 | fzf --preview="p=\$(awk \"$packagename\" <<< {}); xbps-query -Rx \$p" \ 116 | --query="$1" <<< "$package_list" | 117 | awk "$packagename" | 118 | install 'xbps-install -S' 119 | } 120 | 121 | fedora() { 122 | fzf --query="$*" --preview='p={}; p="${p%% *}"; dnf -q info "${p%.*}"' \ 123 | < <(dnf -qC repoquery --qf "${c_green}%{name} ${c_reset} - %{summary}" \*) | 124 | awk '{ package=$1; sub(/\.\S+/, "", package); print package }' | 125 | install 'sudo dnf install' 126 | } 127 | 128 | while true; do 129 | case "$1" in 130 | -h|--help) usage; exit ;; 131 | -p|--preview) preview_pos="$2"; shift 2 ;; 132 | *) break 133 | esac 134 | done 135 | 136 | has -v fzf gawk || die 137 | 138 | request="$*" 139 | 140 | if [[ -r /etc/os-release ]]; then 141 | distro=$(awk -F'=' '"NAME" == $1 { gsub("\"", "", $2); print tolower($2); }' /etc/os-release) 142 | distro="${distro%% *}" 143 | else 144 | distro="$(uname -o)" 145 | fi 146 | 147 | case "$distro" in 148 | debian|ubuntu|Android) debian "$request" ;; 149 | arch) arch "$request" ;; 150 | manjaro) arch "$request" ;; 151 | void) void "$request" ;; 152 | fedora) fedora "$request" ;; 153 | *) die 'unknown distro :(' ;; 154 | esac 155 | 156 | # TODO: homebrew: brew desc -s 157 | # sample output: https://pastebin.com/raw/3frRf6C7 158 | -------------------------------------------------------------------------------- /dmenu/cabl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Dependencies are xclip and xorg-xprop. 3 | # qrencode required for qrcode generation. 4 | 5 | [ -z "$LAUNCER" ] && LAUNCER="dmenu" 6 | [ -z "$OPENER" ] && OPENER="xdg-open" 7 | while getopts cs: f 8 | do 9 | case $f in 10 | c) 11 | prim="$(xclip -o)" 12 | if [ -z "${prim}" ]; then 13 | notify-send "no selection in clipboard" 14 | exit 1 15 | fi 16 | ;; 17 | s) 18 | src=$OPTARG 19 | ;; 20 | \?) 21 | printf 'Invalid option: -%s\n' "${f}" && exit 1 22 | ;; 23 | esac 24 | done 25 | shift $(( OPTIND - 1)) 26 | 27 | # Custom opener when called from shell 28 | shellopener(){ 29 | open $* 30 | exit 1 31 | } 32 | 33 | fallbackopen() { 34 | case ${prim} in 35 | *.xopp) 36 | exec xournalpp "${prim}" 37 | ;; 38 | *) 39 | exec "$OPENER" "${prim}" 40 | ;; 41 | esac 42 | 43 | 44 | } 45 | 46 | istext(){ 47 | case $src in 48 | shell) 49 | case "$*" in 50 | *\.1) 51 | exec man "$*" 52 | ;; 53 | *) 54 | exec "${EDITOR:-vi}" "$*" 55 | ;; 56 | esac 57 | ;; 58 | vim) 59 | nvr -o "$*" --nostart && exit 60 | ;; 61 | *) 62 | fallbackopen "$*" 63 | ;; 64 | esac 65 | fallbackopen "$*" 66 | } 67 | 68 | 69 | isfile() { 70 | case $(file --mime-type "$*" -b) in 71 | # follow symlinks 72 | inode/symlink) isfile "$(readlink "$*")" && exit;; 73 | # open text files with sc 74 | text/*) istext "$*";; 75 | *) for f in "$@"; do fallbackopen "$*" > /dev/null 2> /dev/null & done && exit 0;; 76 | esac 77 | } 78 | 79 | isdir() { 80 | cd "$*" && exec "$TERMINAL" && exit 0 81 | fallbackopen "$*" 82 | } 83 | 84 | [ -z "${prim}" ] && prim="$*" 85 | [ -z "${prim}" ] && exit 86 | PID=$(xprop -id "$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')" | grep -m 1 PID | cut -d " " -f 3) 87 | PID=$(echo "$(pstree -lpA "${PID}" | tail -n 1)" | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g') 88 | cd "$(readlink /proc/"${PID}"/cwd)" || exit 89 | 90 | # FILE 91 | prim=$(echo "${prim}" | sed 's/file://g') # Remove file url 92 | [ -f "${prim}" ] && isfile "${prim}" && exit 1 93 | 94 | browse() { exec "${BROWSER}" "${prim}" ; } 95 | email() { xdg-email "${prim}" && exit; } 96 | vimplug() { exec "${BROWSER}" "https://github.com/$(echo "${prim}" | cut -d\' -f2)"; } 97 | errormsg() { exec "${TERMINAL}" -e "${EDITOR:-vi}" "$(echo "${prim}" | cut -d: -f1)" "+$(echo "${prim}" | cut -d: -f2)" ; } 98 | date() { 99 | exec "${BROWSER}" "https://calendar.google.com/calendar/r/day/$(echo "${prim}" | 100 | awk -F '[- ]' '{$1=$1}1 {printf "%s/%s/%s", $1, $2, $3}' | tr -d '<')" 101 | } 102 | 103 | # DIRECTORY 104 | [ -d "$prim" ] && isdir "${prim}" && exit 1 105 | 106 | # ONLY ONE LINE 107 | if [ "$(echo "${prim}" | wc -l )" -eq 1 ] ; then 108 | # URL 109 | echo "${prim}" | grep "^\s*https\?.*\.[A-Za-z]\+.*" > /dev/null && browse 110 | # EMAIL 111 | echo "${prim}" | grep "[A-Za-z0-9._%+-]\+@[A-Za-z0-9.-]\+\.[A-Za-z]\{2,6\}\$" > /dev/null && email 112 | # VIM PLUGIN 113 | echo "${prim}" | grep ".*Plug.*'.*/.*'.*" > /dev/null && vimplug 114 | # ERROR MESSAGE 115 | echo "${prim}" | cut -d: -f1 | xargs -r test -f && 116 | echo "${prim}" | grep -E '^[A-Za-z/\.-]+:[0-9]+' > /dev/null && errormsg 117 | # DATE https://calendar.google.com/calendar/r/day/ 118 | echo "${prim}" | grep '\s*<\?[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\} [a-zA-Z]\{3\} \?\([0-9]\{2\}:[0-9]\{2\}\)\?>\?\s*' > /dev/null && date 119 | fi 120 | 121 | # BEGIN OPTIONS 122 | OPTIONS=" 123 | search 124 | qrcode 125 | maps 126 | read" 127 | 128 | search() { "${BROWSER}" "https://duckduckgo.com/?q=$*"; } 129 | qrcode() { qrencode "$*" -s 10 -o /tmp/qr.png && "$OPENER" /tmp/qr.png; } 130 | maps() { "${BROWSER}" "https://maps.google.com/?q=$*"; } 131 | dhandler() { dmenuhandler "$@"; } 132 | manual() { man -Tpdf "${prim}" | ${READER} -; } 133 | 134 | # READ ALOUD 135 | read() { 136 | tts.sh "$1" 137 | # killall aplay 138 | # pico2wave -w=/tmp/test.wav -- "$1" 139 | # picospeaker "$*" 140 | # aplay /tmp/test.wav -D 'pulse' 141 | # aplay /tmp/test.wav 142 | # rm /tmp/test.wav 143 | } 144 | 145 | 146 | # MAYBE A URL 147 | echo "${prim}" | grep "^.*\.[A-Za-z]\+.*" > /dev/null && OPTIONS="${OPTIONS}\ndhandler" 148 | 149 | # check if single word 150 | if [ "$(echo "${prim}" | wc -w)" -eq 1 ]; then 151 | # if manpage exists 152 | man -w "${prim}" > /dev/null && OPTIONS="${OPTIONS}\nmanual" 153 | fi 154 | 155 | prompt="Plumb \"$(echo "${prim}" | awk ' NR==1' | cut -c -18)\" to?" 156 | 157 | func="$(printf "$OPTIONS" | awk 'NR>1' | ${LAUNCER} -p "${prompt}" -i -l 15)" 158 | 159 | [ -z "${func}" ] || "${func}" "${prim}" 160 | #vim:ft=sh 161 | -------------------------------------------------------------------------------- /tools/psave.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/sh 2 | 3 | ###################################################################### 4 | # @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) 5 | # @file : psave.sh 6 | # @created : Thu 05 Dec 2019 01:03:47 PM MST 7 | # 8 | # @description : This is a simple script used for managing power. 9 | # Simply set this as a cronjob (i have it run every 15 10 | # minutes). This script is specific to my thinkpad x200, I 11 | # tried to remove some of the stuff specific to me and left a 12 | # label where it used to be. 13 | # 14 | # @resources : If you want to learn more about how this script works and 15 | # other optimizations checkout these resources. 16 | # https://wiki.archlinux.org/index.php/CPU_frequency_scaling 17 | # https://wiki.archlinux.org/index.php/Power_management 18 | # 19 | # @WARNING : This script may conflict with other power managers on your 20 | # system such as tlp. This Script is very specific to my 21 | # machine so you will probably have to make some adjustments. 22 | ###################################################################### 23 | 24 | # manage power to usb ports 25 | 26 | wifiman(){ 27 | # Check for wifi and determines if it should start syncthing 28 | if ping -q -c 1 8.8.8.8; then 29 | syncthing -no-browser 2>&1 >/dev/null | xargs notify-send 30 | WIFI=$(nmcli connection show --active | sed '1d' | awk '{print $1}') 31 | 32 | # Only kill kdeconnect when using wifi that doesn't support it 33 | case ${WIFI} in 34 | Uvic ) 35 | killall kdeconnectd ;; 36 | ShawOpen ) 37 | killall kdeconnectd ;; 38 | *) 39 | # If on any other wifi start kdeconnect 40 | # Since kdeconnect isnt working comment it out 41 | # kdeconnect-cli -l;; 42 | esac 43 | else 44 | # If there is no wifi kill syncthing and kdeconnect 45 | killall syncthing 46 | # killall kdeconnectd 47 | fi 48 | } 49 | 50 | # This adjusts the maximum clock of the cpu depending on the current battery 51 | # percentage as well as if it is charging. If you have a more modern CPU I 52 | # highly recommend you use spcpugov instead. the numbers used for 53 | # scaling_max_freq should be adjusted based on the options available for your 54 | # computer. to find these stats use check the 55 | # /sys/devices/system/cpu/cpu1/cpufreq/scaling_available_frequencies. 56 | # double check that the BAT# is correct for your computer 57 | cpugov(){ 58 | full=$(cat /sys/class/power_supply/BAT0/energy_full) 59 | now=$(cat /sys/class/power_supply/BAT0/energy_now) 60 | state=$(cat /sys/class/power_supply/BAT0/status) 61 | [ "${state}" = Charging ] && echo ondemand | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor && \ 62 | echo 1867000 | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq && exit 63 | batt=$(echo "scale=2; 100*(${now}/${full})" | bc | cut -d"." -f1) 64 | [ "${batt}" -ge "80" ] && echo ondemand | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor && \ 65 | echo 1867000 | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq && exit 66 | [ "${batt}" -ge "35" ] && echo ondemand | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor && \ 67 | echo 1600000 | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq && exit 68 | echo powersave | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor && \ 69 | echo 1867000 | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq && exit 70 | } 71 | 72 | # This version of cpugov is works on more modern computers since intel_pstate 73 | # is more efficient then cpufreq but is only available in 'core i' series cpus 74 | # double check that the BAT# is correct for your computer 75 | spcpugov(){ 76 | full=$(cat /sys/class/power_supply/BAT1/energy_full) 77 | now=$(cat /sys/class/power_supply/BAT1/energy_now) 78 | state=$(cat /sys/class/power_supply/BAT1/status) 79 | [ "${state}" = Charging ] && echo 100 | sudo tee /sys/devices/system/cpu/intel_pstate/max_perf_pct && exit 80 | batt=$(echo "scale=2; 100*(${now}/${full})" | bc | cut -d"." -f1) 81 | [ "${batt}" -ge "80" ] && echo 80 | sudo tee /sys/devices/system/cpu/intel_pstate/max_perf_pct && exit 82 | [ "${batt}" -ge "35" ] && echo 50 | sudo tee /sys/devices/system/cpu/intel_pstate/max_perf_pct && exit 83 | echo 26 | sudo tee /sys/devices/system/cpu/intel_pstate/max_perf_pct && exit 84 | } 85 | 86 | # device=$(uname -n) 87 | wifiman "$1" 88 | # replace MODERN with the name of the system that should use spcpugov 89 | # [ "$device" = "MODERN" ] && spcpugov && exit 90 | # cpugov 91 | 92 | # vim: set tw=78 ts=2 et sw=2 sr: 93 | -------------------------------------------------------------------------------- /tools/compiler: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script will compile or run another finishing operation on a document. I 4 | # have this script run via Vim. 5 | # # tex files: Compiles to pdf, including bibliography if necessary 6 | # md files: Compiles to pdf via pandoc 7 | # rmd files: Compiles via R Markdown 8 | # c files: Compiles via whatever compiler is set to cc. Usually gcc. 9 | # Use make if Makefile exists. 10 | # py files: runs via python command 11 | # go files: compiles and runs with "go run" 12 | # config.h files: (For suckless utils) recompiles and installs program. 13 | # all others: run `sent` to show a presentation 14 | 15 | file=$(readlink -f "$1") 16 | dir=$(dirname "$file") 17 | base="${file%.*}" 18 | 19 | cd "$dir" || exit 20 | 21 | Ifinstalled() { 22 | command -v "$1" >/dev/null || { notify-send "📦 $1 must be installed for this function." && exit 1; } 23 | } 24 | 25 | textype() { 26 | command="pdflatex" 27 | errorfmt="-file-line-error" 28 | # ( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex" 29 | secdir="$(dirname "$dir")" 30 | cd "$secdir" 31 | if [ -f "${secdir}/Notes.tex" ]; then 32 | echo "${secdir}/Notes.tex" 33 | $command $errorfmt --output-directory="$secdir" "${secdir}/Notes.tex" 34 | exit 35 | fi 36 | $command $errorfmt --output-directory="$dir" "$base" 37 | grep -i addbibresource "$file" >/dev/null && 38 | biber --input-directory "$dir" "$base" && 39 | $command $errorfmt --output-directory="$dir" "$base" && 40 | $command $errorfmt --output-directory="$dir" "$base" 41 | } 42 | 43 | pandoccmd() { 44 | # Ifinstalled pdflatex && pandoc -V geometry:margin=4cm -f markdown-implicit_figures "$1" -o "${2}.pdf" 45 | Ifinstalled groff && pandoc "${1}" -t ms --pdf-engine-opt=-p -o "${2}.pdf" 46 | } 47 | 48 | pandocorg() { pandoccmd "$file" "$base"; } 49 | 50 | compilec() { 51 | if [ -f "${dir}/Makefile" ]; then 52 | make 53 | else 54 | clang "$file" -o "$base" && "$base" 55 | fi 56 | } 57 | 58 | neatroff_prefix='/opt/share/neatroff' 59 | 60 | case "$file" in 61 | *\.ms | *\.groff) preconv "$file" | groff -Tpdf -ktesp -ms >"$base".pdf ;; 62 | # *\.ms | *\.groff) 63 | # cat "$file"| 64 | # ${neatroff_prefix}/soin/soin | 65 | # ${neatroff_prefix}/troff/tbl/tbl | 66 | # ${neatroff_prefix}/troff/pic/pic | 67 | # ${neatroff_prefix}/neateqn/eqn | 68 | # ${neatroff_prefix}/neatroff/roff -men -mpost -mkeep -mfp | 69 | # ${neatroff_prefix}/neatpost/pdf > "$base".pdf && 70 | # killall -s SIGHUP mupdf;; 71 | *\.sh) bash "$file" ;; 72 | *\.ps) ps2pdf "$file" ;; 73 | *\.mom) pdfroff -pktes -b -wall -mom -mpdfmark "$file" >"$base".pdf ;; 74 | *\.present) groff -p -e -t -mm -mpresent "$file" | presentps -l | ps2pdf - >"$base".pdf ;; 75 | *\.me) groff -Gktes -b -w w -me -T ps "$file" | ps2pdf - >"$base".pdf ;; 76 | *\.mm) groff -Gktes -b -w w -mm -mpic -T ps "$file" | ps2pdf - >"$base".pdf ;; 77 | *\.tex) textype "$file" ;; 78 | *\.org) Ifinstalled pandoc && pandocorg "$file" "$base" && exit ;; 79 | *\.md) Ifinstalled pandoc && pandoccmd "$file" "$base" && exit ;; 80 | *config.h) make && sudo make install ;; 81 | *\.hs) runghc "$file" ;; 82 | *\.c) compilec ;; 83 | *\.cpp) 84 | g++ -std=c++26 \ 85 | -fconcepts-diagnostics-depth=2 \ 86 | -Wpedantic -Wall -Wconversion -Wextra \ 87 | -Wcast-align -Wcast-qual -Wctor-dtor-privacy \ 88 | -Wdisabled-optimization -Wformat=2 -Winit-self \ 89 | -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs \ 90 | -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls \ 91 | -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel \ 92 | -Wstrict-overflow=5 -Wswitch-default -Wundef \ 93 | -fsanitize=undefined -fsanitize=address \ 94 | -o "${base##*/}" "$file" && ./"${base##*/}" 95 | ;; 96 | *\.h) compilec ;; 97 | *\.r) R -f "$file" ;; 98 | *\.java) javac "$file" && java "${base##*/}" ;; 99 | *\.js) node "$file" ;; 100 | *\.py) python "$file" ;; 101 | *\.tcl) tclsh "$file" ;; 102 | *\.docx | *\.doc) 103 | Ifinstalled libreoffice && lowriter --convert-to pdf "$file" && exit 104 | Ifinstalled pandoc && pandoccmd "$file" "$base" && exit 105 | ;; 106 | *\.dot | *\.gv) dot -Tsvg "$file" | convert svg:- "$base".eps ;; 107 | *\.go) go run "$file" ;; 108 | *\.rs) rustc -o "${base##*/}" "$file" && ./"${base##*/}" ;; 109 | *\.vim*) vint "$file" ;; 110 | *\.sent) setsid sent "$file" 2>/dev/null & ;; 111 | *\.html) refreshbrowser ;; 112 | *\.rkt) racket "$file" ;; 113 | *\.apl) apl -f "$file" ;; 114 | *\.fnl) 115 | echo "fennel --compile "$file" > "$base".lua" 116 | fennel --compile "$file" >"$base".lua 117 | ;; 118 | *) chmod +x "$file" && sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;; 119 | esac 120 | # vim:ft=sh 121 | -------------------------------------------------------------------------------- /cl-menu.ros: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #|-*- mode:lisp -*-|# 3 | #| 4 | exec ros -Q -- $0 "$@" 5 | |# 6 | #| 7 | This is the simple beginings to a dmenu written in Common Lisp because 8 | some times C just isn't enough. 9 | 10 | WARNING: This is not at all complete or even functional. 11 | 12 | To run this simply install Roswell and make this file executable. 13 | 14 | Roswell installation instructions: 15 | https://roswell.github.io/Installation.html 16 | |# 17 | (progn ;;init forms 18 | (ros:ensure-asdf) 19 | #+quicklisp(ql:quickload '(clx) :silent t) 20 | ) 21 | 22 | (defpackage :ros.script.cl-menu.3849918680 23 | (:use :cl)) 24 | (in-package :ros.script.cl-menu.3849918680) 25 | (in-package :xlib) 26 | 27 | ;; TODO Add multi monitor support utilizing the display-number 28 | ;; TODO Handle user input 29 | ;; TODO Implement sorting algorithm 30 | ;; TODO Properly handle events and close display 31 | (declaim (optimize (speed 3) (safety 1))) 32 | 33 | (defstruct (menu (:constructor create-menu (prompt font text window gcontext))) 34 | (prompt ">" :type string :read-only t) 35 | (font nil :type font :read-only t) 36 | (text "" :type string) 37 | (window nil :type window) 38 | (gcontext nil :type gcontext)) 39 | 40 | (defun h-center-of-monitor (display) 41 | (let ((screen (display-default-screen display)) 42 | (monitor-x (xlib/xinerama:screen-info-x 43 | (car (xlib/xinerama::xinerama-query-screens display))))) 44 | (truncate (+ monitor-x (screen-width screen)) 45 | 2))) 46 | 47 | (defun get-text-width (font border text) 48 | (+ (text-width font text) (* 2 border))) 49 | 50 | (defun get-text-height (font border) 51 | (+ (max-char-ascent font) 52 | (max-char-descent font) (* 2 border))) 53 | 54 | (declaim (ftype (function (string string display &optional string) menu) make-menu)) 55 | (defun make-menu (text prompt display &optional (font-name "fixed")) 56 | (progn 57 | (print display) 58 | (let* ((screen (display-default-screen display)) 59 | (font (open-font display font-name)) 60 | (border 1) 61 | (x (h-center-of-monitor display)) 62 | (y 0) 63 | (bg (screen-black-pixel screen)) 64 | (fg (screen-white-pixel screen)) 65 | (win (create-window :parent (screen-root screen) 66 | ;; :override-redirect :on 67 | :save-under :on 68 | :x x :y y 69 | :width (get-text-width font border text) :height (get-text-height font border) 70 | :background bg 71 | :border fg 72 | :border-width border 73 | :colormap (screen-default-colormap screen) 74 | :bit-gravity :center 75 | :event-mask (make-event-mask :exposure 76 | :key-press 77 | :key-release 78 | :button-press 79 | ))) 80 | (gcontext (create-gcontext :drawable win 81 | :background bg 82 | :foreground fg 83 | :font font))) 84 | (create-menu 85 | prompt 86 | font 87 | text 88 | win 89 | gcontext)))) 90 | 91 | (declaim (ftype (function (menu display) t) display-menu)) 92 | (defun display-menu (menu display) 93 | (progn 94 | (let ((font (menu-font menu)) 95 | (text (menu-text menu)) 96 | (width (get-text-width (menu-font menu) 1 (menu-text menu))) 97 | (gcontext (menu-gcontext menu))) 98 | (map-window (menu-window menu)) 99 | ;; (loop for ev = (process-event display :handler 100 | ;; (lambda (&rest event-slots 101 | ;; &key event-key 102 | ;; &allow-other-keys) 103 | ;; (case event-key 104 | ;; ((or :key-release :key-press) 105 | ;; "hello"))) 106 | ;; :timeout nil) 107 | ;; do (print ev)) 108 | (event-case (display ;; :discard-p t :force-output-p t 109 | ) 110 | (:key-press () 111 | t) 112 | (:exposure ;; Come here on exposure events 113 | (window count) 114 | (when (zerop count) ;; Ignore all but the last exposure event 115 | (with-state (window) 116 | (let ((x (truncate (- (drawable-width window) width) 2)) 117 | (y (truncate (- (+ (drawable-height window) 118 | (max-char-ascent font)) 119 | (max-char-descent font)) 120 | 2))) 121 | ;; Draw text centered in window 122 | (clear-area window) 123 | (draw-glyphs window gcontext x y text))) 124 | ;; Returning non-nil causes event-case to exit 125 | nil)) 126 | (:button-press () t)) 127 | ) ;; exit event-case 128 | (when display 129 | (close-display display :abort nil)))) 130 | 131 | (declaim (ftype (function (string string &optional string) t) cl-menu)) 132 | (defun cl-menu (text prompt &optional (font-name "fixed")) 133 | "Start cl-menu on HOST with STRING in FONT " 134 | (let ((display (open-display 135 | (car (get-default-display))))) 136 | (display-menu (make-menu text prompt display) 137 | display))) 138 | 139 | (defun main (&rest argv) 140 | (declare (ignorable argv)) 141 | (cl-menu "hello world" "> ")) 142 | ;;; vim: set ft=lisp lisp: 143 | -------------------------------------------------------------------------------- /tools/tpb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # demo: https://www.youtube.com/watch?v=IY56U1L6FCI 3 | # source: https://github.com/saironiq/shellscripts 4 | # 5 | # by Sairon Istyar, 2012 6 | # distributed under the GPLv3 license 7 | # http://www.opensource.org/licenses/gpl-3.0.html 8 | # 9 | 10 | ### CONFIGURATION ### 11 | # program to use for torrent download 12 | # magnet link to torrent will be appended 13 | # you can add -- at the end to indicate end of options 14 | # (if your program supports it, most do) 15 | program='/home/gavinok/.scripts/tools/transadd' 16 | TPB="https://proxtpb.art/" 17 | 18 | # show N first matches by default 19 | limit=25 20 | 21 | # colors 22 | # numbcolor='' 23 | # namecolor='' 24 | # sizecolor='' 25 | # seedcolor='' 26 | # peercolor='' 27 | # errocolor='' 28 | # mesgcolor='' 29 | # nonecolor='' 30 | numbcolor='\x1b[1;35m' 31 | namecolor='\x1b[1;33m' 32 | sizecolor='\x1b[1;36m' 33 | seedcolor='\x1b[1;31m' 34 | peercolor='\x1b[1;32m' 35 | errocolor='\x1b[1;31m' 36 | mesgcolor='\x1b[1;37m' 37 | nonecolor='\x1b[0m' 38 | 39 | # default ordering method 40 | # 1 - name ascending; 2 - name descending; 41 | # 3 - recent first; 4 - oldest first; 42 | # 5 - size descending; 6 - size ascending; 43 | # 7 - seeds descending; 8 - seeds ascending; 44 | # 9 - leechers descending; 10 - leechers ascending; 45 | orderby=7 46 | ### END CONFIGURATION ### 47 | 48 | thisfile="$0" 49 | 50 | printhelp() { 51 | echo -e "Usage:" 52 | echo -e "\t$thisfile [options] search query" 53 | echo 54 | echo 55 | echo -e "Available options:" 56 | echo -e "\t-h\t\tShow help" 57 | echo -e "\t-n [num]\tShow only first N results (default 15; max 100 [top] or 30 [search])" 58 | echo -e "\t-C\t\tDo not use colors" 59 | echo -e "\t-P [prog]\tSet torrent client command (\`-P torrent-client\` OR \`-P \"torrent-client --options\"\`)" 60 | echo 61 | echo -e "Current client settings: $program [magnet link]" 62 | } 63 | 64 | # change torrent client 65 | chex() { 66 | sed "s!^program=.*!program=\'$program\'!" -i "$thisfile" 67 | if [ $? -eq 0 ] ; then 68 | echo "Client changed successfully." 69 | exit 0 70 | else 71 | echo -e "${errocolor}(EE) ${mesgcolor}==> Something went wrong!${nonecolor}" 72 | exit 1 73 | fi 74 | } 75 | 76 | # script cmdline option handling 77 | while getopts :hn:CP:: opt ; do 78 | case "$opt" in 79 | h) printhelp; exit 0;; 80 | n) limit="$OPTARG";; 81 | C) unset numbcolor namecolor sizecolor seedcolor peercolor nonecolor errocolor mesgcolor;; 82 | P) program="$OPTARG"; chex;; 83 | *) echo -e "Unknown option(s)."; printhelp; exit 1;; 84 | esac 85 | done 86 | 87 | shift `expr $OPTIND - 1` 88 | 89 | # correctly encode query 90 | q=`echo "$*" | tr -d '\n' | od -t x1 -A n | tr ' ' '%'` 91 | 92 | # if not searching, show top torrents 93 | if [ -z "$q" ] ; then 94 | url="top/all" 95 | else 96 | url='search/'"$q"'/0/'"$orderby"'/0' 97 | fi 98 | 99 | # get results 100 | # Here be dragons! 101 | r=`curl -k -A Mozilla -b "lw=s" -m 15 -s "$TPB/$url" \ 102 | | grep -Eo '^]*>.*|^[^<]*' \ 103 | | sed 's!^]*>!!; \ 104 | s!$!!; \ 105 | s!^]*>!!; \ 107 | s! !\ !g; \ 108 | s/|/!/g' \ 109 | | sed 'N;N;N;N;s!\n!|!g'` 110 | 111 | # number of results 112 | n=`echo "$r" | wc -l` 113 | 114 | IFS=$'\n' 115 | 116 | # print results 117 | echo "$r" \ 118 | | head -n "$limit" \ 119 | | awk -v N=1 \ 120 | -v NU="$numbcolor" \ 121 | -v NA="$namecolor" \ 122 | -v SI="$sizecolor" \ 123 | -v SE="$seedcolor" \ 124 | -v PE="$peercolor" \ 125 | -v NO="$nonecolor" \ 126 | -F '|' \ 127 | '{print NU N ") " NA $1 " " SI $3 " " SE $4 " " PE $5 NO; N++}' 128 | 129 | # read ID(s), expand ranges, ignore everything else 130 | read -p ">> Torrents to download (eg. 1 3 5-7): " selection 131 | IFS=$'\n\ ' 132 | for num in $selection ; do 133 | if [ "$num" = "`echo "$num" | grep -o '[[:digit:]][[:digit:]]*'`" ] ; then 134 | down="$down $num" 135 | elif [ "$num" = "`echo "$num" | grep -o '[[:digit:]][[:digit:]]*-[[:digit:]][[:digit:]]*'`" ] ; then 136 | seqstart="${num%-*}" 137 | seqend="${num#*-}" 138 | if [ "$seqstart" -le "$seqend" ] ; then 139 | down=""$down" `seq "$seqstart" "$seqend"`" 140 | fi 141 | fi 142 | done 143 | 144 | # normalize download list, sort it and remove dupes 145 | down="$(echo "$down" | tr '\ ' '\n' | sort -n | uniq)" 146 | IFS=$'\n' 147 | 148 | # check whether we're downloading something, else exit 149 | if [ -z "$down" ] ; then 150 | exit 0 151 | fi 152 | 153 | # download all torrents in list 154 | echo -n "Downloading torrent(s): " 155 | for torrent in $down ; do 156 | # check if ID is valid and in range of results, download torrent 157 | if [ "$torrent" -ge 1 ] ; then 158 | if [ "$torrent" -le "$limit" ] ; then 159 | echo -n "$torrent " 160 | command=""$program" `echo "$r" | awk -F '|' 'NR=='$torrent'{print $2; exit}'`" 161 | status=$(eval "$command" 2>&1) 162 | if [ $? -ne 0 ] ; then 163 | echo -n '(failed!) ' 164 | report=""$report"\n(#$torrent) $status" 165 | fi 166 | fi 167 | fi 168 | done 169 | echo 170 | if [ -n "$report" ] ; then 171 | echo -n "Exited with errors:" 172 | echo -e "$report" 173 | fi 174 | unset IFS 175 | # vim:ft=sh 176 | -------------------------------------------------------------------------------- /dmenu/tutorialvids: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # LAUNCER="dmenu -i -l 20 -p " 4 | LAUNCER="emenu -p " 5 | [ -z "${DISPLAY}" ] && LAUNCER="fzf --prompt" 6 | 7 | vidlist=" 8 | Bash script https://www.youtube.com/watch?v=YOpeXETS2z0&t=192s 9 | Bash script full https://www.youtube.com/watch?v=oxuRxtrO2Ag 10 | dmenu script https://www.youtube.com/watch?v=R9m723tAurA 11 | status bar https://www.youtube.com/watch?v=gKumet6b-WY 12 | mutt https://www.youtube.com/watch?v=2U3vRbF7v5A 13 | ncmpcpp https://www.youtube.com/watch?v=sZIEdI9TS2U 14 | newsboat https://www.youtube.com/watch?v=dUFCRqs822w 15 | ranger https://www.youtube.com/watch?v=L6Vu7WPkoJo 16 | gpg keys https://www.youtube.com/watch?v=DMGIlj7u7Eo 17 | urlview https://www.youtube.com/watch?v=IgzpAjFgbCw 18 | ncurses https://www.youtube.com/watch?v=2tWN6ntNo4w 19 | SQL https://www.youtube.com/watch?v=bEtnYWuo2Bw 20 | SQL Full https://www.youtube.com/watch?v=HXV3zeQKqGY&t=4342s 21 | C programming https://www.youtube.com/watch?v=2NWeucMKrLI&index=1&list=PL6gx4Cwl9DGAKIXv8Yr6nhGJ9Vlcjyymq 22 | C File I/O https://www.youtube.com/watch?v=-LqUMHoBo6o 23 | C Error Handling https://www.youtube.com/watch?v=IZiUT-ipnj0 24 | install latex https://www.youtube.com/watch?v=NwnYHoNtfJ0 25 | Latex all https://m.youtube.com/watch?v=VhmkLrOjLsw 26 | Latex1 https://www.youtube.com/watch?v=mfRmmZ_84Mw&t=2s 27 | Latex2 https://www.youtube.com/watch?v=25LExaNtdF0 28 | Latex bib https://www.youtube.com/watch?v=46piog3Fzp4 29 | Latex Resume https://www.youtube.com/watch?v=VjsX4tznW40&t=570s 30 | Latex Resume2 https://www.youtube.com/watch?v=o5-BZ7JmYWk 31 | Latex Images https://www.youtube.com/watch?v=zgThRPjy-vw 32 | Latex Macros https://www.youtube.com/watch?v=rvgP7IMeUn8 33 | Latex and vim https://www.youtube.com/watch?v=yNOkCYuPt3E 34 | Python https://www.youtube.com/watch?v=rfscVS0vtbw&t=2s 35 | JSON https://www.youtube.com/watch?v=wI1CWzNtE-M 36 | JavaScript https://www.youtube.com/watch?v=W6NZfCO5SIk 37 | Go 7 hour Course https://www.youtube.com/watch?v=YS4e4q9oBaU&t=2h19m0s 38 | Regex https://www.youtube.com/watch?v=vcRPNhLbhoc 39 | Game Dev in C https://www.youtube.com/watch?v=yFLa3ln16w0&t=556s 40 | Red Hat Linux Course complete https://www.youtube.com/watch?v=oflN6WZOzxw 41 | Full ArchLinux Install https://www.youtube.com/watch?v=4PBqpX0_UOc&t=1473s 42 | Power of Unix https://www.youtube.com/watch?v=7uwW20odwEk 43 | Manjaro Architect https://www.youtube.com/watch?v=530O4InhR3A 44 | POSIX pthreads https://www.youtube.com/watch?v=ynCc-v0K-do&list=PLzCAxcRKUAgkc65DlRo0gr0B8sqlE6WZY 45 | groff https://www.youtube.com/watch?v=w8EKH_fjmXA 46 | groff Macros and Others https://www.youtube.com/watch?v=kJ_TXZB4Gm4 47 | groff refer https://www.youtube.com/watch?v=XfOwRYmb5bQ&list=PL-p5XmQHB_JRe2YeaMjPTKXSc5FqJZ_km&index=4&t=0s 48 | groff auto refer https://www.youtube.com/watch?v=yTQbi_E_Gys&list=PL-p5XmQHB_JRe2YeaMjPTKXSc5FqJZ_km&index=4 49 | eqn groff https://www.youtube.com/watch?v=sp0qgpeG6EY 50 | rclone https://www.youtube.com/watch?v=G8YMspboIXs 51 | Arch Linux Maintenance https://www.youtube.com/watch?v=3BnHHP7Fmo0 52 | Awk https://www.youtube.com/watch?v=_q6Uj4X_knc 53 | Hacking with Vim https://www.youtube.com/watch?v=l8iXMgk2nnY 54 | mutt isync https://www.youtube.com/watch?v=tR9zk3xz5SA 55 | ffmpeg screen casting https://www.youtube.com/watch?v=386Z2yeQ5fo 56 | installing fonts https://www.youtube.com/watch?v=LJ7CEhnS0OM 57 | cs50 Beyond javascript https://www.youtube.com/watch?v=dlEPkLSDQi0&t=51s 58 | cs50 Beyond javascript continued https://www.youtube.com/watch?v=XNDZ3eg_VcE&t=319s 59 | spotifyd https://www.youtube.com/watch?v=R5jikGfSdh4 60 | hugo netlify github pages https://www.youtube.com/watch?v=NSts93C9UeE 61 | Lua https://www.youtube.com/watch?v=iMacxZQMPXs 62 | Gnu Parallel https://www.youtube.com/playlist?list=PL284C9FF2488BC6D1 63 | Curl for REST APIs https://www.youtube.com/watch?v=czeIHABQCxo 64 | ImageMagick transparency https://www.youtube.com/watch?v=D8pcvkRsx1g&t=300s 65 | ImageMagick Canvases, Plasma, Composites, Geometry https://www.youtube.com/watch?v=nbXHbHrfrIs 66 | hub https://www.youtube.com/watch?v=xWbaKNFAh8Y 67 | valgrind https://www.youtube.com/watch?v=bb1bTJtgXrI 68 | pass https://www.youtube.com/watch?v=sVkURNfxPd4 69 | discord bridge https://www.youtube.com/watch?v=xIOyc4Rklqc&t=317s 70 | " 71 | 72 | pdfs=" 73 | pic for image drawing PDF http://floppsie.comp.glam.ac.uk/Glamorgan/gaius/web/pic.html 74 | pic Revised User Manual PDF http://doc.cat-v.org/unix/v8/picmemo.pdf 75 | tbl PDF http://doc.cat-v.org/unix/v10/10thEdMan/tbl.pdf 76 | eqn PDF http://www.kohala.com/start/troff/v7man/eqn/eqn2e.ps 77 | refer PDF http://www.kohala.com/start/troff/v7man/refer/refer.ps 78 | grap PDF http://doc.cat-v.org/unix/v8/grap.pdf 79 | unix text processing (utp) PDF https://github.com/larrykollar/Unix-Text-Processing/releases/download/1.0/utp-1.0.pdf 80 | pdf manipulation in groff with pdfmark PDF http://pipeline.lbl.gov/code/3rd_party/licenses.win/groff/1.19.2/pdf/pdfmark.pdf 81 | pdfmark.ms PDF http://git.savannah.gnu.org/cgit/groff.git/plain/contrib/pdfmark/pdfmark.ms 82 | general troff tutorial PDF http://www.kohala.com/start/troff/v7man/trofftut/trofftut.ps 83 | Troff User Manual PDF http://doc.cat-v.org/plan_9/4th_edition/papers/troff.pdf 84 | Groff and Friends HOWTO PDF https://www.troff.org/TheGroffFriendsHowto.pdf 85 | mom macros PDF http://www.schaffter.ca/mom/pdf/mom-pdf.pdf 86 | ms macros PDF http://www.kohala.com/start/troff/v7man/msmacros/msmacros.ps 87 | " 88 | tutorials=" 89 | ${vidlist} 90 | ${pdfs} 91 | " 92 | 93 | # TODO: grep for youtube to determin if it should use ytplay or xdg-open 94 | if command -v www >/dev/null; then 95 | Player='www' 96 | else 97 | Player='xdg-open' 98 | fi 99 | echo "${tutorials}" | grep -P "^$(echo "${tutorials}" | grep "https\?:" | sed 's/\t.*//g' | ${LAUNCER} "Learn about what?" | cut -f1)\t" | sed 's/.*\t//' | xargs -r ${Player} 100 | #vim:ft=sh 101 | -------------------------------------------------------------------------------- /dwm/colortheme: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | version="0.1.0" 5 | slroot=~ 6 | 7 | die() { 8 | printf '%s \n' "$1" >&2 9 | exit 1 10 | } 11 | 12 | show_help() { 13 | echo "usage: ${0##*/} [OPTION] THEMEFILE" 14 | echo "Writes colors from THEMEFILE to:" 15 | echo " ~/.Xresources" 16 | # echo " $slroot/st/config.h" 17 | # echo " $slroot/tabbed/config.h" 18 | # echo " $slroot/dwm/config.h" 19 | echo "Valid OPTIONS are:" 20 | echo " -h, --help show this message" 21 | echo " -v, --version show version information" 22 | } 23 | 24 | show_version() { 25 | echo "${0##*/} version $version" 26 | echo "Licensed under GNU Public License v3+" 27 | echo "Written by Anders Damsgaard " 28 | } 29 | 30 | get_theme_color() { 31 | ! [ -f "$path" ] && die "Error: Could not find $path" 32 | grep --ignore-case "^\*\.*$1:" "$path" | awk '{ print $2 }' 33 | } 34 | 35 | report_colors() { 36 | echo "foreground: $foreground" 37 | echo "background: $background" 38 | echo "color0: $color0" 39 | echo "color1: $color1" 40 | echo "color2: $color2" 41 | echo "color3: $color3" 42 | echo "color4: $color4" 43 | echo "color5: $color5" 44 | echo "color6: $color6" 45 | echo "color7: $color7" 46 | echo "color8: $color8" 47 | echo "color9: $color9" 48 | echo "color10: $color10" 49 | echo "color11: $color11" 50 | echo "color12: $color12" 51 | echo "color13: $color13" 52 | echo "color14: $color14" 53 | echo "color15: $color15" 54 | echo "cursorColor: $cursorColor" 55 | } 56 | 57 | get_colors() { 58 | path="$1" 59 | ! [ -f "$path" ] && die "Error: Could not find $path" 60 | foreground=$(get_theme_color foreground) 61 | background=$(get_theme_color background) 62 | echo $background 63 | color0=$(get_theme_color color0) 64 | color1=$(get_theme_color color1) 65 | color2=$(get_theme_color color2) 66 | color3=$(get_theme_color color3) 67 | color4=$(get_theme_color color4) 68 | color5=$(get_theme_color color5) 69 | color6=$(get_theme_color color6) 70 | color7=$(get_theme_color color7) 71 | color8=$(get_theme_color color8) 72 | color9=$(get_theme_color color9) 73 | color10=$(get_theme_color color10) 74 | color11=$(get_theme_color color11) 75 | color12=$(get_theme_color color12) 76 | color13=$(get_theme_color color13) 77 | color14=$(get_theme_color color14) 78 | color15=$(get_theme_color color15) 79 | cursorColor=$(get_theme_color cursorColor) 80 | cursorColor=${cursorColor:-#FF00FF} 81 | 82 | if [ "$foreground" = "" ] || \ 83 | [ "$background" = "" ] || \ 84 | [ "$color0" = "" ] || \ 85 | [ "$color1" = "" ] || \ 86 | [ "$color2" = "" ] || \ 87 | [ "$color3" = "" ] || \ 88 | [ "$color4" = "" ] || \ 89 | [ "$color5" = "" ] || \ 90 | [ "$color6" = "" ] || \ 91 | [ "$color7" = "" ] || \ 92 | [ "$color8" = "" ] || \ 93 | [ "$color9" = "" ] || \ 94 | [ "$color10" = "" ] || \ 95 | [ "$color11" = "" ] || \ 96 | [ "$color12" = "" ] || \ 97 | [ "$color13" = "" ] || \ 98 | [ "$color14" = "" ] || \ 99 | [ "$color15" = "" ] || \ 100 | [ "$cursorColor" = "" ]; then 101 | 102 | report_colors 103 | die 'Error: One or more colors were not defined' 104 | fi 105 | } 106 | 107 | set_colors() { 108 | get_colors "$1" 109 | 110 | if [ -f ~/.Xresources ]; then 111 | sed -i "s/^\*\.foreground: .*$/\*.foreground: $foreground/;\ 112 | s/^\*\.background: .*$/\*.background: $background/;\ 113 | s/^\*\.color0: .*$/\*.color0: $color0/;\ 114 | s/^\*\.color1: .*$/\*.color1: $color1/;\ 115 | s/^\*\.color2: .*$/\*.color2: $color2/;\ 116 | s/^\*\.color3: .*$/\*.color3: $color3/;\ 117 | s/^\*\.color4: .*$/\*.color4: $color4/;\ 118 | s/^\*\.color5: .*$/\*.color5: $color5/;\ 119 | s/^\*\.color6: .*$/\*.color6: $color6/;\ 120 | s/^\*\.color7: .*$/\*.color7: $color7/;\ 121 | s/^\*\.color8: .*$/\*.color8: $color8/;\ 122 | s/^\*\.color9: .*$/\*.color9: $color9/;\ 123 | s/^\*\.color10: .*$/\*.color10: $color10/;\ 124 | s/^\*\.color11: .*$/\*.color11: $color11/;\ 125 | s/^\*\.color12: .*$/\*.color12: $color12/;\ 126 | s/^\*\.color13: .*$/\*.color13: $color13/;\ 127 | s/^\*\.color14: .*$/\*.color14: $color14/;\ 128 | s/^\*\.color15: .*$/\*.color15: $color15/;\ 129 | s/^\*\.cursorColor: .*$/\*.cursorColor: $cursorColor/" ~/.Xresources 130 | xrdb -merge ~/.Xresources 131 | command -v i3-msg >/dev/null 2>&1 && (i3-msg restart || :) 132 | command -v wallpaper >/dev/null 2>&1 && (wallpaper || :) 133 | fi 134 | 135 | # if [ -f $slroot/st/config.h ]; then 136 | # sed -i "s/^\t\[257\] = \".*\",.*$/\t\[257\] = \"$foreground\",/;\ 137 | # s/^\t\[256\] = \".*\",.*$/\t\[256\] = \"$background\",/;\ 138 | # s/^\t\[0\] = \".*\",.*$/\t\[0\] = \"$color0\",/;\ 139 | # s/^\t\[1\] = \".*\",.*$/\t\[1\] = \"$color1\",/;\ 140 | # s/^\t\[2\] = \".*\",.*$/\t\[2\] = \"$color2\",/;\ 141 | # s/^\t\[3\] = \".*\",.*$/\t\[3\] = \"$color3\",/;\ 142 | # s/^\t\[4\] = \".*\",.*$/\t\[4\] = \"$color4\",/;\ 143 | # s/^\t\[5\] = \".*\",.*$/\t\[5\] = \"$color5\",/;\ 144 | # s/^\t\[6\] = \".*\",.*$/\t\[6\] = \"$color6\",/;\ 145 | # s/^\t\[7\] = \".*\",.*$/\t\[7\] = \"$color7\",/;\ 146 | # s/^\t\[8\] = \".*\",.*$/\t\[8\] = \"$color8\",/;\ 147 | # s/^\t\[9\] = \".*\",.*$/\t\[9\] = \"$color9\",/;\ 148 | # s/^\t\[10\] = \".*\",.*$/\t\[10\] = \"$color10\",/;\ 149 | # s/^\t\[11\] = \".*\",.*$/\t\[11\] = \"$color11\",/;\ 150 | # s/^\t\[12\] = \".*\",.*$/\t\[12\] = \"$color12\",/;\ 151 | # s/^\t\[13\] = \".*\",.*$/\t\[13\] = \"$color13\",/;\ 152 | # s/^\t\[14\] = \".*\",.*$/\t\[14\] = \"$color14\",/;\ 153 | # s/^\t\[258\] = \".*\",.*$/\t\[258\] = \"$cursorColor\",/"\ 154 | # $slroot/st/config.h 155 | # fi 156 | 157 | # if [ -f $slroot/tabbed/config.h ]; then 158 | # sed -i "s/normbgcolor \+= \".*\";/normbgcolor = \"$background\";/;\ 159 | # s/normfgcolor \+= \".*\";/normfgcolor = \"$foreground\";/;\ 160 | # s/selfgcolor \+= \".*\";/selfgcolor = \"$background\";/;\ 161 | # s/selbgcolor \+= \".*\";/selbgcolor = \"$foreground\";/;\ 162 | # s/urgbgcolor \+= \".*\";/urgbgcolor = \"$color9\";/;\ 163 | # s/urgfgcolor \+= \".*\";/urgfgcolor = \"$color0\";/"\ 164 | # $slroot/tabbed/config.h 165 | # fi 166 | 167 | 168 | if [ -f $slroot/dwm/config.h ]; then 169 | sed -i "s/col_gray4\[\] *= \".*\";/col_gray4\[\] = \"$background\";/;\ 170 | s/col_cyan\[\] *= \".*\";/col_cyan\[\] = \"$color6\";/;\ 171 | s/col_gray3\[\] *= \".*\";/col_gray3\[\] = \"$foreground\";/;\ 172 | s/col_gray1\[\] *= \".*\";/col_gray1\[\] = \"$background\";/;"\ 173 | $slroot/dwm/config.h 174 | fi 175 | 176 | } 177 | 178 | [ $# -lt 1 ] && (show_help && exit 1) 179 | 180 | while :; do 181 | case "$1" in 182 | -h|-\?|--help) 183 | show_help 184 | exit 0 185 | ;; 186 | -v|--version) 187 | show_version 188 | exit 0 189 | ;; 190 | --) # end all options 191 | shift 192 | break 193 | ;; 194 | -?*) 195 | die "Error: Unknown option '$1' specified" 196 | ;; 197 | *) # no more options 198 | break 199 | esac 200 | shift 201 | done 202 | 203 | [ $# -lt 1 ] && die 'Error: No THEMEFILE specified' 204 | [ $# -gt 1 ] && die 'Error: More than one THEMEFILE specified' 205 | 206 | set_colors "$1" 207 | #vim:ft=sh 208 | -------------------------------------------------------------------------------- /dmenu/dmenu_kdeconnect.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # dmenu_kdeconnect.sh is a script based off of these scripts 3 | # [polybar-kdeconnect] https://github.com/HackeSta/polybar-kdeconnect 4 | # [polybar-kdeconnect-scripts] https://github.com/witty91/polybar-kdeconnect-scripts 5 | # Added features 6 | # - Removed polybar as a Dependencies (since I use dwm) 7 | # - Integration with a variety of file managers 8 | # - Implementation as one simplified shell script 9 | # - utilize sh instead of bash 10 | 11 | #TODO 12 | # 1. Allow different dmenu colors based on the battery percentage 13 | # 2. Make the script no sh complaint 14 | # 3. Implement a contacts list to make sms messaging easier 15 | 16 | # Dependancies 17 | # -dmenu 18 | # -kdeconnect 19 | # -zenity, nnn, or ranger 20 | # -qt5-tools 21 | # -dbus 22 | # -dunst 23 | 24 | # options 25 | # nnn 26 | # zenity 27 | # ranger 28 | Picker='zenity' 29 | 30 | # Color Settings of dmenu 31 | COLOR_DISCONNECTED='#000' # Device Disconnected 32 | COLOR_NEWDEVICE='#ff0' # New Device 33 | COLOR_BATTERY_90='#fff' # Battery >= 90 34 | COLOR_BATTERY_80='#ccc' # Battery >= 80 35 | COLOR_BATTERY_70='#aaa' # Battery >= 70 36 | COLOR_BATTERY_60='#888' # Battery >= 60 37 | COLOR_BATTERY_50='#666' # Battery >= 50 38 | COLOR_BATTERY_LOW='#f00' # Battery < 50 39 | 40 | # Icons shown in dmenu 41 | ICON_SMARTPHONE='' 42 | ICON_TABLET='' 43 | SEPERATOR='|' 44 | 45 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 46 | 47 | ping -q -c 1 1.1.1.1 > /dev/null || "$(notify-send "check internet connection" && exit)" 48 | 49 | show_devices (){ 50 | IFS=$',' 51 | devices="" 52 | # for all the devices avalable 53 | for device in $(qdbus --literal org.kde.kdeconnect /modules/kdeconnect org.kde.kdeconnect.daemon.devices); do 54 | #get the device info 55 | deviceid=$(echo "$device" | awk -F'["|"]' '{print $2}') 56 | devicename=$(qdbus org.kde.kdeconnect /modules/kdeconnect/devices/$deviceid org.kde.kdeconnect.device.name) 57 | devicetype=$(qdbus org.kde.kdeconnect /modules/kdeconnect/devices/$deviceid org.kde.kdeconnect.device.type) 58 | isreach="$(qdbus org.kde.kdeconnect /modules/kdeconnect/devices/$deviceid org.kde.kdeconnect.device.isReachable)" 59 | istrust="$(qdbus org.kde.kdeconnect /modules/kdeconnect/devices/$deviceid org.kde.kdeconnect.device.isTrusted)" 60 | if [ "$isreach" = "true" ] && [ "$istrust" = "true" ];then 61 | #is connected 62 | battery="$(qdbus org.kde.kdeconnect /modules/kdeconnect/devices/$deviceid org.kde.kdeconnect.device.battery.charge)%" 63 | icon=$(get_icon $battery $devicetype) 64 | # colors="$(get_colors $battery)" 65 | # echo "$colors" 66 | show_menu "$devicename | $battery $icon" $deviceid $battery 67 | devices+="$devicename $battery $icon $SEPERATOR" 68 | elif [ "$isreach" = "false" ] && [ "$istrust" = "true" ];then 69 | #nothing is found 70 | devices+="$(get_icon -1 $devicetype)$SEPERATOR" 71 | else 72 | #found but not yet paired 73 | icon=$(get_icon -2 $devicetype) 74 | show_pmenu $devicename $deviceid 75 | devices+="$devicename $icon $SEPERATOR" 76 | fi 77 | done 78 | } 79 | 80 | SendKeys(){ 81 | output="?" 82 | TEMPFILE=/tmp/VimFloat 83 | > $TEMPFILE 84 | st -t "vim-anywhere" -n 'popup' -e "${EDITOR:-vi}" -c 'startinsert' $TEMPFILE 85 | xsel -i < $TEMPFILE 86 | output=$(xsel -o) 87 | notify-send "$output" 88 | kdeconnect-cli --device "$*" -k "$output" 89 | } 90 | 91 | #used to interact with notifications if they are avalable 92 | Notification_menu () { 93 | replyable=`qdbus org.kde.kdeconnect /modules/kdeconnect/devices/$2/notifications/$1 org.kde.kdeconnect.device.notifications.notification.replyId` 94 | echo $replyable 95 | options=$(printf "View\\nDissmiss") 96 | if [ "$replyable" ]; then 97 | options+=$(printf "\\nReply") 98 | optionNum=$((optionNum+1)) 99 | fi 100 | ticker1=`qdbus org.kde.kdeconnect /modules/kdeconnect/devices/$2/notifications/$1 org.kde.kdeconnect.device.notifications.notification.ticker` 101 | prompt=$(echo $ticker1 | cut -c 1-100) 102 | menu=$(echo $options | dmenu -i -p "$prompt" -l $optionNum ) 103 | case "$menu" in 104 | *'View' ) 105 | ticker1=`qdbus org.kde.kdeconnect /modules/kdeconnect/devices/$2/notifications/$1 org.kde.kdeconnect.device.notifications.notification.ticker` 106 | notify-send "$ticker1";; 107 | *'Dissmiss') 108 | qdbus org.kde.kdeconnect /modules/kdeconnect/devices/$2/notifications/$1 org.kde.kdeconnect.device.notifications.notification.dismiss;; 109 | *'Reply' ) 110 | qdbus org.kde.kdeconnect /modules/kdeconnect/devices/$2/notifications/$1 org.kde.kdeconnect.device.notifications.notification.reply;; 111 | esac 112 | } 113 | 114 | #displays a menu for the connected device 115 | show_menu () { 116 | optionNum=5 117 | options=$(printf "Send SMS\\nSend File\\nFind Device\\nPing\\nUnpair\\nkeys\\n") 118 | notification1=`dbus-send --session --print-reply --dest="org.kde.kdeconnect" /modules/kdeconnect/devices/$2 org.kde.kdeconnect.device.notifications.activeNotifications|tr '\n' ' ' | awk '{print $12}'| sed s/\"//g` 119 | if [ $notification1 ]; then 120 | options+=$(printf "\\nNotification") 121 | optionNum=$((optionNum+1)) 122 | fi 123 | options+=$(printf "\\nRefresh\\n") 124 | menu=$(echo $options | dmenu -i -p $1 -l $optionNum ) 125 | case "$menu" in 126 | *'Ping') 127 | message=$(echo 'Ping' | dmenu -i -p "Msg to send") 128 | kdeconnect-cli --ping-msg "$message" -d $2;; 129 | *'Find Device') kdeconnect-cli --ring -d $2 ;; 130 | *'Send File') 131 | [ $Picker == 'nnn' ] && kdeconnect-cli --share "file://$($TERMINAL nnn -p -)" -d $2 ; 132 | [ $Picker == 'zenity' ] && kdeconnect-cli --share "file://$(zenity --file-selection)" -d $2 ; 133 | if [ $Picker == 'ranger' ]; then 134 | mkdir -p /tmp/ranger/ && touch /tmp/ranger/sentfile 135 | kdeconnect-cli --share "file://$($TERMINAL ranger --choosefile=/tmp/ranger/sentfile)" -d $2 136 | fi;; 137 | *'Unpair' ) kdeconnect-cli --unpair -d $2 ;; 138 | *'Send SMS' ) 139 | message=$(echo 'OTW' | dmenu -i -p "Msg to send") 140 | recipient=$(echo '14039199518' | dmenu -i -p "Recipient's phone #") 141 | kdeconnect-cli --send-sms "$message" --destination "$recipient" -d $2 ;; 142 | *'Refresh' ) 143 | kdeconnect-cli --refresh;; 144 | *'Notification' ) 145 | Notification_menu $notification1 $2;; 146 | *'keys' ) 147 | SendKeys "$2";; 148 | esac 149 | } 150 | 151 | show_pmenu () { 152 | menu="$(printf "Pair Device" | dmenu -i -p "$1" )" 153 | case "$menu" in 154 | *'Pair Device') kdeconnect-cli --pair -d $2 ;; 155 | esac 156 | } 157 | #still a work in progress 158 | # get_colors () { 159 | # case $1 in 160 | # "-1") colors="-nb \"$COLOR_DISCONNECTED\" -nf \"#000\" " ;; 161 | # "-2") colors="-nb \"$COLOR_NEWDEVICE\" -nf \"#000\" ";; 162 | # 5*) colors="-nb \"$COLOR_BATTERY_50\" -nf \"#000\" ";; 163 | # 6*) colors="-nb \"$COLOR_BATTERY_60\" -nf \"#000\" ";; 164 | # 7*) colors="-nb \"$COLOR_BATTERY_70\" -nf \"#000\" ";; 165 | # 8*) colors="-nb \"$COLOR_BATTERY_80\" -nf \"#000\" ";; 166 | # *) colors="-nb \"$COLOR_BATTERY_LOW\" -nf \"#000\" ";; 167 | # 9*|100) colors="-nb \"$COLOR_BATTERY_90\" -nf \"#000\" ";; 168 | # esac 169 | # echo $colors 170 | # } 171 | 172 | get_icon () { 173 | if [ "$2" = "tablet" ] 174 | then 175 | ICON=$ICON_TABLET 176 | else 177 | ICON=$ICON_SMARTPHONE 178 | fi 179 | echo $ICON 180 | } 181 | show_devices 182 | #vim:ft=sh 183 | --------------------------------------------------------------------------------