diff options
Diffstat (limited to '.scripts')
| -rw-r--r-- | .scripts/SCRIPTS.md | 2 | ||||
| -rwxr-xr-x | .scripts/cron/checkup | 2 | ||||
| -rwxr-xr-x | .scripts/cron/newsup | 4 | ||||
| -rwxr-xr-x | .scripts/i3cmds/displayselect | 4 | ||||
| -rwxr-xr-x | .scripts/i3cmds/dmenumount | 6 | ||||
| -rwxr-xr-x | .scripts/i3cmds/dmenuumount | 4 | ||||
| -rwxr-xr-x | .scripts/i3cmds/dropdowncalc | 5 | ||||
| -rwxr-xr-x | .scripts/i3cmds/lockscreen | 19 | ||||
| -rwxr-xr-x | .scripts/i3cmds/maimpick | 4 | ||||
| -rwxr-xr-x | .scripts/i3cmds/td-toggle | 13 | ||||
| -rwxr-xr-x | .scripts/i3cmds/torwrap | 6 | ||||
| -rwxr-xr-x | .scripts/i3cmds/xcqr | 2 | ||||
| -rwxr-xr-x | .scripts/statusbar/battery | 16 | ||||
| -rwxr-xr-x | .scripts/statusbar/mailbox | 3 | ||||
| -rwxr-xr-x | .scripts/statusbar/mpdupdate | 3 | ||||
| -rwxr-xr-x | .scripts/statusbar/popupgrade | 1 | ||||
| -rwxr-xr-x | .scripts/statusbar/torrent | 5 | ||||
| -rwxr-xr-x | .scripts/tools/compiler | 25 | ||||
| -rwxr-xr-x | .scripts/tools/ifinstalled | 2 | ||||
| -rwxr-xr-x | .scripts/tools/linkhandler | 9 | ||||
| -rwxr-xr-x | .scripts/tools/note | 8 | ||||
| -rwxr-xr-x | .scripts/tools/qndl | 11 | ||||
| -rwxr-xr-x | .scripts/tools/queueandnotify | 7 | ||||
| -rwxr-xr-x | .scripts/tools/setbg | 2 | ||||
| -rwxr-xr-x | .scripts/tools/shortcuts | 10 | ||||
| -rwxr-xr-x | .scripts/tools/texclear | 2 | ||||
| -rwxr-xr-x | .scripts/tools/transadd | 11 |
27 files changed, 70 insertions, 116 deletions
diff --git a/.scripts/SCRIPTS.md b/.scripts/SCRIPTS.md index 34bb01b..a99e35e 100644 --- a/.scripts/SCRIPTS.md +++ b/.scripts/SCRIPTS.md @@ -54,7 +54,7 @@ in vim or another program. - `opout` -- "Open output", opens the corresponding `.pdf` file if run on a `.md`, `.tex` or `.rmd` file, or if given an `.html` file, will open it in the browser. Bound to `<leader>p` in my vim config to reveal typical output. - `pauseallmpv` -- Pauses all mpv instances by sending the `,` key to each. Used by several scripts, but can be used alone as well. It will not pause an audio only mpv instance. If you know how to add a hack to do this, feel free to PR it or email me an addition. - `remaps` -- Remaps capslock to escape when pressed and super/mod when held. Maps the menu key to super as well. Runs the US international keyboard setup. If you want another keyboard setup, edit this fine. -- `shortcuts` -- For updating bash and ranger shortcuts. Reads `~/.key_directories` and `~/.key_files` for pairs of keypresses and directories and files, then autoproduces bash aliases and ranger shortcuts for them which output to `~/.shortcuts` and `~/.config/ranger/shortcuts.conf` respectively. These are read automatically by my bash and ranger configs. You don't have to run this script manually though, as it's run by vim whenever you edit one of the `~/.key_*` files. +- `shortcuts` -- For updating bash and ranger shortcuts. Reads `~/.config/bmdirs` and `~/.config/bmfiles` for pairs of keypresses and directories and files, then autoproduces bash aliases and ranger shortcuts for them which output to `~/.config/shortcutrc` and `~/.config/ranger/shortcuts.conf` respectively. These are read automatically by my bash and ranger configs. You don't have to run this script manually though, as it's run by vim whenever you edit one of the `~/.bm*` files. - `speedvid` -- Speed up a given video file (`$1`) by a given ammount (`$2`). - `tpb` -- Search Pirate Bay for the certain search terms given as arguments. - `texclear` -- Remove all `.tex` related build files. This is run by my vim when I stop editing any `.tex` file. diff --git a/.scripts/cron/checkup b/.scripts/cron/checkup index 770c349..a32cdcb 100755 --- a/.scripts/cron/checkup +++ b/.scripts/cron/checkup @@ -3,7 +3,7 @@ ping -q -w 1 -c 1 `ip r | grep -m 1 default | cut -d ' ' -f 3` >/dev/null || exit -notify-send -i "$PIX/larbs.gif" "Checking for pacakge updates..." +notify-send -i "$PIX/larbs.svg" "Checking for pacakge updates..." sudo pacman -Syyuw --noconfirm || notify-send "Error downloading updates. diff --git a/.scripts/cron/newsup b/.scripts/cron/newsup index 598cced..32f6a37 100755 --- a/.scripts/cron/newsup +++ b/.scripts/cron/newsup @@ -4,7 +4,7 @@ ping -q -t 1 -c 1 `ip r | grep -m 1 default | cut -d ' ' -f 3` >/dev/null || exit -/usr/bin/notify-send -i "$PIX/rss.gif" "Updating RSS feeds..." +/usr/bin/notify-send -i "$PIX/rss.svg" "Updating RSS feeds..." pgrep -x newsboat >/dev/null && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --name newsboat)" R && exit @@ -13,4 +13,4 @@ pkill -RTMIN+6 i3blocks /usr/bin/newsboat -x reload rm -f ~/.config/newsboat/.update pkill -RTMIN+6 i3blocks -/usr/bin/notify-send -i "$PIX/rss.gif" "RSS feed update complete." +/usr/bin/notify-send -i "$PIX/rss.svg" "RSS feed update complete." diff --git a/.scripts/i3cmds/displayselect b/.scripts/i3cmds/displayselect index 2c3133f..e526014 100755 --- a/.scripts/i3cmds/displayselect +++ b/.scripts/i3cmds/displayselect @@ -49,7 +49,7 @@ morescreen() { # If multi-monitor is selected and there are more than two screen multimon() { # Multi-monitor handler. case "$(echo "$screens" | wc -l)" in - 1) xrandr $(echo "$allposs" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; + 1) xrandr $(echo "$allposs" | grep -v "$screens" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; 2) twoscreen ;; *) morescreen ;; esac ;} @@ -65,7 +65,7 @@ chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p case "$chosen" in "manual selection") arandr ; exit ;; "multi-monitor") multimon ;; - *) xrandr --output "$chosen" --auto --scale 1.0x1.0 $(echo "$screens" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; + *) xrandr --output "$chosen" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; esac setbg # Fix background if screen size/arangement has changed. diff --git a/.scripts/i3cmds/dmenumount b/.scripts/i3cmds/dmenumount index 4de7438..a270886 100755 --- a/.scripts/i3cmds/dmenumount +++ b/.scripts/i3cmds/dmenumount @@ -17,21 +17,21 @@ getmount() { \ mountusb() { \ chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?" | awk '{print $1}')" - sudo -A mount "$chosen" && notify-send "$chosen mounted." && exit 0 + sudo -A mount "$chosen" && notify-send -i "$PIX/usb.svg" "$chosen mounted." && exit 0 getmount "/mnt /media /mount /home -maxdepth 5 -type d" partitiontype="$(lsblk -no "fstype" "$chosen")" case "$partitiontype" in "vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;; *) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" 741 "$mp";; esac - notify-send "$chosen mounted to $mp." + notify-send -i "$PIX/usb.svg" "$chosen mounted to $mp." } mountandroid() { \ chosen=$(echo "$anddrives" | dmenu -i -p "Which Android device?" | cut -d : -f 1) getmount "$HOME -maxdepth 3 -type d" simple-mtpfs --device "$chosen" "$mp" - notify-send "Android device mounted to $mp." + notify-send -i "$PIX/android.svg" "Android device mounted to $mp." } asktype() { \ diff --git a/.scripts/i3cmds/dmenuumount b/.scripts/i3cmds/dmenuumount index a267010..e4ec064 100755 --- a/.scripts/i3cmds/dmenuumount +++ b/.scripts/i3cmds/dmenuumount @@ -7,13 +7,13 @@ unmountusb() { [ -z "$drives" ] && exit chosen=$(echo "$drives" | dmenu -i -p "Unmount which drive?" | awk '{print $1}') [ -z "$chosen" ] && exit - sudo -A umount "$chosen" && pgrep -x dunst && notify-send "$chosen unmounted." + sudo -A umount "$chosen" && pgrep -x dunst && notify-send -i "$PIX/usb.svg" "$chosen unmounted." } unmountandroid() { \ chosen=$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?") [ -z "$chosen" ] && exit - fusermount -u "$chosen" && pgrep -x dunst && notify-send "$chosen unmounted." + sudo -A umount -l "$chosen" && pgrep -x dunst && notify-send -i "$PIX/android.svg" "$chosen unmounted." } asktype() { \ diff --git a/.scripts/i3cmds/dropdowncalc b/.scripts/i3cmds/dropdowncalc index fee8f07..4d41f88 100755 --- a/.scripts/i3cmds/dropdowncalc +++ b/.scripts/i3cmds/dropdowncalc @@ -1,5 +1,2 @@ #!/bin/sh -# This script ensures that i3 will spawn a calculator. -# If R is installed, it will run R, otherwise it will run -# Python. -([ -e /usr/bin/R ] && R -q --no-save) || python -q +ifinstalled bc && echo "Welcome to the Calculator." && bc -lq diff --git a/.scripts/i3cmds/lockscreen b/.scripts/i3cmds/lockscreen deleted file mode 100755 index b745a6a..0000000 --- a/.scripts/i3cmds/lockscreen +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -rm -f /tmp/locked.png - -# If `imagemagick` is not installed, use a blank screen. -[ -f /usr/bin/convert ] && -scrot -m -z /tmp/base.png && -pgrep -x dunst && notify-send -i ~/.scripts/pix/lock.png "Locking computer..." && -convert /tmp/base.png -blur 0x8 /tmp/locked.png - -# Pause music (mocp, mpd and send the pause key to all mpv videos): -mocp -P >/dev/null 2>&1 -mpc pause >/dev/null 2>&1 -pauseallmpv >/dev/null 2>&1 - -i3lock -e -f -c 000000 -i /tmp/locked.png - -# In five seconds, turn off display unless key press in last 4 seconds. -sleep 5 && [ 4000 -lt "$(xssstate -i)" ] && pgrep -x i3lock && xset dpms force off diff --git a/.scripts/i3cmds/maimpick b/.scripts/i3cmds/maimpick index f3f72fe..07d032f 100755 --- a/.scripts/i3cmds/maimpick +++ b/.scripts/i3cmds/maimpick @@ -1,9 +1,9 @@ #!/bin/sh -case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfullscreen (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in +case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in "a selected area") maim -s pic-selected-"$(date '+%y%m%d-%H%M-%S').png" ;; "current window") maim -i "$(xdotool getactivewindow)" pic-window-"$(date '+%y%m%d-%H%M-%S').png" ;; "full screen") maim pic-full-"$(date '+%y%m%d-%H%M-%S').png" ;; "a selected area (copy)") maim -s | xclip -selection clipboard -t image/png ;; - "current window (copy)") maim -i | xclip -selection clipboard -t image/png ;; + "current window (copy)") maim -i "$(xdotool getactivewindow)" | xclip -selection clipboard -t image/png ;; "full screen (copy)") maim | xclip -selection clipboard -t image/png ;; esac diff --git a/.scripts/i3cmds/td-toggle b/.scripts/i3cmds/td-toggle index 6489626..729e697 100755 --- a/.scripts/i3cmds/td-toggle +++ b/.scripts/i3cmds/td-toggle @@ -1,15 +1,10 @@ #!/bin/sh - # If transmission-daemon is running, will ask to kill, else will ask to start. - -[ ! -f /usr/bin/transmission-daemon ] && notify-send "Transmission daemon not installed." && exit - -if pgrep -x transmission-da >/dev/null ; +if pgrep -x transmission-da >/dev/null ; then - yn=$(printf "No\\nYes" | dmenu -i -p "Kill transmission-daemon?") - [ "$yn" = "Yes" ] && killall transmission-da + [ "$(printf "No\\nYes" | dmenu -i -p "Kill transmission-daemon?")" = "Yes" ] && killall transmission-da && notify-send -i "$PIX/torrent.svg" "transmission-daemon killed." else - yn=$(printf "No\\nYes" | dmenu -i -p "Start transmission daemon?") - [ "$yn" = "Yes" ] && transmission-daemon + ifinstalled transmission-cli || exit + [ "$(printf "No\\nYes" | dmenu -i -p "Start transmission daemon?")" = "Yes" ] && transmission-daemon && notify-send -i "$PIX/torrent.svg" "tranmission-daemon started." fi sleep 3 && pkill -RTMIN+7 i3blocks diff --git a/.scripts/i3cmds/torwrap b/.scripts/i3cmds/torwrap new file mode 100755 index 0000000..6b501cc --- /dev/null +++ b/.scripts/i3cmds/torwrap @@ -0,0 +1,6 @@ +#!/bin/sh +ifinstalled transmission-remote-cli transmission-cli || exit + +! pgrep -x transmission-da >/dev/null && transmission-daemon && notify-send -i "$PIX/torrent.svg" "Starting torrent daemon..." && sleep 3 && pkill -RTMIN+7 i3blocks + +$TERMINAL -e transmission-remote-cli diff --git a/.scripts/i3cmds/xcqr b/.scripts/i3cmds/xcqr index 5e7b5f0..2352599 100755 --- a/.scripts/i3cmds/xcqr +++ b/.scripts/i3cmds/xcqr @@ -1,6 +1,6 @@ #!/bin/sh # Credit to Maddison Hellstrom (@b0o on Github) -qrencode -o - -s 1 \ +ifinstalled feh && qrencode -o - -s 1 \ "$(xclip -out -selection clipboard)" | feh --zoom max \ -F \ diff --git a/.scripts/statusbar/battery b/.scripts/statusbar/battery index b2634e6..e5f6ec7 100755 --- a/.scripts/statusbar/battery +++ b/.scripts/statusbar/battery @@ -1,12 +1,10 @@ #!/bin/sh # Give a battery name (e.g. BAT0) as an argument. -# get xresources colors -for x in "$(xrdb -query | sed "s/.*\./export /g;s/:\s*/=\"/g;s/$/\"/g")"; do eval "$x"; done - case $BLOCK_BUTTON in 3) pgrep -x dunst >/dev/null && notify-send "<b>🔋 Battery module:</b> 🔋: discharging +🛑: not charging ♻: stagnant charge 🔌: charging ⚡: charged @@ -18,18 +16,18 @@ capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit status=$(cat /sys/class/power_supply/"$1"/status) if [ "$capacity" -ge 75 ]; then - color="$color10" + color="#00ff00" elif [ "$capacity" -ge 50 ]; then - color="$color15" + color="#ffffff" elif [ "$capacity" -ge 25 ]; then - color="$color11" + color="#ffff00" else - color="$color9" + color="#ff0000" warn="❗" fi [ -z $warn ] && warn=" " -[ "$status" = "Charging" ] && color="$color15" +[ "$status" = "Charging" ] && color="#ffffff" -printf "<span color='%s'>%s%s%s</span>" "$color" "$(echo "$status" | sed -e "s/,//g;s/Discharging/🔋/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$warn" "$(echo "$capacity" | sed -e 's/$/%/')" +printf "<span color='%s'>%s%s%s</span>" "$color" "$(echo "$status" | sed -e "s/,//;s/Discharging/🔋/;s/Not Charging/🛑/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$warn" "$(echo "$capacity" | sed -e 's/$/%/')" diff --git a/.scripts/statusbar/mailbox b/.scripts/statusbar/mailbox index bb72c5d..0c5ccbe 100755 --- a/.scripts/statusbar/mailbox +++ b/.scripts/statusbar/mailbox @@ -14,5 +14,4 @@ case $BLOCK_BUTTON in - Middle click syncs mail" ;; esac -echo "$(du -a ~/.mail/*/INBOX/new/* 2>/dev/null | sed -n '$=')$(cat ~/.config/mutt/.dl 2>/dev/null)" - +echo "$(du -a ~/.mail/*/INBOX/new/* 2>/dev/null | sed -n '$=')$(cat /tmp/imapsyncicon 2>/dev/null)" diff --git a/.scripts/statusbar/mpdupdate b/.scripts/statusbar/mpdupdate index 84c7ab1..9a57ca4 100755 --- a/.scripts/statusbar/mpdupdate +++ b/.scripts/statusbar/mpdupdate @@ -1,8 +1,7 @@ #!/bin/sh - [ "$(pgrep -x "$(basename "$0")" | wc -l)" -gt 2 ] && exit -while : ; do +sleep 5 && while : ; do pgrep -x mpd || exit mpc idle > /dev/null pkill -RTMIN+11 i3blocks ; diff --git a/.scripts/statusbar/popupgrade b/.scripts/statusbar/popupgrade index 739fcb7..83035c3 100755 --- a/.scripts/statusbar/popupgrade +++ b/.scripts/statusbar/popupgrade @@ -3,7 +3,6 @@ printf "Beginning upgrade.\\n" yay -Syu -pacman -Qu | wc -l > ~/.pacupgrnum pkill -RTMIN+8 i3blocks printf "\\nUpgrade complete.\\nPress <Enter> to exit window.\\n\\n" diff --git a/.scripts/statusbar/torrent b/.scripts/statusbar/torrent index 06ddd3e..8534cb1 100755 --- a/.scripts/statusbar/torrent +++ b/.scripts/statusbar/torrent @@ -6,10 +6,12 @@ transmission-remote -l | grep % | s/.*Seeding.*/Z/g; s/.*100%.*/N/g; s/.*Idle.*/B/g; + s/.*Uploading.*/L/g; s/.*%.*/M/g" | sort -h | uniq -c | sed " # Now we replace the standin letters with icons. s/A/🛑/g; s/B/⌛️/g; + s/L/🔼/g; s/M/🔽/g; s/N/✅/g; s/Z/🌱/g" | awk '{print $2, $1}' | tr '\n' ' ' | sed -e "s/ $//g" @@ -18,7 +20,8 @@ case $BLOCK_BUTTON in 1) $TERMINAL -e transmission-remote-cli ;; 3) pgrep -x dunst >/dev/null && notify-send "<b>Torrent module:</b> 🛑: paused -⏳: waiting +⏳: idle (seeds needed) +🔼: uploading (unfinished) 🔽: downloading ✅: done 🌱: done and seeding" ;; diff --git a/.scripts/tools/compiler b/.scripts/tools/compiler index cf628aa..7d3bf1d 100755 --- a/.scripts/tools/compiler +++ b/.scripts/tools/compiler @@ -1,21 +1,14 @@ #!/bin/sh - # This script will compile or run another finishing operation on a document. I # have this script run via vim. # -# tex files: Compiles to pdf, including bibliography if necessary -# md files: Compiles to pdf via pandoc -# rmd files: Compiles via R Markdown -# c files: Compiles via whatever compiler is set to cc. Usually gcc. -# py files: runs via python command -# go files: compiles and runs with "go run" -# config.h files: (For suckless utils) recompiles and installs program. -# all others: run `sent` to show a presentation +# Compiles .tex. groff (.mom, .ms), .rmd, .md. +# Opens .sent files as sent presentations. +# Runs scripts based on extention or shebang file=$(readlink -f "$1") dir=$(dirname "$file") base="${file%.*}" -shebang=$(sed -n 1p "$file") cd "$dir" || exit @@ -29,22 +22,16 @@ textype() { \ $command --output-directory="$dir" "$base" } -shebangtest() { - case "$shebang" in - \#\!*) "$file" ;; - *) sent "$file" 2>/dev/null & ;; - esac -} - case "$file" in *\.ms) refer -PS -e "$file" | groff -me -ms -kejpt -T pdf > "$base".pdf ;; *\.mom) refer -PS -e "$file" | groff -mom -kejpt -T pdf > "$base".pdf ;; *\.rmd) echo "require(rmarkdown); render('$file')" | R -q --vanilla ;; *\.tex) textype "$file" ;; *\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;; - *config.h) make && sudo make install ;; + *config.h) sudo make install ;; *\.c) cc "$file" -o "$base" && "$base" ;; *\.py) python "$file" ;; *\.go) go run "$file" ;; - *) shebangtest ;; + *\.sent) setsid sent "$file" 2>/dev/null & ;; + *) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;; esac diff --git a/.scripts/tools/ifinstalled b/.scripts/tools/ifinstalled index bdbcbc4..0305f4f 100755 --- a/.scripts/tools/ifinstalled +++ b/.scripts/tools/ifinstalled @@ -1,3 +1,3 @@ #!/bin/sh # If $1 command is not available, error code and notify. -command -v "$1" >/dev/null || { notify-send "$1 is not installed." && exit 1 ;} +command -v "$1" >/dev/null || { notify-send "📦 <b>$1</b> must be installed for this function." && exit 1 ;} diff --git a/.scripts/tools/linkhandler b/.scripts/tools/linkhandler index 0719660..c616d04 100755 --- a/.scripts/tools/linkhandler +++ b/.scripts/tools/linkhandler @@ -1,14 +1,11 @@ #!/bin/sh # Feed script a url or file location. -# If an image, it will view in feh, +# If an image, it will view in sxiv, # if a video or gif, it will view in mpv # if a music file or pdf, it will download, # otherwise it opens link in browser. -# Sci-Hub's domain occasionally changes due to shutdowns: -scihub="http://sci-hub.tw/" - # If no url given. Opens browser. For using script as $BROWSER. [ -z "$1" ] && { "$BROWSER"; exit; } @@ -16,11 +13,9 @@ case "$1" in *mkv|*webm|*mp4|*youtube.com*|*youtu.be*|*hooktube.com*|*bitchute.com*) setsid mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) -quiet "$1" >/dev/null 2>&1 & ;; *png|*jpg|*jpe|*jpeg|*gif) - setsid sxiv -a "$1" >/dev/null 2>&1 & ;; + curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 & ;; *mp3|*flac|*opus|*mp3?source*) setsid tsp curl -LO "$1" >/dev/null 2>&1 & ;; - *springer.com*) - setsid curl -sO "$(curl -s "$scihub$*" | grep -Po "(?<=location.href=').+.pdf")" >/dev/null 2>&1 & ;; *) if [ -f "$1" ]; then "$TERMINAL" -e "$EDITOR $1" else setsid "$BROWSER" "$1" >/dev/null 2>&1 & fi ;; diff --git a/.scripts/tools/note b/.scripts/tools/note deleted file mode 100755 index 09186ea..0000000 --- a/.scripts/tools/note +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# This is a general notification command for my own ease. -# $1 should be a message -# $2 is an optional image for notify-send -# Echos content on terminal and if dunst is running, shows notification. - -[ -z "$2" ] || img="-i $2" -echo "$1" && pgrep -x dunst >/dev/null && notify-send $img "$1" diff --git a/.scripts/tools/qndl b/.scripts/tools/qndl new file mode 100755 index 0000000..a99d37e --- /dev/null +++ b/.scripts/tools/qndl @@ -0,0 +1,11 @@ +#!/bin/sh +# $1 is a url; $2 is a command +[ -z "$1" ] && exit +base="$(basename "$1")" +notify-send "⏳ Queuing $base..." +cmd="$2" +[ -z "$cmd" ] && cmd="youtube-dl --add-metadata" +idnum="$(tsp $cmd "$1")" +realname="$(echo "$base" | sed "s/?\(source\|dest\).*//;s/%20/ /g")" +tsp -D "$idnum" mv "$base" "$realname" +tsp -D "$idnum" notify-send "👍 $realname done." diff --git a/.scripts/tools/queueandnotify b/.scripts/tools/queueandnotify index 332668f..a1417ec 100755 --- a/.scripts/tools/queueandnotify +++ b/.scripts/tools/queueandnotify @@ -7,12 +7,7 @@ queuefile="$HOME/.local/share/newsboat/queue" while read -r line; do [ -z "$line" ] && continue url="$(echo "$line" | awk '{print $1}')" - base="$(basename "$url")" - notify-send -i "$PIX/dl.png" "Queuing $base..." - idnum="$(tsp curl -LO "$url")" - realname="$(echo "$base" | sed "s/?\(source\|dest\).*//;s/%20/ /g")" - tsp -D "$idnum" mv "$base" "$realname" - tsp -D "$idnum" notify-send -i "$PIX/check.png" "$realname done." + qndl "$url" "curl -LO" done < "$queuefile" echo > "$queuefile" diff --git a/.scripts/tools/setbg b/.scripts/tools/setbg index 00e996a..950ae7c 100755 --- a/.scripts/tools/setbg +++ b/.scripts/tools/setbg @@ -1,4 +1,4 @@ #!/bin/sh # Sets the background. If given an argument, will set file as background. [ ! -z "$1" ] && cp "$1" ~/.config/wall.png && notify-send -i "$HOME/.config/wall.png" "Wallpaper changed." -xwallpaper --center ~/.config/wall.png +xwallpaper --zoom ~/.config/wall.png diff --git a/.scripts/tools/shortcuts b/.scripts/tools/shortcuts index cb4cc6e..3ac0bbd 100755 --- a/.scripts/tools/shortcuts +++ b/.scripts/tools/shortcuts @@ -1,10 +1,10 @@ #!/bin/bash # Output locations. Unactivated progs should go to /dev/null. -shell_shortcuts="$HOME/.shortcuts" +shell_shortcuts="$HOME/.config/shortcutrc" ranger_shortcuts="$HOME/.config/ranger/shortcuts.conf" qute_shortcuts="/dev/null" -fish_shortcuts="$HOME/.config/fish/shortcuts.fish" -vifm_shortcuts="$HOME/.vifmshortcuts" +fish_shortcuts="/dev/null" +vifm_shortcuts="$HOME/.config/vifm/vifmshortcuts" # Remove, prepare files rm -f "$ranger_shortcuts" "$qute_shortcuts" 2>/dev/null @@ -13,14 +13,14 @@ printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts" printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts" # Format the `bmdirs` file in the correct syntax and sent it to all three configs. -sed "s/\s*#.*$//;/^\s*$/d" "$HOME/.bmdirs" | tee >(awk '{print $1"=\"cd "$2" && ls -a\" \\"}' >> "$shell_shortcuts") \ +sed "s/\s*#.*$//;/^\s*$/d" "$HOME/.config/bmdirs" | tee >(awk '{print $1"=\"cd "$2" && ls -a\" \\"}' >> "$shell_shortcuts") \ >(awk '{print "abbr", $1, "\"cd " $2 "; and ls -a\""}' >> "$fish_shortcuts") \ >(awk '{print "map g" $1, ":cd", $2 "<CR>\nmap t" $1, "<tab>:cd", $2 "<CR><tab>\nmap M" $1, "<tab>:cd", $2 "<CR><tab>:mo<CR>\nmap Y" $1, "<tab>:cd", $2 "<CR><tab>:co<CR>" }' >> "$vifm_shortcuts") \ >(awk '{print "config.bind(\";"$1"\", \"set downloads.location.directory "$2" ;; hint links download\")"}' >> "$qute_shortcuts") \ | 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" # Format the `configs` file in the correct syntax and sent it to both configs. -sed "s/\s*#.*$//;/^\s*$/d" "$HOME/.bmfiles" | tee >(awk '{print $1"=\"$EDITOR "$2"\" \\"}' >> "$shell_shortcuts") \ +sed "s/\s*#.*$//;/^\s*$/d" "$HOME/.config/bmfiles" | tee >(awk '{print $1"=\"$EDITOR "$2"\" \\"}' >> "$shell_shortcuts") \ >(awk '{print "abbr", $1, "\"$EDITOR "$2"\""}' >> "$fish_shortcuts") \ >(awk '{print "map", $1, ":e", $2 "<CR>" }' >> "$vifm_shortcuts") \ | awk '{print "map "$1" shell $EDITOR "$2}' >> "$ranger_shortcuts" diff --git a/.scripts/tools/texclear b/.scripts/tools/texclear index 20f435c..f6a5062 100755 --- a/.scripts/tools/texclear +++ b/.scripts/tools/texclear @@ -8,7 +8,7 @@ case "$1" in file=$(readlink -f "$1") dir=$(dirname "$file") base="${file%.*}" - 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 ;; + 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|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|bcf|run\\.xml|synctex\\.gz|blg|bbl)" -delete ;; *) printf "Give .tex file as argument.\\n" ;; esac diff --git a/.scripts/tools/transadd b/.scripts/tools/transadd index 8cc7e80..ad2ee7f 100755 --- a/.scripts/tools/transadd +++ b/.scripts/tools/transadd @@ -1,12 +1,9 @@ #!/bin/sh -# Mimeapp script for adding torrent to transmission-daemon, but will also start -# the daemon first if not running. +# Mimeapp script for adding torrent to transmission-daemon, but will also start the daemon first if not running. -# Optionally requires my `note` script. The sleep of 3 seconds is because the -# transmission-daemon sometimes fails to take remote requests in its first -# moments. +# transmission-daemon sometimes fails to take remote requests in its first moments. -pgrep -x transmission-da || (transmission-daemon && note "Starting daemon..." "$PIX/dl.png" && sleep 3 && pkill -RTMIN+7 i3blocks) +pgrep -x transmission-da || (transmission-daemon && notify-send "Starting transmission daemon..." && sleep 3 && pkill -RTMIN+7 i3blocks) -transmission-remote -a "$@" && note "Torrent added." "$PIX/dl.png" +transmission-remote -a "$@" && notify-send "🔽 Torrent added." |
