summaryrefslogtreecommitdiff
path: root/.local/bin
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/displayselect70
-rwxr-xr-x.local/bin/dmenu_shudown12
-rwxr-xr-x.local/bin/dmenupass7
-rwxr-xr-x.local/bin/doc_compiler38
-rwxr-xr-x.local/bin/edit_screen.sh5
-rwxr-xr-x.local/bin/internet_test3
-rwxr-xr-x.local/bin/linkhandler22
-rwxr-xr-x.local/bin/mpdup8
-rwxr-xr-x.local/bin/newsup17
-rwxr-xr-x.local/bin/opout14
-rwxr-xr-x.local/bin/read_books8
-rwxr-xr-x.local/bin/set_wallpaper10
-rwxr-xr-x.local/bin/statusbar/battery34
-rwxr-xr-x.local/bin/statusbar/clock30
-rwxr-xr-x.local/bin/statusbar/mailbox20
-rwxr-xr-x.local/bin/statusbar/music19
-rwxr-xr-x.local/bin/statusbar/news18
-rwxr-xr-x.local/bin/statusbar/volume38
-rwxr-xr-x.local/bin/statusbar/weather35
-rwxr-xr-x.local/bin/texclear13
-rwxr-xr-x.local/bin/unix26
21 files changed, 447 insertions, 0 deletions
diff --git a/.local/bin/displayselect b/.local/bin/displayselect
new file mode 100755
index 0000000..745fdeb
--- /dev/null
+++ b/.local/bin/displayselect
@@ -0,0 +1,70 @@
+#!/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.
+
+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
+
+pgrep -x dunst >/dev/null && killall dunst && setsid dunst & # Restart dunst to ensure proper location on screen
diff --git a/.local/bin/dmenu_shudown b/.local/bin/dmenu_shudown
new file mode 100755
index 0000000..ed868e7
--- /dev/null
+++ b/.local/bin/dmenu_shudown
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+choice=$(printf "no\\nYES" | dmenu -p "Shutdown?")
+
+if [ "$choice" = "YES" ]; then
+
+ choice=$(printf "no\\nYES" | dmenu -p "Are you sure?")
+ if [ "$choice" = "YES" ]; then
+ echo "Shutting down"
+ # shutdown -h now
+ fi
+fi
diff --git a/.local/bin/dmenupass b/.local/bin/dmenupass
new file mode 100755
index 0000000..59aa75f
--- /dev/null
+++ b/.local/bin/dmenupass
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# This script is the SUDO_ASKPASS variable, meaning that it will be used as a
+# password prompt if needed.
+
+dmenu -fn "Monospace-18" -P -p "$1" <&- && echo
+
diff --git a/.local/bin/doc_compiler b/.local/bin/doc_compiler
new file mode 100755
index 0000000..1ae86bc
--- /dev/null
+++ b/.local/bin/doc_compiler
@@ -0,0 +1,38 @@
+#!/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 ;;
+ *\.[rR]md) Rscript -e "require(rmarkdown); rmarkdown::render('$file', quiet=TRUE)" ;;
+ *\.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/edit_screen.sh b/.local/bin/edit_screen.sh
new file mode 100755
index 0000000..39eda14
--- /dev/null
+++ b/.local/bin/edit_screen.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+tmpfile=$(mktemp /tmp/st-edit.XXXXXX)
+trap 'rm "$tmpfile"' 0 1 15
+cat > "$tmpfile"
+$TERMINAL -e "$EDITOR" "$tmpfile"
diff --git a/.local/bin/internet_test b/.local/bin/internet_test
new file mode 100755
index 0000000..099be10
--- /dev/null
+++ b/.local/bin/internet_test
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+ping -c 3 jacksontaylor.xyz
diff --git a/.local/bin/linkhandler b/.local/bin/linkhandler
new file mode 100755
index 0000000..7c7e96f
--- /dev/null
+++ b/.local/bin/linkhandler
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# Feed script a url or file location.
+# 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.
+
+# If no url given. Opens browser. For using script as $BROWSER.
+[ -z "$1" ] && { "$BROWSER"; exit; }
+
+case "$1" in
+ *mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*)
+ setsid -f mpv -quiet "$1" >/dev/null 2>&1 ;;
+ *png|*jpg|*jpe|*jpeg|*gif)
+ 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 -f tsp curl -LO "$1" >/dev/null 2>&1 ;;
+ *)
+ if [ -f "$1" ]; then "$TERMINAL" -e "$EDITOR" "$1"
+ else setsid -f "$BROWSER" "$1" >/dev/null 2>&1; fi ;;
+esac
diff --git a/.local/bin/mpdup b/.local/bin/mpdup
new file mode 100755
index 0000000..af81a7d
--- /dev/null
+++ b/.local/bin/mpdup
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+# This loop will update the mpd statusbar module whenever a command changes the
+# music player's status. mpd must be running on X's start for this to work.
+
+while : ; do
+ mpc idle >/dev/null && kill -45 "$(pidof "${STATUSBAR:-dwmblocks}")" || break
+done
diff --git a/.local/bin/newsup b/.local/bin/newsup
new file mode 100755
index 0000000..29f2b3c
--- /dev/null
+++ b/.local/bin/newsup
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# Set as a cron job to check for new RSS entries for newsboat.
+# If newsboat is open, sends it an "R" key to refresh.
+
+ping -q -c 1 example.org > /dev/null || exit
+
+/usr/bin/notify-send "πŸ“° Updating RSS feeds..."
+
+pgrep -f newsboat$ && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --name newsboat)" R && exit
+
+echo πŸ”ƒ > /tmp/newsupdate
+pkill -RTMIN+6 "${STATUSBAR:-dwmblocks}"
+/usr/bin/newsboat -x reload
+rm -f /tmp/newsupdate
+pkill -RTMIN+6 "${STATUSBAR:-dwmblocks}"
+/usr/bin/notify-send "πŸ“° RSS feed update complete."
diff --git a/.local/bin/opout b/.local/bin/opout
new file mode 100755
index 0000000..f81daa2
--- /dev/null
+++ b/.local/bin/opout
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# opout: "open output": A general handler for opening a file's intended output,
+# usually the pdf of a compiled document. I find this useful especially
+# running from vim.
+
+basename="$(echo "$1" | sed 's/\.[^\/.]*$//')"
+
+case "$1" in
+ *.tex|*.md|*.[rR]md|*.ms|*.me|*.mom) setsid "$READER" "$basename".pdf >/dev/null 2>&1 & ;;
+ *.[0-9]) setsid "$READER" "$basename".pdf >/dev/null 2>&1 & ;;
+ *.html) setsid $BROWSER "$basename".html >/dev/null 2>&1 & ;;
+ *.sent) setsid sent "$1" >/dev/null 2>&1 & ;;
+esac
diff --git a/.local/bin/read_books b/.local/bin/read_books
new file mode 100755
index 0000000..3ff2411
--- /dev/null
+++ b/.local/bin/read_books
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+#DMENU_OPTION="dmenu -fn \"hack:size=10\" -nb \"#3c302e\" -nf \"#bbbbbb\" -sb \"#a86438\" -sf \"#000000\" -l 20"
+
+#du -a ~/Documents/books/* | awk '/\.pdf/{print $2}' | dmenu -fn "hack:size=10" -nb "#3c302e" -nf "#bbbbbb" -sb "#a86438" -sf "#000000" -l 20 | xargs -r $READER ;
+book=$(du -a ~/Documents/books/* | awk '/\.pdf/{print $2}' | dmenu -fn "hack:size=10" -nb "#3c302e" -nf "#bbbbbb" -sb "#a86438" -sf "#000000" -l 20);
+if [ -n $book ]; then $READER $book; fi
+
diff --git a/.local/bin/set_wallpaper b/.local/bin/set_wallpaper
new file mode 100755
index 0000000..3229094
--- /dev/null
+++ b/.local/bin/set_wallpaper
@@ -0,0 +1,10 @@
+#!/bin/sh
+pape=$1
+
+if [ -z "$pape" ]
+then
+ pape=$WALLPAPER
+fi
+
+xwallpaper --zoom $pape
+wal -i $pape
diff --git a/.local/bin/statusbar/battery b/.local/bin/statusbar/battery
new file mode 100755
index 0000000..f42d096
--- /dev/null
+++ b/.local/bin/statusbar/battery
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+# Prints all batteries, their percentage remaining and an emoji corresponding
+# to charge status (πŸ”Œ for plugged up, πŸ”‹ for discharging on battery, etc.).
+
+case $BLOCK_BUTTON in
+ 3) notify-send "πŸ”‹ Battery module" "πŸ”‹: discharging
+πŸ›‘: not charging
+β™»: stagnant charge
+πŸ”Œ: charging
+⚑: charged
+❗: battery very low!
+- Scroll to change adjust xbacklight." ;;
+ 4) xbacklight -inc 10 ;;
+ 5) xbacklight -dec 10 ;;
+ 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+# acpi alternative
+# acpi | sed "s/Battery [0-9]: //;s/[Dd]ischarging, /πŸ”‹/;s/[Nn]ot charging, /πŸ›‘/;s/[Cc]harging, /πŸ”Œ/;s/[Uu]nknown, /♻️/;s/[Ff]ull, /⚑/;s/ \(remaining\|until charged\)//"; exit
+
+# Loop through all attached batteries.
+for battery in /sys/class/power_supply/BAT?
+do
+ # Get its remaining capacity and charge status.
+ capacity=$(cat "$battery"/capacity 2>/dev/null) || break
+ status=$(sed "s/[Dd]ischarging/πŸ”‹/;s/[Nn]ot charging/πŸ›‘/;s/[Cc]harging/πŸ”Œ/;s/[Uu]nknown/♻️/;s/[Ff]ull/⚑/" "$battery"/status)
+
+ # If it is discharging and 25% or less, we will add a ❗ as a warning.
+ [ "$capacity" -le 25 ] && [ "$status" = "πŸ”‹" ] && warn="❗"
+
+ printf "%s%s%s%% " "$status" "$warn" "$capacity"
+ unset warn
+done | sed 's/ *$//'
diff --git a/.local/bin/statusbar/clock b/.local/bin/statusbar/clock
new file mode 100755
index 0000000..04deca4
--- /dev/null
+++ b/.local/bin/statusbar/clock
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+clock=$(date '+%I')
+
+case "$clock" in
+ "00") icon="πŸ•›" ;;
+ "01") icon="πŸ•" ;;
+ "02") icon="πŸ•‘" ;;
+ "03") icon="πŸ•’" ;;
+ "04") icon="πŸ•“" ;;
+ "05") icon="πŸ•”" ;;
+ "06") icon="πŸ••" ;;
+ "07") icon="πŸ•–" ;;
+ "08") icon="πŸ•—" ;;
+ "09") icon="πŸ•˜" ;;
+ "10") icon="πŸ•™" ;;
+ "11") icon="πŸ•š" ;;
+ "12") icon="πŸ•›" ;;
+esac
+
+case $BLOCK_BUTTON in
+ 1) notify-send "This Month" "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s/..27m/<\/span><\/b>/")" && notify-send "Appointments" "$(calcurse -D ~/.config/calcurse -d3)" ;;
+ 2) setsid -f "$TERMINAL" -e calcurse -D ~/.config/calcurse ;;
+ 3) notify-send "πŸ“… Time/date module" "\- Left click to show upcoming appointments for the next three days via \`calcurse -d3\` and show the month via \`cal\`
+- Middle click opens calcurse if installed" ;;
+ 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+date "+%a %m/%d/%y $icon%I:%M%p"
+# date "+%Y %b %d (%a) $icon%I:%M%p"
diff --git a/.local/bin/statusbar/mailbox b/.local/bin/statusbar/mailbox
new file mode 100755
index 0000000..ca77f5c
--- /dev/null
+++ b/.local/bin/statusbar/mailbox
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# Displays number of unread mail and an loading icon if updating.
+# When clicked, brings up `neomutt`.
+
+case $BLOCK_BUTTON in
+ 1) setsid -f "$TERMINAL" -e neomutt ;;
+ 2) setsid -f mailsync >/dev/null ;;
+ 3) notify-send "πŸ“¬ Mail module" "\- Shows unread mail
+- Shows πŸ”ƒ if syncing mail
+- Left click opens neomutt
+- Middle click syncs mail" ;;
+ 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+unread="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/*/[Ii][Nn][Bb][Oo][Xx]/new/* -type f | wc -l 2>/dev/null)"
+
+pidof mbsync >/dev/null 2>&1 && icon="πŸ”ƒ"
+
+[ "$unread" = "0" ] && [ "$icon" = "" ] || echo "πŸ“¬$unread$icon"
diff --git a/.local/bin/statusbar/music b/.local/bin/statusbar/music
new file mode 100755
index 0000000..faba0c3
--- /dev/null
+++ b/.local/bin/statusbar/music
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+filter() { mpc | sed "/^volume:/d;s/\\&/&amp;/g;s/\\[paused\\].*/⏸/g;/\\[playing\\].*/d" | paste -sd ' ';}
+
+pidof -x mpdup >/dev/null 2>&1 || mpdup >/dev/null 2>&1 &
+
+case $BLOCK_BUTTON in
+ 1) mpc status | filter ; setsid -f "$TERMINAL" -e ncmpcpp ;; # right click, pause/unpause
+ 2) mpc toggle | filter ;; # right click, pause/unpause
+ 3) mpc status | filter ; notify-send "🎡 Music module" "\- Shows mpd song playing.
+- Italic when paused.
+- Left click opens ncmpcpp.
+- Middle click pauses.
+- Scroll changes track.";; # right click, pause/unpause
+ 4) mpc prev | filter ;; # scroll up, previous
+ 5) mpc next | filter ;; # scroll down, next
+ 6) mpc status | filter ; "$TERMINAL" -e "$EDITOR" "$0" ;;
+ *) mpc status | filter ;;
+esac
diff --git a/.local/bin/statusbar/news b/.local/bin/statusbar/news
new file mode 100755
index 0000000..a850aff
--- /dev/null
+++ b/.local/bin/statusbar/news
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Displays number of unread news items and an loading icon if updating.
+# When clicked, brings up `newsboat`.
+
+case $BLOCK_BUTTON in
+ 1) setsid "$TERMINAL" -e newsboat ;;
+ 2) setsid -f newsup >/dev/null exit ;;
+ 3) notify-send "πŸ“° News module" "\- Shows unread news items
+- Shows πŸ”ƒ if updating with \`newsup\`
+- Left click opens newsboat
+- Middle click syncs RSS feeds
+<b>Note:</b> Only one instance of newsboat (including updates) may be running at a time." ;;
+ 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+ # cat /tmp/newsupdate 2>/dev/null || echo "$(newsboat -x print-unread | awk '{ if($1>0) print "πŸ“°" $1}')$(cat "${XDG_CONFIG_HOME:-$HOME/.config}"/newsboat/.update 2>/dev/null)"
+ cat /tmp/newsupdate 2>/dev/null || echo "$(newsboat -x print-unread | awk '{ if($1>-1) print "πŸ“°" $1}')$(cat "${XDG_CONFIG_HOME:-$HOME/.config}"/newsboat/.update 2>/dev/null)"
diff --git a/.local/bin/statusbar/volume b/.local/bin/statusbar/volume
new file mode 100755
index 0000000..2766ed2
--- /dev/null
+++ b/.local/bin/statusbar/volume
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# Prints the current volume or πŸ”‡ if muted. Uses PulseAudio by default,
+# uncomment the ALSA lines if you remove PulseAudio.
+
+case $BLOCK_BUTTON in
+ # 1) setsid -f "$TERMINAL" -e alsamixer ;;
+ # 2) amixer sset Master toggle ;;
+ # 4) amixer sset Master 5%+ >/dev/null 2>/dev/null ;;
+ # 5) amixer sset Master 5%- >/dev/null 2>/dev/null ;;
+ 1) setsid -f "$TERMINAL" -e pulsemixer ;;
+ 2) pamixer -t ;;
+ 4) pamixer --allow-boost -i 1 ;;
+ 5) pamixer --allow-boost -d 1 ;;
+ 3) notify-send "πŸ“’ Volume module" "\- Shows volume πŸ”Š, πŸ”‡ if muted.
+- Middle click to mute.
+- Scroll to change." ;;
+ 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+volstat="$(pactl list sinks)"
+# volstat="$(amixer get Master)" # ALSA only equivalent.
+
+echo "$volstat" | grep -q "Mute: yes" && printf "πŸ”‡\\n" && exit
+# echo "$volstat" | grep "\[off\]" >/dev/null && printf "πŸ”‡\\n" && exit # ALSA
+
+vol="$(echo "$volstat" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")"
+# vol=$(echo "$volstat" | grep -o "\[[0-9]\+%\]" | sed "s/[^0-9]*//g;1q") # ALSA
+
+if [ "$vol" -gt "70" ]; then
+ icon="πŸ”Š"
+elif [ "$vol" -lt "30" ]; then
+ icon="πŸ”ˆ"
+else
+ icon="πŸ”‰"
+fi
+
+printf "%s%s%%\\n" "$icon" "$vol"
diff --git a/.local/bin/statusbar/weather b/.local/bin/statusbar/weather
new file mode 100755
index 0000000..e04bac0
--- /dev/null
+++ b/.local/bin/statusbar/weather
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# Displays todays precipication chance (β˜”) and daily low (πŸ₯Ά) and high (🌞).
+# Usually intended for the statusbar.
+
+# If we have internet, get a weather report from wttr.in and store it locally.
+# You could set up a shell alias to view the full file in a pager in the
+# terminal if desired. This function will only be run once a day when needed.
+weatherreport="${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport"
+getforecast() { curl -sf "wttr.in/$LOCATION" > "$weatherreport" || exit 1 ;}
+
+# Some very particular and terse stream manipulation. We get the maximum
+# precipication chance and the daily high and low from the downloaded file and
+# display them with coresponding emojis.
+showweather() { printf "%s" "$(sed '16q;d' "$weatherreport" |
+ grep -wo "[0-9]*%" | sort -rn | sed "s/^/β˜”/g;1q" | tr -d '\n')"
+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 "Β°"}' ;}
+
+case $BLOCK_BUTTON in
+ 1) setsid -f "$TERMINAL" -e less -Srf "$weatherreport" ;;
+ 2) getforecast && showweather ;;
+ 3) notify-send "🌈 Weather module" "\- Left click for full forecast.
+- Middle click to update forecast.
+β˜”: Chance of rain/snow
+πŸ₯Ά: Daily low
+🌞: Daily high" ;;
+ 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+# The test if our forcecast is updated to the day. If it isn't download a new
+# weather report from wttr.in with the above function.
+[ "$(stat -c %y "$weatherreport" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
+ getforecast
+
+showweather
diff --git a/.local/bin/texclear b/.local/bin/texclear
new file mode 100755
index 0000000..2061a2e
--- /dev/null
+++ b/.local/bin/texclear
@@ -0,0 +1,13 @@
+#!/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/unix b/.local/bin/unix
new file mode 100755
index 0000000..a9fb96e
--- /dev/null
+++ b/.local/bin/unix
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+#original artwork by http://www.sanderfocus.nl/#/portfolio/tech-heroes
+#converted to shell by #nixers @ irc.unix.chat
+
+cat << 'eof'
+ ,_ ,_==β–„β–‚
+ , β–‚β–ƒβ–„β–„β–…β–…β–…β–‚β–…ΒΎ. / /
+ β–„β–†<Β΄ "Β»β–“β–“β–“%\ / / / /
+ ,β–…7" Β΄>β–“β–“β–“% / / > / >/%
+ ▐ΒΆβ–“ ,Β»β–“β–“ΒΎΒ΄ /> %/%// / /
+ ▓▃▅▅▅▃,,▄▅▅▅Æ\// ///>// />/ /
+ V║«¼.;→ ║<«.,`=// />//%/% / /
+ //β• <Β΄ -Β²,)(β–“~"-╝/ΒΎ/ %/>/ />
+ / / / ▐% -./β–„β–ƒβ–„β–…▐, /7//;//% / /
+ / ////`β–Œ▐ %zWv xXβ–“β–‡β–Œ//&;% / /
+ / / / %//%/ΒΎΒ½Β΄β–Œβ–ƒβ–„β–„β–„β–„β–ƒβ–ƒ▐ΒΆ\/& /
+ </ /</%//`β–“!%β–“%β•£[38;5;255;β•£WY<Y)y&/`\
+ / / %/%//</%//\i7; β• N>)VY>7; \_ UNIX IS VERY SIMPLE IT JUST NEEDS A
+ / /</ //<///<_/%\β–“ V%W%Β£)XY _/%β€Ύ\_, GENIUS TO UNDERSTAND ITS SIMPLICITY
+ / / //%/_,=--^/%/%%\ΒΎ%ΒΆ%%} /%%%%%%;\,
+ %/< /_/ %%%%%;X%%\%%;, _/%%%;, \
+ / / %%%%%%;, \%%l%%;// _/%;, dmr
+ / %%%;, <;\-=-/ /
+ ;, l
+eof