summaryrefslogtreecommitdiffstats
path: root/.scripts
diff options
context:
space:
mode:
Diffstat (limited to '.scripts')
-rw-r--r--.scripts/SCRIPTS.md12
-rwxr-xr-x.scripts/compiler33
-rwxr-xr-x.scripts/ddspawn26
-rwxr-xr-x.scripts/dmenumount23
-rwxr-xr-x.scripts/dmenuumount13
-rwxr-xr-x.scripts/dropdowncalc2
-rwxr-xr-x.scripts/ducksearch15
-rwxr-xr-x.scripts/extract7
-rwxr-xr-x.scripts/i3pacman2
-rwxr-xr-x.scripts/i3volume20
-rwxr-xr-x.scripts/i3wifi14
-rwxr-xr-x.scripts/lmc47
-rwxr-xr-x.scripts/newsup1
-rwxr-xr-x.scripts/tmuxdd (renamed from .scripts/tmuxinit)2
-rwxr-xr-x.scripts/tutorialvids2
15 files changed, 168 insertions, 51 deletions
diff --git a/.scripts/SCRIPTS.md b/.scripts/SCRIPTS.md
index 7e794c1..cd16f20 100644
--- a/.scripts/SCRIPTS.md
+++ b/.scripts/SCRIPTS.md
@@ -28,6 +28,12 @@ Turns off/on all user cronjobs.
Select which displays to use. Bound to `mod+F3`.
+## `dmenuarchwiki`
+
+Bind this script to a key and it will give you a prompt to search for a term in
+the Arch Wiki. Used to be binded to `mod+F11`, but has been replaced by
+`ducksearch` there.
+
## `dmenuhandler`
Give this script a url and it will offer dmenu options for opening it. Used by
@@ -53,6 +59,12 @@ if none are mounted.
The command initially run in the `math` window (toggeable with `mod+a`). Runs
`r` if available, else `python`.
+## `ducksearch`
+
+Show a dmenu prompt and search for the inputed text in DuckDuckGo. Can take
+bangtags as expected, i.e. typing in `!aw Arch Linux` will search the Arch Wiki
+for "Arch Linux" or `!yt Luke Smith` will search YouTube for "Luke Smith", etc.
+
## `extract`
Will detect file type of archive and run appropriate extraction command.
diff --git a/.scripts/compiler b/.scripts/compiler
index cb47638..7338d30 100755
--- a/.scripts/compiler
+++ b/.scripts/compiler
@@ -1,20 +1,27 @@
#!/bin/sh
# This script will compile or run another finishing operation on a document. I
-# have this script run via vim.
+# have this script run via vim/emacs.
#
# 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
+
oridir=$(pwd)
file=$(readlink -f "$1")
dir=$(dirname "$file")
base="${file%.*}"
-cd "$dir" || exit
+shebang=$(sed -n 1p $file)
+
+cd $dir
+
textype() { \
command="pdflatex"
@@ -26,11 +33,27 @@ textype() { \
$command --output-directory="$dir" "$base"
}
+shebangtest() {
+ case "$shebang" in
+ \#\!*) "$file" ;;
+ *) sent "$file" 2>/dev/null & ;;
+ esac
+}
+
+
case "$file" in
- *\.rmd) echo "require(rmarkdown); render('$file')" | R --vanilla ;;
+ *\.rmd) echo "require(rmarkdown); render('$file')" | R --vanilla && mv "$base".pdf "$dir"/pdfs;;
*\.tex) textype "$file" ;;
*\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;;
*config.h) make && sudo make install ;;
- *) sent "$file" 2>/dev/null & ;;
+ *\.c) cc "$file" -o "$base" && "$base" ;;
+ *\.py) python "$file" ;;
+ *\.go) go run "$file" ;;
+
+
+
+ *) shebangtest ;;
+
esac
-cd "$oridir" || exit
+cd $oridir
+
diff --git a/.scripts/ddspawn b/.scripts/ddspawn
new file mode 100755
index 0000000..aedcd18
--- /dev/null
+++ b/.scripts/ddspawn
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# This script simplifies dropdown windows in i3.
+# Shows/hides a scratchpad of a given name, if it doesn't exist, creates it.
+# Usage:
+# argument 1: script to run in dropdown window
+# all other args are interpreted as options for your terminal
+# My usage:
+# ddpawn
+# bindsym $mod+u exec --no-startup-id ddspawn tmuxdd
+# Will hide/show window running the `tmuxdd` script when I press mod+u in i3
+# bindsym $mod+a exec --no-startup-id ddspawn dropdowncalc -f mono:pixelsize=24
+# Similar to above but with `dropdowncalc` and the other args are interpretated as for my terminal emulator (to increase font)
+
+
+[ -z "$1" ] && exit
+
+if xwininfo -tree -root | grep "(\"$1\" ";
+then
+ echo "Window detected."
+else
+ echo "Window not detected... spawning."
+ i3 "exec --no-startup-id $TERMINAL -n $1 $(echo "$@" | cut -d ' ' -f2-) -e $1" && i3 "[instance=\"$1\"] scratchpad show; [instance=\"$1\"] move position center"
+ sleep .25 # This sleep is my laziness, will fix later (needed for immediate appearance after spawn).
+fi
+i3 "[instance=\"$1\"] scratchpad show; [instance=\"$1\"] move position center"
diff --git a/.scripts/dmenumount b/.scripts/dmenumount
index 33060c2..1aadf01 100755
--- a/.scripts/dmenumount
+++ b/.scripts/dmenumount
@@ -7,7 +7,7 @@ pgrep -x dmenu && exit
getmount() { \
[ -z "$chosen" ] && exit 1
- mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")"
+ 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?")
@@ -16,17 +16,14 @@ getmount() { \
}
mountusb() { \
- drives="$(lsblk -rpo "name,type,size,mountpoint" | awk '$2=="part"&&$4==""{printf "%s (%s)\n",$1,$3}')"
+ chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?" | awk '{print $1}')"
sudo -A mount "$chosen" && exit 0
- [ -z "$drives" ] && exit 1
- chosen="$(echo "$drives" | dmenu -i -p "Mount which drive?" | awk '{print $1}')"
getmount "/mnt /media /mount /home -type d -maxdepth 5"
sudo -A mount "$chosen" "$mp" && pgrep -x dunst && notify-send "$chosen mounted to $mp."
}
mountandroid() { \
- drives=$(simple-mtpfs -l)
- chosen=$(echo "$drives" | dmenu -i -p "Which Android device?" | cut -d : -f 1)
+ chosen=$(echo "$anddrives" | dmenu -i -p "Which Android device?" | cut -d : -f 1)
getmount "$HOME -type d -maxdepth 3"
simple-mtpfs --device "$chosen" "$mp"
echo simple-mtpfs --device "$chosen" "$mp"
@@ -39,8 +36,16 @@ asktype() { \
esac
}
-if simple-mtpfs -l; then
- asktype
+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 detected."
+ mountandroid
else
- mountusb
+ echo "USB drive(s) detected."
+ [ -z "$anddrives" ] && echo "USB drive detected." && mountusb
+ echo "Mountable USB drive(s) and Android device(s) detected."
+ asktype
fi
diff --git a/.scripts/dmenuumount b/.scripts/dmenuumount
index 95393db..c169326 100755
--- a/.scripts/dmenuumount
+++ b/.scripts/dmenuumount
@@ -4,7 +4,6 @@
# Drives mounted at /, /boot and /home will not be options to unmount.
unmountusb() {
- drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$2=="part"&&$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')
[ -z "$drives" ] && exit
chosen=$(echo "$drives" | dmenu -i -p "Unmount which drive?" | awk '{print $1}')
[ -z "$chosen" ] && exit
@@ -24,8 +23,14 @@ asktype() { \
esac
}
-if grep simple-mtpfs /etc/mtab; then
- asktype
-else
+drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$2=="part"&&$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')
+
+if ! grep simple-mtpfs /etc/mtab; then
+ [ -z "$drives" ] && echo "No drives to unmount." && exit
+ echo "Unmountable USB drive detected."
unmountusb
+else
+ [ -z "$drives" ] && echo "Unmountable Android device detected." && unmountandroid
+ echo "Unmountable USB drive(s) and Android device(s) detected."
+ asktype
fi
diff --git a/.scripts/dropdowncalc b/.scripts/dropdowncalc
index 7c4dbff..fee8f07 100755
--- a/.scripts/dropdowncalc
+++ b/.scripts/dropdowncalc
@@ -2,4 +2,4 @@
# 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) || python -q
+([ -e /usr/bin/R ] && R -q --no-save) || python -q
diff --git a/.scripts/ducksearch b/.scripts/ducksearch
new file mode 100755
index 0000000..13a1e19
--- /dev/null
+++ b/.scripts/ducksearch
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Gives a dmenu prompt to search DuckDuckGo.
+# Without input, will open DuckDuckGo.com.
+# Anything else, it search it.
+
+pgrep -x dmenu && exit
+
+choice=$(echo "🦆" | dmenu -i -p "Search DuckDuckGo:") || exit 1
+
+if [ "$choice" = "🦆" ]; then
+ $BROWSER "https://duckduckgo.com"
+else
+ $BROWSER "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1"
+fi
diff --git a/.scripts/extract b/.scripts/extract
index 40f4d66..c214583 100755
--- a/.scripts/extract
+++ b/.scripts/extract
@@ -22,16 +22,13 @@ fi
if [ -f "$archive" ] ; then
case "$archive" in
- *.tar.bz2) tar xvjf "$archive" ;;
- *.tar.gz) tar xvzf "$archive" ;;
- *.tar.xz) tar xvJf "$archive" ;;
+ *.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" ;;
- *.tbz2) tar xvjf "$archive" ;;
- *.tgz) tar xvzf "$archive" ;;
*.zip) unzip "$archive" ;;
*.Z) uncompress "$archive" ;;
*.7z) 7z x "$archive" ;;
diff --git a/.scripts/i3pacman b/.scripts/i3pacman
index acf69c1..6825b92 100755
--- a/.scripts/i3pacman
+++ b/.scripts/i3pacman
@@ -10,4 +10,4 @@ case $BLOCK_BUTTON in
1) $TERMINAL -e "popupgrade" ;;
esac
-yay -Qu | wc -l | sed -e "s/^0$//g"
+yay -Qu | sed -e '/^Get/d' | wc -l | sed -e "s/^0$//g"
diff --git a/.scripts/i3volume b/.scripts/i3volume
index 6dc72cd..9492906 100755
--- a/.scripts/i3volume
+++ b/.scripts/i3volume
@@ -1,12 +1,22 @@
-#!/bin/bash
+#!/bin/sh
case $BLOCK_BUTTON in
- 1) $TERMINAL -e pulsemixer & disown ;;
+ 1) setsid "$TERMINAL" -e pulsemixer & ;;
3) pulsemixer --toggle-mute ;;
4) pulsemixer --change-volume +5 ;;
5) pulsemixer --change-volume -5 ;;
esac
-printpastatus() { [[ $(pulsemixer --get-mute) = 1 ]] && echo -n 🔇 " " && exit
-echo 🔊 $(pulsemixer --get-volume | sed -e "s/\s[0-9][0-9]*//g")% ;}
-printpastatus
+[ "$(pulsemixer --get-mute)" = "1" ] && printf "🔇\\n" && exit
+
+vol=$(pulsemixer --get-volume | awk '{print $1}')
+
+if [ "$vol" -gt "70" ]; then
+ icon="🔊"
+elif [ "$vol" -lt "30" ]; then
+ icon="🔈"
+else
+ icon="🔉"
+fi
+
+printf "%s %s%%\\n" "$icon" "$vol"
diff --git a/.scripts/i3wifi b/.scripts/i3wifi
index 3fe5fb0..b9f79ec 100755
--- a/.scripts/i3wifi
+++ b/.scripts/i3wifi
@@ -8,18 +8,18 @@ INTERFACE="${BLOCK_INSTANCE:-wlan0}"
[[ "$(cat /sys/class/net/$INTERFACE/operstate)" = 'down' ]] && echo 📡 && exit
-QUALITY=$(grep $INTERFACE /proc/net/wireless | awk '{ print int($3 * 100 / 70) }')
+QUALITY=$(grep $INTERFACE /proc/net/wireless | awk '{ print int($3 * 100 / 70 - 1) }')
echo 📶 $QUALITY%
echo 📶 $QUALITY%
# color
if [[ $QUALITY -ge 80 ]]; then
- echo "#00FF00"
-elif [[ $QUALITY -lt 80 ]]; then
- echo "#FFF600"
-elif [[ $QUALITY -lt 60 ]]; then
- echo "#FFAE00"
+ echo "#00FF00"
elif [[ $QUALITY -lt 40 ]]; then
- echo "#FF0000"
+ echo "#FF0000"
+elif [[ $QUALITY -lt 60 ]]; then
+ echo "#FF8000"
+elif [[ $QUALITY -lt 80 ]]; then
+ echo "#FFF600"
fi
diff --git a/.scripts/lmc b/.scripts/lmc
index f506e9a..9c92f3f 100755
--- a/.scripts/lmc
+++ b/.scripts/lmc
@@ -3,18 +3,41 @@
# A general audio interface for LARBS.
newvol="pkill -RTMIN+10 i3blocks"
-# Uncomment if i3mpdupdate isn't running:
+
+[ -z "$2" ] && num="2" || num="$2"
case "$1" in
- "up") pulsemixer --change-volume +"$2" ; $newvol ;;
- "down") pulsemixer --change-volume -"$2" ; $newvol ;;
- "mute") pulsemixer --toggle-mute ; $newvol ;;
- "truemute") pulsemixer --mute ; $newvol ;;
- "toggle") mpc toggle ;;
- "pause") mpc pause ; pauseallmpv ;;
- "forward") mpc seek +"$2" ;;
- "back") mpc seek -"$2" ;;
- "next") mpc next ;;
- "prev") mpc prev ;;
- "replay") mpc seek 0% ;;
+ u*) pulsemixer --change-volume +"$num" ; $newvol ;;
+ d*) pulsemixer --change-volume -"$num" ; $newvol ;;
+ m*) pulsemixer --toggle-mute ; $newvol ;;
+ truemute) pulsemixer --mute ; $newvol ;;
+ 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.
+
+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/.scripts/newsup b/.scripts/newsup
index 986524a..ab4116e 100755
--- a/.scripts/newsup
+++ b/.scripts/newsup
@@ -1,5 +1,6 @@
#!/bin/sh
+ping -q -t 1 -c 1 `ip r | grep -m 1 default | cut -d ' ' -f 3` >/dev/null || exit
echo "📰 🔃" > ~/.newsup
pkill -RTMIN+6 i3blocks
printf "Loading new RSS entries for newsboat...\\n"
diff --git a/.scripts/tmuxinit b/.scripts/tmuxdd
index 68a4b86..c194ff1 100755
--- a/.scripts/tmuxinit
+++ b/.scripts/tmuxdd
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# This is the script that i3 runs to either start tmux in
# the dropdown terminal or log into a previous session.
tmux a || tmux
diff --git a/.scripts/tutorialvids b/.scripts/tutorialvids
index ed607fd..f248253 100755
--- a/.scripts/tutorialvids
+++ b/.scripts/tutorialvids
@@ -14,4 +14,4 @@ urlview https://www.youtube.com/watch?v=IgzpAjFgbCw
vi mode in shell https://www.youtube.com/watch?v=GqoJQft5R2E
"
-mpv $(grep -P "^$(grep https: <<< $vidlist | sed 's/\t.*//g' | dmenu -i -p "Learn about what? (ESC to cancel)" -l 5)\t" <<<$vidlist | sed 's/.*\t//')
+mpv "$(echo "$vidlist" | grep -P "^$(echo "$vidlist" | grep "https:" | sed 's/\t.*//g' | dmenu -i -p "Learn about what? (ESC to cancel)" -l 5)\\t" | sed 's/.*\t//')"