From f541c98a4bdd4d65be3be9db4a7bf0c9bcd73a98 Mon Sep 17 00:00:00 2001 From: tiynger Date: Fri, 4 Oct 2019 01:15:05 +0200 Subject: [PATCH] cleaning up unused scripts --- .config/nvim/init.vim | 9 -- .local/bin/{i3cmds => }/dmenuunicode | 0 .local/bin/i3cmds/cabl | 26 ----- .local/bin/i3cmds/camtoggle | 2 - .local/bin/i3cmds/ddspawn | 19 ---- .local/bin/i3cmds/displayselect | 73 -------------- .local/bin/i3cmds/dmenurecord | 105 -------------------- .local/bin/i3cmds/dropdowncalc | 2 - .local/bin/i3cmds/hover | 14 --- .local/bin/i3cmds/maimpick | 9 -- .local/bin/i3cmds/samedir | 5 - .local/bin/i3cmds/td-toggle | 10 -- .local/bin/i3cmds/torwrap | 6 -- .local/bin/i3cmds/tutorialvids | 18 ---- .local/bin/i3cmds/winresize | 2 - .local/bin/sxhkd/dmenumount | 59 +++++++++++ .local/bin/{i3cmds => sxhkd}/dmenuumount | 0 .local/bin/sxhkd/ducksearch | 20 ++++ .local/bin/tools/compiler | 38 ------- .local/bin/tools/ext | 1 - .local/bin/tools/extract | 41 -------- .local/bin/tools/getbib | 14 --- .local/bin/tools/getkeys | 4 - .local/bin/tools/lmc | 23 +---- .local/bin/tools/opout | 11 -- .local/bin/tools/pauseallmpv | 4 - .local/bin/tools/podentr | 6 -- .local/bin/{i3cmds => tools}/prompt | 2 +- .local/bin/tools/qndl | 11 -- .local/bin/tools/queueandnotify | 13 --- .local/bin/tools/remaps | 4 - .local/bin/tools/rotdir | 4 - .local/bin/tools/rssadd | 9 -- .local/bin/tools/shortcuts | 26 ----- .local/bin/tools/texclear | 14 --- .local/bin/{i3cmds => tools}/toggletouchpad | 0 .local/bin/tools/transadd | 9 -- .local/bin/tools/vifmimg | 13 --- .local/bin/tools/vu | 15 --- 39 files changed, 82 insertions(+), 559 deletions(-) rename .local/bin/{i3cmds => }/dmenuunicode (100%) delete mode 100755 .local/bin/i3cmds/cabl delete mode 100755 .local/bin/i3cmds/camtoggle delete mode 100755 .local/bin/i3cmds/ddspawn delete mode 100755 .local/bin/i3cmds/displayselect delete mode 100755 .local/bin/i3cmds/dmenurecord delete mode 100755 .local/bin/i3cmds/dropdowncalc delete mode 100755 .local/bin/i3cmds/hover delete mode 100755 .local/bin/i3cmds/maimpick delete mode 100755 .local/bin/i3cmds/samedir delete mode 100755 .local/bin/i3cmds/td-toggle delete mode 100755 .local/bin/i3cmds/torwrap delete mode 100755 .local/bin/i3cmds/tutorialvids delete mode 100755 .local/bin/i3cmds/winresize create mode 100755 .local/bin/sxhkd/dmenumount rename .local/bin/{i3cmds => sxhkd}/dmenuumount (100%) create mode 100755 .local/bin/sxhkd/ducksearch delete mode 100755 .local/bin/tools/compiler delete mode 120000 .local/bin/tools/ext delete mode 100755 .local/bin/tools/extract delete mode 100755 .local/bin/tools/getbib delete mode 100755 .local/bin/tools/getkeys delete mode 100755 .local/bin/tools/opout delete mode 100755 .local/bin/tools/pauseallmpv delete mode 100755 .local/bin/tools/podentr rename .local/bin/{i3cmds => tools}/prompt (60%) delete mode 100755 .local/bin/tools/qndl delete mode 100755 .local/bin/tools/queueandnotify delete mode 100755 .local/bin/tools/remaps delete mode 100755 .local/bin/tools/rotdir delete mode 100755 .local/bin/tools/rssadd delete mode 100755 .local/bin/tools/shortcuts delete mode 100755 .local/bin/tools/texclear rename .local/bin/{i3cmds => tools}/toggletouchpad (100%) delete mode 100755 .local/bin/tools/transadd delete mode 100755 .local/bin/tools/vifmimg delete mode 100755 .local/bin/tools/vu diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index a050da8..e6061f2 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -60,15 +60,6 @@ set clipboard=unnamedplus " Replace all is aliased to S. nnoremap S :%s//g -" Compile document, be it groff/LaTeX/markdown/etc. - map c :w! \| !compiler % - -" Open corresponding .pdf/.html or preview - map p :!opout % - -" Runs a script that cleans out tex build files whenever I close out of a .tex file. - autocmd VimLeave *.tex !texclear % - " Ensure files are read as what I want: let g:vimwiki_ext2syntax = {'.Rmd': 'markdown', '.rmd': 'markdown','.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'} let g:vimwiki_list = [{'path': '~/vimwiki', 'syntax': 'markdown', 'ext': '.md'}] diff --git a/.local/bin/i3cmds/dmenuunicode b/.local/bin/dmenuunicode similarity index 100% rename from .local/bin/i3cmds/dmenuunicode rename to .local/bin/dmenuunicode diff --git a/.local/bin/i3cmds/cabl b/.local/bin/i3cmds/cabl deleted file mode 100755 index b5b1b3f..0000000 --- a/.local/bin/i3cmds/cabl +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# Dependencies are xclip and xorg-xprop. -# qrencode required for qrcode generation. -# groff/zathura required for man pages. -prim="$(xclip -o)"; [ -z "$prim" ] && exit - -PID=$(xprop -id "$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')" | grep -m 1 PID | cut -d " " -f 3) -PID=$(echo "$(pstree -lpA "$PID" | tail -n 1)" | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g') -cd "$(readlink /proc/"$PID"/cwd)" -[ -f "$prim" ] && xdg-open "$prim" && exit -[ -d "$prim" ] && "$TERMINAL" "$prim" && exit - -websearch() { "$BROWSER" "https://duckduckgo.com/?q=$@" ;} -wikipedia() { "$BROWSER" "https://en.wikipedia.org/wiki/$@" ;} -wiktionary() { "$BROWSER" "https://en.wiktionary.org/wiki/$@" ;} -maps() { "$BROWSER" "https://www.openstreetmap.org/search?query=$@" ;} -ebay() { "$BROWSER" "https://www.ebay.com/sch/$@" ;} - -echo "$prim" | grep "^.*\.[A-Za-z]\+.*" >/dev/null && gotourl() { "$BROWSER" "$@" ;} -echo "$prim" | grep "^.*@.*\.[A-Za-z]\+$" >/dev/null && email() { xdg-email "$@" ;} -command -v qrencode >/dev/null && qrcode() { qrencode "$@" -s 10 -o /tmp/qr.png && xdg-open /tmp/qr.png ;} -man -k "^$prim$" >/dev/null && manual() { man -Tpdf "$prim" | zathura - ;} - -func="$(declare -F | awk '{print $3}' | dmenu -p "Plumb \"$(echo "$prim" | cut -c -30)\" to?" -i -l 15)" - -[ -z "$func" ] || "$func" "$prim" diff --git a/.local/bin/i3cmds/camtoggle b/.local/bin/i3cmds/camtoggle deleted file mode 100755 index 05679c0..0000000 --- a/.local/bin/i3cmds/camtoggle +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -pkill -f /dev/video || mpv --no-osc --no-input-default-bindings --input-conf=/dev/null --geometry=-0-0 --autofit=30% --title="mpvfloat" /dev/video0 diff --git a/.local/bin/i3cmds/ddspawn b/.local/bin/i3cmds/ddspawn deleted file mode 100755 index d4a4034..0000000 --- a/.local/bin/i3cmds/ddspawn +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -# Toggle floating dropdown terminal in i3, or start if non-existing. -# $1 is the script run in the terminal. -# All other args are terminal settings. -# Terminal names are in dropdown_* to allow easily setting i3 settings. - -[ -z "$1" ] && exit - -script=$1 -shift -if xwininfo -tree -root | grep "(\"dropdown_$script\" "; -then - echo "Window detected." - i3 "[instance=\"dropdown_$script\"] scratchpad show; [instance=\"dropdown_$script\"] move position center" -else - echo "Window not detected... spawning." - i3 "exec --no-startup-id $TERMINAL -n dropdown_$script $@ -e $script" -fi diff --git a/.local/bin/i3cmds/displayselect b/.local/bin/i3cmds/displayselect deleted file mode 100755 index e526014..0000000 --- a/.local/bin/i3cmds/displayselect +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh - -# A UI for detecting and selecting all displays. -# Probes xrandr for connected displays and lets user select one to use. -# User may also select "manual selection" which opens arandr. -# I plan on adding a routine from multi-monitor setups later. - -twoscreen() { # If multi-monitor is selected and there are two screens. - - mirror=$(printf "no\\nyes" | dmenu -i -p "Mirror displays?") - # Mirror displays using native resolution of external display and a scaled - # version for the internal display - if [ "$mirror" = "yes" ]; then - external=$(echo "$screens" | dmenu -i -p "Optimize resolution for:") - internal=$(echo "$screens" | grep -v "$external") - - res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \ - tail -n 1 | awk '{print $1}') - res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" | \ - tail -n 1 | awk '{print $1}') - - res_ext_x=$(echo $res_external | sed 's/x.*//') - res_ext_y=$(echo $res_external | sed 's/.*x//') - res_int_x=$(echo $res_internal | sed 's/x.*//') - res_int_y=$(echo $res_internal | sed 's/.*x//') - - scale_x=$(echo "$res_ext_x / $res_int_x" | bc -l) - scale_y=$(echo "$res_ext_y / $res_int_y" | bc -l) - - xrandr --output "$external" --auto --scale 1.0x1.0 \ - --output "$internal" --auto --same-as "$external" \ - --scale "$scale_x"x"$scale_y" - else - - primary=$(echo "$screens" | dmenu -i -p "Select primary display:") - secondary=$(echo "$screens" | grep -v "$primary") - direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?") - xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0 - fi - } - -morescreen() { # If multi-monitor is selected and there are more than two screens. - primary=$(echo "$screens" | dmenu -i -p "Select primary display:") - secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:") - direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?") - tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:") - xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto - } - -multimon() { # Multi-monitor handler. - case "$(echo "$screens" | wc -l)" in - 1) xrandr $(echo "$allposs" | grep -v "$screens" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; - 2) twoscreen ;; - *) morescreen ;; - esac ;} - -# Get all possible displays -allposs=$(xrandr -q | grep "connected") - -# Get all connected screens. -screens=$(echo "$allposs" | grep " connected" | awk '{print $1}') - -# Get user choice including multi-monitor and manual selection: -chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") && -case "$chosen" in - "manual selection") arandr ; exit ;; - "multi-monitor") multimon ;; - *) 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. -remaps # Re-remap keys if keyboard added (for laptop bases) -pgrep -x dunst >/dev/null && killall dunst && setsid dunst & # Restart dunst to ensure proper location on screen diff --git a/.local/bin/i3cmds/dmenurecord b/.local/bin/i3cmds/dmenurecord deleted file mode 100755 index 6af25a9..0000000 --- a/.local/bin/i3cmds/dmenurecord +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/sh - -# Usage: -# `record`: Ask for recording type via dmenu -# `record screencast`: Record both audio and screen -# `record video`: Record only screen -# `record audio`: Record only audio -# `record kill`: Kill existing recording -# -# If there is already a running instance, user will be prompted to end it. - -updateicon() { \ - echo "$1" > /tmp/recordingicon - pkill -RTMIN+9 i3blocks - } - -killrecording() { - recpid="$(cat /tmp/recordingpid)" - # kill with SIGTERM, allowing finishing touches. - kill -15 "$recpid" - rm -f /tmp/recordingpid - updateicon "" - pkill -RTMIN+9 i3blocks - # even after SIGTERM, ffmpeg may still run, so SIGKILL it. - sleep 3 - kill -9 "$recpid" - exit - } - -screencast() { \ - ffmpeg -y \ - -f x11grab \ - -framerate 60 \ - -s $(xdpyinfo | grep dimensions | awk '{print $2;}') \ - -i $DISPLAY \ - -f alsa -i default \ - -r 30 \ - -c:v libx264rgb -crf 0 -preset ultrafast -c:a flac \ - "$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mkv" & - echo $! > /tmp/recordingpid - updateicon "βΊοΈπŸŽ™οΈ" - } - -video() { ffmpeg \ - -f x11grab \ - -s $(xdpyinfo | grep dimensions | awk '{print $2;}') \ - -i $DISPLAY \ - -c:v libx264 -qp 0 -r 30 \ - "$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" & - echo $! > /tmp/recordingpid - updateicon "⏺️" - } - -webcamhidef() { ffmpeg \ - -f v4l2 \ - -i /dev/video0 \ - -video_size 1920x1080 \ - "$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" & - echo $! > /tmp/recordingpid - updateicon "πŸŽ₯" - } - -webcam() { ffmpeg \ - -f v4l2 \ - -i /dev/video0 \ - -video_size 640x480 \ - "$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" & - echo $! > /tmp/recordingpid - updateicon "πŸŽ₯" - } - - -audio() { \ - ffmpeg \ - -f alsa -i default \ - -c:a flac \ - "$HOME/audio-$(date '+%y%m%d-%H%M-%S').flac" & - echo $! > /tmp/recordingpid - updateicon "πŸŽ™οΈ" - } - -askrecording() { \ - choice=$(printf "screencast\\nvideo\\naudio\\nwebcam\\nwebcam (hi-def)" | dmenu -i -p "Select recording style:") - case "$choice" in - screencast) screencast;; - audio) audio;; - video) video;; - webcam) webcam;; - "webcam (hi-def)") webcamhidef;; - esac - } - -asktoend() { \ - response=$(printf "No\\nYes" | dmenu -i -p "Recording still active. End recording?") && - [ "$response" = "Yes" ] && killrecording - } - - -case "$1" in - screencast) screencast;; - audio) audio;; - video) video;; - kill) killrecording;; - *) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording;; -esac diff --git a/.local/bin/i3cmds/dropdowncalc b/.local/bin/i3cmds/dropdowncalc deleted file mode 100755 index 4d41f88..0000000 --- a/.local/bin/i3cmds/dropdowncalc +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -ifinstalled bc && echo "Welcome to the Calculator." && bc -lq diff --git a/.local/bin/i3cmds/hover b/.local/bin/i3cmds/hover deleted file mode 100755 index 8d03a99..0000000 --- a/.local/bin/i3cmds/hover +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -[ -z "$1" ] && exit # If $1 is left, hovers in the bottom left, if right, the bottom right -current=$(xdotool getwindowfocus) -newwidth=$(($(xdotool getdisplaygeometry | awk '{print $2}') / 3)) -newheight=$(($(xdotool getdisplaygeometry | awk '{print $1}') / 3)) -xdotool windowsize "$current" $newheight $newwidth -newsize=$(xdotool getwindowgeometry "$current" | grep Geometry | sed -e 's/x/ /g' | awk '{print $3}') -newwidth=$(xdotool getwindowgeometry "$current" | grep Geometry | grep -o " [0-9]*") - -case "$1" in - left) horizontal=0; vertical=$(($(xdotool getdisplaygeometry | awk '{print $2}') - newsize)) ;; - right) horizontal=$(($(xdotool getdisplaygeometry | awk '{print $1}') - newwidth)) ; vertical=$(($(xdotool getdisplaygeometry | awk '{print $2}') - newsize)) ;; -esac -xdotool windowmove "$current" $horizontal $vertical diff --git a/.local/bin/i3cmds/maimpick b/.local/bin/i3cmds/maimpick deleted file mode 100755 index 07d032f..0000000 --- a/.local/bin/i3cmds/maimpick +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -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 "$(xdotool getactivewindow)" | xclip -selection clipboard -t image/png ;; - "full screen (copy)") maim | xclip -selection clipboard -t image/png ;; -esac diff --git a/.local/bin/i3cmds/samedir b/.local/bin/i3cmds/samedir deleted file mode 100755 index 88845fc..0000000 --- a/.local/bin/i3cmds/samedir +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -PID=$(xprop -id "$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')" | grep -m 1 PID | cut -d " " -f 3) -PID=$(echo "$(pstree -lpA "$PID" | tail -n 1)" | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g') -cd "$(readlink /proc/"$PID"/cwd)" -"$TERMINAL" diff --git a/.local/bin/i3cmds/td-toggle b/.local/bin/i3cmds/td-toggle deleted file mode 100755 index dc727b9..0000000 --- a/.local/bin/i3cmds/td-toggle +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# If transmission-daemon is running, will ask to kill, else will ask to start. -if pgrep -x transmission-da >/dev/null ; -then - [ "$(printf "No\\nYes" | dmenu -i -p "Kill transmission-daemon?")" = "Yes" ] && killall transmission-da && notify-send "transmission-daemon killed." -else - ifinstalled transmission-cli || exit - [ "$(printf "No\\nYes" | dmenu -i -p "Start transmission daemon?")" = "Yes" ] && transmission-daemon && notify-send "tranmission-daemon started." -fi -sleep 3 && pkill -RTMIN+7 i3blocks diff --git a/.local/bin/i3cmds/torwrap b/.local/bin/i3cmds/torwrap deleted file mode 100755 index 04e7a51..0000000 --- a/.local/bin/i3cmds/torwrap +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -ifinstalled transmission-remote-cli transmission-cli || exit - -! pgrep -x transmission-da >/dev/null && transmission-daemon && notify-send "Starting torrent daemon..." && sleep 3 && pkill -RTMIN+7 i3blocks - -$TERMINAL -e transmission-remote-cli diff --git a/.local/bin/i3cmds/tutorialvids b/.local/bin/i3cmds/tutorialvids deleted file mode 100755 index f1357eb..0000000 --- a/.local/bin/i3cmds/tutorialvids +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -vidlist=" -status bar https://www.youtube.com/watch?v=gKumet6b-WY -sxiv (image viewer) https://www.youtube.com/watch?v=GYW9i_u5PYs -st (terminal) https://www.youtube.com/watch?v=9H75enWM22k -i3 (window manager) https://www.youtube.com/watch?v=GKviflL9XeI -pacman (installing/managing programs) https://www.youtube.com/watch?v=-dEuXTMzRKs -mutt (email) https://www.youtube.com/watch?v=2U3vRbF7v5A -ncmpcpp (music player) https://www.youtube.com/watch?v=sZIEdI9TS2U -newsboat (RSS reader) https://www.youtube.com/watch?v=dUFCRqs822w -zathura (pdf viewer) https://www.youtube.com/watch?v=V_Iz4zdyRM4 -gpg keys https://www.youtube.com/watch?v=DMGIlj7u7Eo -calcurse (calendar) https://www.youtube.com/watch?v=hvc-pHjbhdE -urlview https://www.youtube.com/watch?v=IgzpAjFgbCw -colorschemes with pywal https://www.youtube.com/watch?v=Es79N_9BblE -vi mode in shell https://www.youtube.com/watch?v=GqoJQft5R2E -" -echo "$vidlist" | grep -P "^$(echo "$vidlist" | grep "https:" | sed 's/\t.*//g' | dmenu -i -p "Learn about what? (ESC to cancel)" -l 20 | awk '{print $1}')\s" | sed 's/.*\t//' | xargs -r mpv diff --git a/.local/bin/i3cmds/winresize b/.local/bin/i3cmds/winresize deleted file mode 100755 index 090bbf3..0000000 --- a/.local/bin/i3cmds/winresize +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -echo "πŸ“" | dmenu -p "Give width and height:" | xargs xdotool windowsize "$(xdotool getwindowfocus)" diff --git a/.local/bin/sxhkd/dmenumount b/.local/bin/sxhkd/dmenumount new file mode 100755 index 0000000..0de5f0f --- /dev/null +++ b/.local/bin/sxhkd/dmenumount @@ -0,0 +1,59 @@ +#!/bin/sh +# Gives a dmenu prompt to mount unmounted drives. +# If they're in /etc/fstab, they'll be mounted automatically. +# Otherwise, you'll be prompted to give a mountpoint from already existsing directories. +# If you input a novel directory, it will prompt you to create that directory. + +getmount() { \ + [ -z "$chosen" ] && exit 1 + mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")" + [ "$mp" = "" ] && exit 1 + if [ ! -d "$mp" ]; then + mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") + [ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp") + fi + } + +mountusb() { \ + chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?" | awk '{print $1}')" + sudo -A mount "$chosen" 2>/dev/null && notify-send "πŸ’» USB mounting" "$chosen mounted." && exit 0 + alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$2=="part"&&$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not \\( -path *%s -prune \\) \\ \n",$3}') + getmount "/mnt /media /mount /home -maxdepth 5 -type d $alreadymounted" + 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" "$mp";; + esac + notify-send "πŸ’» USB mounting" "$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 Mounting" "Android device mounted to $mp." + } + +asktype() { \ + case $(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?") in + USB) mountusb ;; + Android) mountandroid ;; + esac + } + +anddrives=$(simple-mtpfs -l 2>/dev/null) +usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | awk '$2=="part"&&$4==""{printf "%s (%s)\n",$1,$3}')" + +if [ -z "$usbdrives" ]; then + [ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit + echo "Android device(s) detected." + mountandroid +else + if [ -z "$anddrives" ]; then + echo "USB drive(s) detected." + mountusb + else + echo "Mountable USB drive(s) and Android device(s) detected." + asktype + fi +fi diff --git a/.local/bin/i3cmds/dmenuumount b/.local/bin/sxhkd/dmenuumount similarity index 100% rename from .local/bin/i3cmds/dmenuumount rename to .local/bin/sxhkd/dmenuumount diff --git a/.local/bin/sxhkd/ducksearch b/.local/bin/sxhkd/ducksearch new file mode 100755 index 0000000..2639413 --- /dev/null +++ b/.local/bin/sxhkd/ducksearch @@ -0,0 +1,20 @@ +#!/bin/sh +# Gives a dmenu prompt to search DuckDuckGo. +# Without input, will open DuckDuckGo.com. +# URLs will be directly handed to the browser. +# Anything else, it search it. +browser=${BROWSER:-firefox} + +pgrep -x dmenu && exit + +choice=$(echo "πŸ¦†" | dmenu -i -p "Search DuckDuckGo:") || exit 1 + +if [ "$choice" = "πŸ¦†" ]; then + $RTV_BROWSER "https://duckduckgo.com" +else + if echo "$choice" | grep "^(http:\/\/|https:\/\/)?[a-zA-Z0-9]+\.[a-zA-Z]+(/)?.*$"; then + $RTV_BROWSER "$choice" + else + $RTV_BROWSER "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1" + fi +fi diff --git a/.local/bin/tools/compiler b/.local/bin/tools/compiler deleted file mode 100755 index f9e80bd..0000000 --- a/.local/bin/tools/compiler +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -# This script will compile or run another finishing operation on a document. I -# have this script run via vim. -# -# 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%.*}" - -cd "$dir" || exit - -textype() { \ - command="pdflatex" - ( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex" - $command --output-directory="$dir" "$base" && - grep -i addbibresource "$file" >/dev/null && - biber --input-directory "$dir" "$base" && - $command --output-directory="$dir" "$base" && - $command --output-directory="$dir" "$base" - } - -case "$file" in - *\.ms) refer -PS -e "$file" | groff -me -ms -kept -T pdf > "$base".pdf ;; - *\.mom) refer -PS -e "$file" | groff -mom -kept -T pdf > "$base".pdf ;; - *\.[0-9]) refer -PS -e "$file" | groff -mandoc -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) sudo make install ;; - *\.c) cc "$file" -o "$base" && "$base" ;; - *\.py) python "$file" ;; - *\.go) go run "$file" ;; - *\.sent) setsid sent "$file" 2>/dev/null & ;; - *) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;; -esac diff --git a/.local/bin/tools/ext b/.local/bin/tools/ext deleted file mode 120000 index 562d2b3..0000000 --- a/.local/bin/tools/ext +++ /dev/null @@ -1 +0,0 @@ -extract \ No newline at end of file diff --git a/.local/bin/tools/extract b/.local/bin/tools/extract deleted file mode 100755 index a63ab10..0000000 --- a/.local/bin/tools/extract +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# A general, all-purpose extraction script. -# -# Default behavior: Extract archive into new directory -# Behavior with `-c` option: Extract contents into current directory - -while getopts "hc" o; do case "${o}" in - c) extracthere="True" ;; - *) printf "Options:\\n -c: Extract archive into current directory rather than a new one.\\n" && exit ;; -esac done - -if [ -z "$extracthere" ]; then - archive="$(readlink -f "$*")" && - directory="$(echo "$archive" | sed 's/\.[^\/.]*$//')" && - mkdir -p "$directory" && - cd "$directory" || exit -else - archive="$(readlink -f "$(echo "$*" | cut -d' ' -f2)")" -fi - -[ "$archive" = "" ] && printf "Give archive to extract as argument.\\n" && exit - -if [ -f "$archive" ] ; then - case "$archive" in - *.tar.bz2|*.tar.xz|*.tbz2) tar xvjf "$archive" ;; - *.tar.gz|*.tgz) tar xvzf "$archive" ;; - *.lzma) unlzma "$archive" ;; - *.bz2) bunzip2 "$archive" ;; - *.rar) unrar x -ad "$archive" ;; - *.gz) gunzip "$archive" ;; - *.tar) tar xvf "$archive" ;; - *.zip) unzip "$archive" ;; - *.Z) uncompress "$archive" ;; - *.7z) 7z x "$archive" ;; - *.xz) unxz "$archive" ;; - *.exe) cabextract "$archive" ;; - *) printf "extract: '%s' - unknown archive method\\n" "$archive" ;; - esac -else - printf "File \"%s\" not found.\\n" "$archive" -fi diff --git a/.local/bin/tools/getbib b/.local/bin/tools/getbib deleted file mode 100755 index ed441c5..0000000 --- a/.local/bin/tools/getbib +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -[ -z "$1" ] && echo "Give either a pdf file or a DOI as an argument." && exit - -if [ -f "$1" ]; then - # Try to get DOI from pdfinfo or pdftotext output. - doi=$(pdfinfo "$1" | grep -io "doi:.*") || - doi=$(pdftotext "$1" 2>/dev/null - | grep -io "doi:.*" -m 1) || - exit 1 -else - doi="$1" -fi - -# Check crossref.org for the bib citation. -curl -s "http://api.crossref.org/works/$doi/transform/application/x-bibtex" -w "\\n" diff --git a/.local/bin/tools/getkeys b/.local/bin/tools/getkeys deleted file mode 100755 index 444f4c0..0000000 --- a/.local/bin/tools/getkeys +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -cat ~/.config/getkeys/"$1" 2>/dev/null && exit -echo "Run command with one of the following arguments for info about that program:" -ls ~/.config/getkeys diff --git a/.local/bin/tools/lmc b/.local/bin/tools/lmc index 18cf2c2..c3f8d8e 100755 --- a/.local/bin/tools/lmc +++ b/.local/bin/tools/lmc @@ -7,35 +7,16 @@ case "$1" in u*) pulsemixer --change-volume +"$num" ;; d*) pulsemixer --change-volume -"$num" ;; m*) pulsemixer --toggle-mute ;; - truemute) pulsemixer --mute ;; - play) mpc play ;; - n*) mpc next ;; - prev) mpc prev ;; - t*) mpc toggle ;; - p*) mpc pause ; pauseallmpv ;; - f*) mpc seek +"$num" ;; - b*) mpc seek -"$num" ;; - r*) mpc seek 0% ;; *) cat << EOF -lmc: cli music interface for mpd and pulse for those with divine intellect too -grand to remember the mpc/pamixer commands. +lmc: cli music interface for pulse for those with divine intellect too +grand to remember the pamixer commands. Allowed options: up NUM Increase volume (2 secs default) down NUM Decrease volume (2 secs default) mute Toggle mute - truemute Mute - next Next track - prev Previous track - toggle Toggle pause - truepause Pause - foward NUM Seek foward in song (2 secs default) - back NUM Seek back in song (2 secs default) - restart Restart current song all else Print this message -All of these commands, except for \`truemute\`, \`prev\` and \`play\` can be truncated, -i.e. \`lmc r\` for \`lmc restart\`. EOF esac diff --git a/.local/bin/tools/opout b/.local/bin/tools/opout deleted file mode 100755 index c742aa9..0000000 --- a/.local/bin/tools/opout +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -# opout: "open output": A general handler for opening a file's intended output. -# I find this useful especially running from vim. - -basename="$(echo "$1" | sed 's/\.[^\/.]*$//')" - -case "$1" in - *.tex|*.md|*.rmd|*.ms|*.me|*.mom) setsid "$READER" "$basename".pdf >/dev/null 2>&1 & ;; - *.html) setsid "$BROWSER" --new-window "$basename".html >/dev/null 2>&1 & ;; - *.sent) setsid sent "$1" >/dev/null 2>&1 & ;; -esac diff --git a/.local/bin/tools/pauseallmpv b/.local/bin/tools/pauseallmpv deleted file mode 100755 index c5da220..0000000 --- a/.local/bin/tools/pauseallmpv +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -for i in $(ls /tmp/mpvsoc*); do - echo '{ "command": ["set_property", "pause", true] }' | socat - $i; -done diff --git a/.local/bin/tools/podentr b/.local/bin/tools/podentr deleted file mode 100755 index 13ab4a8..0000000 --- a/.local/bin/tools/podentr +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -# entr command to run `queueandnotify` when newsboat queue is changed - -[ "$(pgrep -x $(basename $0) | wc -l)" -gt 2 ] && exit - -echo ~/.local/share/newsboat/queue | entr -p queueandnotify 2>/dev/null diff --git a/.local/bin/i3cmds/prompt b/.local/bin/tools/prompt similarity index 60% rename from .local/bin/i3cmds/prompt rename to .local/bin/tools/prompt index 56de2f8..344a1ba 100755 --- a/.local/bin/i3cmds/prompt +++ b/.local/bin/tools/prompt @@ -4,4 +4,4 @@ # For example: # `./prompt "Do you want to shutdown?" "shutdown -h now"` -[ "$(printf "No\\nYes" | dmenu -i -p "$1" -nb darkred -sb red -sf white -nf gray )" = "Yes" ] && $2 +[ "$(printf "No\\nYes" | dmenu -i -fn Monospace-15 -p "$1" -nb darkred -sb red -sf white -nf gray )" = "Yes" ] && $2 diff --git a/.local/bin/tools/qndl b/.local/bin/tools/qndl deleted file mode 100755 index a99d37e..0000000 --- a/.local/bin/tools/qndl +++ /dev/null @@ -1,11 +0,0 @@ -#!/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/.local/bin/tools/queueandnotify b/.local/bin/tools/queueandnotify deleted file mode 100755 index a1417ec..0000000 --- a/.local/bin/tools/queueandnotify +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# Podboat sucks. This script replaces it. -# It reads the newsboat queue, queuing downloads with taskspooler. -# It also removes the junk from extentions. -queuefile="$HOME/.local/share/newsboat/queue" - -while read -r line; do - [ -z "$line" ] && continue - url="$(echo "$line" | awk '{print $1}')" - qndl "$url" "curl -LO" -done < "$queuefile" - -echo > "$queuefile" diff --git a/.local/bin/tools/remaps b/.local/bin/tools/remaps deleted file mode 100755 index d4de05f..0000000 --- a/.local/bin/tools/remaps +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# This script is called by i3 on startup to remap keys. -# Increase key speed via a rate change -xset r rate 300 50 diff --git a/.local/bin/tools/rotdir b/.local/bin/tools/rotdir deleted file mode 100755 index e7103db..0000000 --- a/.local/bin/tools/rotdir +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -[ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1 -base="$(basename $1)" - ls "$PWD" | awk "BEGIN { lines = \"\"; m = 0; } /^$base$/ { m = 1; } { if (!m) { if (lines) { lines = lines\"\n\"; } lines = lines\"\"\$0; } else { print \$0; } } END { print lines; }" diff --git a/.local/bin/tools/rssadd b/.local/bin/tools/rssadd deleted file mode 100755 index 8822fc5..0000000 --- a/.local/bin/tools/rssadd +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -! echo "$1" | grep "https*://\S\+\.[A-Za-z]\+\S*" >/dev/null && - notify-send "That doesn't look like a full URL." && exit -RSSFILE="$HOME/.config/newsboat/urls" -if awk '{print $1}' "$RSSFILE" | grep "^$1$" >/dev/null; then - notify-send "You already have this RSS feed." -else - echo "$1" >> "$RSSFILE" && notify-send "RSS feed added." -fi diff --git a/.local/bin/tools/shortcuts b/.local/bin/tools/shortcuts deleted file mode 100755 index 1c4f278..0000000 --- a/.local/bin/tools/shortcuts +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# Output locations. Unactivated progs should go to /dev/null. -shell_shortcuts="$HOME/.config/shortcutrc" -ranger_shortcuts="/dev/null" -qute_shortcuts="/dev/null" -fish_shortcuts="/dev/null" -vifm_shortcuts="$HOME/.config/vifm/vifmshortcuts" - -# Remove, prepare files -rm -f "$ranger_shortcuts" "$qute_shortcuts" 2>/dev/null -printf "# vim: filetype=sh\\n" > "$fish_shortcuts" -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/.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 "\nmap t" $1, ":cd", $2 "\nmap M" $1, ":cd", $2 ":mo\nmap Y" $1, ":cd", $2 ":co" }' >> "$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/.config/bmfiles" | tee >(awk '{print $1"=\"$EDITOR "$2"\" \\"}' >> "$shell_shortcuts") \ - >(awk '{print "abbr", $1, "\"$EDITOR "$2"\""}' >> "$fish_shortcuts") \ - >(awk '{print "map", $1, ":e", $2 "" }' >> "$vifm_shortcuts") \ - | awk '{print "map "$1" shell $EDITOR "$2}' >> "$ranger_shortcuts" diff --git a/.local/bin/tools/texclear b/.local/bin/tools/texclear deleted file mode 100755 index f6a5062..0000000 --- a/.local/bin/tools/texclear +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -# Clears the build files of a LaTeX/XeLaTeX build. -# I have vim run this file whenever I exit a .tex file. - -case "$1" in - *.tex) - 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|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/.local/bin/i3cmds/toggletouchpad b/.local/bin/tools/toggletouchpad similarity index 100% rename from .local/bin/i3cmds/toggletouchpad rename to .local/bin/tools/toggletouchpad diff --git a/.local/bin/tools/transadd b/.local/bin/tools/transadd deleted file mode 100755 index ad2ee7f..0000000 --- a/.local/bin/tools/transadd +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -# Mimeapp script for adding torrent to transmission-daemon, but will also start the daemon first if not running. - -# transmission-daemon sometimes fails to take remote requests in its first moments. - -pgrep -x transmission-da || (transmission-daemon && notify-send "Starting transmission daemon..." && sleep 3 && pkill -RTMIN+7 i3blocks) - -transmission-remote -a "$@" && notify-send "πŸ”½ Torrent added." diff --git a/.local/bin/tools/vifmimg b/.local/bin/tools/vifmimg deleted file mode 100755 index 1569962..0000000 --- a/.local/bin/tools/vifmimg +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -[ -z "$FIFO_UEBERZUG" ] && exit - -readonly ID_PREVIEW="preview" - -if [ "$1" = "draw" ]; then - declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" [x]="$2" [y]="$3" [max_width]="$4" [max_height]="$5" [path]="${PWD}/$6") > "$FIFO_UEBERZUG" -elif [ "$1" = "videopreview" ]; then - [ ! -f "/tmp/$6.png" ] && ffmpegthumbnailer -i "${PWD}/$6" -o "/tmp/$6.png" -s 0 -q 10 && - declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" [x]="$2" [y]="$3" [max_width]="$4" [max_height]="$5" [path]="/tmp/$6.png") > "$FIFO_UEBERZUG" -else - declare -p -A cmd=([action]=remove [identifier]="$ID_PREVIEW") > "$FIFO_UEBERZUG" -fi diff --git a/.local/bin/tools/vu b/.local/bin/tools/vu deleted file mode 100755 index 778835a..0000000 --- a/.local/bin/tools/vu +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env sh -export FIFO_UEBERZUG="/tmp/vifm-ueberzug-${PPID}" - -cleanup() { - rm "$FIFO_UEBERZUG" 2>/dev/null - pkill -P $$ 2>/dev/null -} - -rm "$FIFO_UEBERZUG" 2>/dev/null -mkfifo "$FIFO_UEBERZUG" -trap cleanup EXIT -tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser bash & - -vifm -cleanup