summaryrefslogtreecommitdiffstats
path: root/.local/bin
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2019-11-23 16:16:30 -0500
committerLuke Smith <luke@lukesmith.xyz>2019-11-23 16:16:30 -0500
commita5e66ac4f45322b3665c944ba34d83b7db43ebc5 (patch)
treebed315d0a7f2c180b3eb634ece3a6a2089cdeb6f /.local/bin
parent85d353d7963391cd66f23a3e99a66b8b58045e4c (diff)
downloadeibhear-a5e66ac4f45322b3665c944ba34d83b7db43ebc5.tar.gz
eibhear-a5e66ac4f45322b3665c944ba34d83b7db43ebc5.tar.zst
eibhear-a5e66ac4f45322b3665c944ba34d83b7db43ebc5.zip
merger of bin
Diffstat (limited to '.local/bin')
-rw-r--r--.local/bin/cron/IMPORTANT_NOTE.md11
-rwxr-xr-x.local/bin/cron/checkup18
-rwxr-xr-x.local/bin/cron/cronbat8
-rwxr-xr-x.local/bin/cron/crontog5
-rwxr-xr-x.local/bin/cron/newsup16
-rwxr-xr-x.local/bin/dwmbar96
-rwxr-xr-x.local/bin/i3cmds/ddspawn19
-rwxr-xr-x.local/bin/i3cmds/dropdowncalc2
-rwxr-xr-x.local/bin/i3cmds/hover14
-rwxr-xr-x.local/bin/i3cmds/i3resize27
-rwxr-xr-x.local/bin/i3cmds/tmuxdd4
-rwxr-xr-x.local/bin/tutorialvids1
12 files changed, 125 insertions, 96 deletions
diff --git a/.local/bin/cron/IMPORTANT_NOTE.md b/.local/bin/cron/IMPORTANT_NOTE.md
new file mode 100644
index 0000000..9eece42
--- /dev/null
+++ b/.local/bin/cron/IMPORTANT_NOTE.md
@@ -0,0 +1,11 @@
+# Important Note
+
+These cronjobs have components that require information about your current display to display notifications correctly.
+
+When you add them as cronjobs, I recommend you precede the command with commands as those below:
+
+```
+export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus; export DISPLAY=:0; . $HOME/.zprofile; then_command_goes_here
+```
+
+This ensures that notifications will display, xdotool commands will function and environmental varialbes will work as well.
diff --git a/.local/bin/cron/checkup b/.local/bin/cron/checkup
new file mode 100755
index 0000000..927b9d8
--- /dev/null
+++ b/.local/bin/cron/checkup
@@ -0,0 +1,18 @@
+#!/usr/bin/env sh
+# Syncs repositories and downloads updates, meant to be run as a cronjob.
+
+ping -q -c 1 1.1.1.1 > /dev/null || exit
+
+notify-send "📦 Repository Sync" "Checking for package updates..."
+
+sudo pacman -Syyuw --noconfirm || notify-send "Error downloading updates.
+
+Check your internet connection, if pacman is already running, or run update manually to see errors."
+pkill -RTMIN+8 i3blocks
+
+if pacman -Qu | grep -v "\[ignored\]"
+then
+ notify-send "🎁 Repository Sync" "Updates available. Click statusbar icon (📦) for update."
+else
+ notify-send "📦 Repository Sync" "Sync complete. No new packages for update."
+fi
diff --git a/.local/bin/cron/cronbat b/.local/bin/cron/cronbat
new file mode 100755
index 0000000..ee21a17
--- /dev/null
+++ b/.local/bin/cron/cronbat
@@ -0,0 +1,8 @@
+#!/usr/bin/env sh
+# Notify me with notify-send if my battery is below 25%.
+# You can set this to run via cron.
+
+[ "$(cat /sys/class/power_supply/BAT0/status)" = "Charging" ] && exit
+[ "$(cat /sys/class/power_supply/BAT0/capacity)" -lt 25 ] &&
+export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1001/bus &&
+notify-send -u critical "Battery critically low."
diff --git a/.local/bin/cron/crontog b/.local/bin/cron/crontog
new file mode 100755
index 0000000..237eb9c
--- /dev/null
+++ b/.local/bin/cron/crontog
@@ -0,0 +1,5 @@
+#!/usr/bin/env sh
+# Toggles all cronjobs off/on.
+# Stores disabled crontabs in ~/.consaved until restored.
+
+([ -f ~/.config/cronsaved ] && crontab - < ~/.config/cronsaved && rm ~/.config/cronsaved && notify-send "🕓 Cronjobs re-enabled.") || ( crontab -l > ~/.config/cronsaved && crontab -r && notify-send "🕓 Cronjobs saved and disabled.")
diff --git a/.local/bin/cron/newsup b/.local/bin/cron/newsup
new file mode 100755
index 0000000..6b6a348
--- /dev/null
+++ b/.local/bin/cron/newsup
@@ -0,0 +1,16 @@
+#!/usr/bin/env 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 1.1.1.1 > /dev/null || exit
+
+/usr/bin/notify-send "📰 Updating RSS feeds..."
+
+pgrep -x newsboat >/dev/null && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --name newsboat)" R && exit
+
+echo 🔃 > /tmp/newsupdate
+pkill -RTMIN+6 i3blocks
+/usr/bin/newsboat -x reload
+rm -f /tmp/newsupdate
+pkill -RTMIN+6 i3blocks
+/usr/bin/notify-send "📰 RSS feed update complete."
diff --git a/.local/bin/dwmbar b/.local/bin/dwmbar
deleted file mode 100755
index 72e2a46..0000000
--- a/.local/bin/dwmbar
+++ /dev/null
@@ -1,96 +0,0 @@
-#!/usr/bin/env sh
-
-# This script sets the statusbar with the xsetroot command at the end. Have it
-# started by ~/.xinitrc or ~/.xprofile.
-
-# Handle SIGTRAP signals sent by refbar to update the status bar immediately.
-trap 'update' 5
-
-# Set the deliminter character.
-delim="|"
-
-# testweather checks to see if the most recent forecast is up to date. If it
-# isn't, it downloads a new weather forecast, then signals to update the
-# statusbar. Gets weather report from wttr.in.
-testweather() { \
- [ "$(stat -c %y "$HOME/.local/share/weatherreport" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] &&
- ping -q -c 1 1.1.1.1 >/dev/null &&
- curl -s "wttr.in/$location" > "$HOME/.local/share/weatherreport" &&
- notify-send "🌞 Weather" "New weather forecast for today." &&
- refbar
- }
-
-# Here is the (big) function that outputs the appearance of the statusbar. It
-# can really be broken down into many submodules which I've commented and
-# explained.
-status() { \
-
- # Get current mpd track filename or artist - title if possible.
- mpc -f "[[%artist% - ]%title%]|[%file%]" 2>/dev/null | grep -v "volume:" | head -n 1 && echo "$delim"
-
- # If the weather report is current, show daily precipitation chance,
- # low and high. Don't even bother to understand this one unless you
- # have all day. Takes the weather report format from wttr.in and makes
- # it look like how I want it for the status bar.
- [ "$(stat -c %y "$HOME/.local/share/weatherreport" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] &&
- sed '16q;d' "$HOME/.local/share/weatherreport" | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/ /g" | tr -d '\n' &&
- sed '13q;d' "$HOME/.local/share/weatherreport" | grep -o "m\\(-\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ",$1 "°","",$2 "°"}' &&
- echo "$delim"
-
- # Get the volume of ALSA's master volume output. Show an icon if or
- # not muted.
- amixer get Master | grep -o "[0-9]*%\|\[on\]\|\[off\]" | sed "s/\[on\]//;s/\[off\]//"
-
- echo "$delim"
-
- # Wifi quality percentage and  icon if ethernet is connected.
- grep "^\s*w" /proc/net/wireless | awk '{ print "", int($3 * 100 / 70) "%" }'
- sed "s/down//;s/up//" /sys/class/net/e*/operstate
-
- # Show unread mail if mutt-wizard is installed.
- command -v mw >/dev/null 2>&1 &&
- echo "$delim" &&
- du -a ~/.local/share/mail/*/INBOX/new/* 2>/dev/null | wc -l | sed 's/^/:/'
- echo "$delim"
-
- # Will show all batteries with approximate icon for remaining power.
- for x in /sys/class/power_supply/BAT?/capacity;
- do
- case "$(cat $x)" in
- 100|9[0-9]) echo "" ;;
- 8[0-9]|7[0-9]) echo "" ;;
- 6[0-9]|5[0-9]) echo "" ;;
- 4[0-9]|3[0-9]) echo "" ;;
- *) echo "" ;;
- esac
- done && echo "$delim"
-
- # Date and time.
- date '+%Y %b %d (%a) %I:%M%p'
- }
-
-update() { \
- # So all that big status function was just a command that quicking gets
- # what we want to be the statusbar. This xsetroot command is what sets
- # it. Note that the tr command replaces newlines with spaces. This is
- # to prevent some weird issues that cause significant slowing of
- # everything in dwm. Note entirely sure of the cause, but again, the tr
- # command easily avoids it.
- xsetroot -name "$(status | tr '\n' ' ')" &
- wait
-
- # Check to see if new weather report is needed.
- testweather &
- wait
- }
-
-
-while :; do
- update
- # Sleep for a minute after changing the status bar before updating it
- # again. We run sleep in the background and use wait until it finishes,
- # because traps can interrupt wait immediately, but they can't do that
- # with sleep.
- sleep 1m &
- wait
-done
diff --git a/.local/bin/i3cmds/ddspawn b/.local/bin/i3cmds/ddspawn
new file mode 100755
index 0000000..1c4af36
--- /dev/null
+++ b/.local/bin/i3cmds/ddspawn
@@ -0,0 +1,19 @@
+#!/usr/bin/env 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/dropdowncalc b/.local/bin/i3cmds/dropdowncalc
new file mode 100755
index 0000000..132d8e1
--- /dev/null
+++ b/.local/bin/i3cmds/dropdowncalc
@@ -0,0 +1,2 @@
+#!/usr/bin/env sh
+ifinstalled bc && echo "Welcome to the Calculator." && bc -lq
diff --git a/.local/bin/i3cmds/hover b/.local/bin/i3cmds/hover
new file mode 100755
index 0000000..d02bbbc
--- /dev/null
+++ b/.local/bin/i3cmds/hover
@@ -0,0 +1,14 @@
+#!/usr/bin/env 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/i3resize b/.local/bin/i3cmds/i3resize
new file mode 100755
index 0000000..f89bdb5
--- /dev/null
+++ b/.local/bin/i3cmds/i3resize
@@ -0,0 +1,27 @@
+#!/usr/bin/env sh
+# This script was made by `goferito` on Github.
+# Some cleanup by Luke.
+
+[ -z "$1" ] && echo "No direction provided" && exit 1
+distanceStr="2 px or 2 ppt"
+
+moveChoice() {
+ i3-msg resize "$1" "$2" "$distanceStr" | grep '"success":true' || \
+ i3-msg resize "$3" "$4" "$distanceStr"
+}
+
+case $1 in
+ up)
+ moveChoice grow up shrink down
+ ;;
+ down)
+ moveChoice shrink up grow down
+ ;;
+ left)
+ moveChoice shrink right grow left
+ ;;
+ right)
+ moveChoice grow right shrink left
+ ;;
+esac
+
diff --git a/.local/bin/i3cmds/tmuxdd b/.local/bin/i3cmds/tmuxdd
new file mode 100755
index 0000000..c8eccbb
--- /dev/null
+++ b/.local/bin/i3cmds/tmuxdd
@@ -0,0 +1,4 @@
+#!/usr/bin/env 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/.local/bin/tutorialvids b/.local/bin/tutorialvids
index f96e77c..41d3c75 100755
--- a/.local/bin/tutorialvids
+++ b/.local/bin/tutorialvids
@@ -8,6 +8,7 @@ pacman (installing/managing programs) https://www.youtube.com/watch?v=-dEuXTMzRK
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
+ranger (file manager) https://www.youtube.com/watch?v=L6Vu7WPkoJo
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