diff options
Diffstat (limited to '.scripts')
| -rwxr-xr-x | .scripts/cron/newsup | 12 | ||||
| -rwxr-xr-x | .scripts/i3cmds/displayselect | 2 | ||||
| -rwxr-xr-x | .scripts/i3cmds/samedir | 30 | ||||
| -rwxr-xr-x | .scripts/i3cmds/showclip | 4 | ||||
| -rwxr-xr-x | .scripts/i3cmds/td-toggle | 2 | ||||
| -rwxr-xr-x | .scripts/i3cmds/tutorialvids | 18 | ||||
| -rwxr-xr-x | .scripts/statusbar/battery (renamed from .scripts/statusbar/i3battery) | 21 | ||||
| -rwxr-xr-x | .scripts/statusbar/clock (renamed from .scripts/statusbar/i3date) | 0 | ||||
| -rwxr-xr-x | .scripts/statusbar/cpu (renamed from .scripts/statusbar/i3cpu) | 2 | ||||
| -rwxr-xr-x | .scripts/statusbar/disk (renamed from .scripts/statusbar/i3disk) | 0 | ||||
| -rwxr-xr-x | .scripts/statusbar/help (renamed from .scripts/statusbar/i3help) | 0 | ||||
| -rwxr-xr-x | .scripts/statusbar/i3mpdupdate | 9 | ||||
| -rwxr-xr-x | .scripts/statusbar/i3torrent | 6 | ||||
| -rwxr-xr-x | .scripts/statusbar/internet (renamed from .scripts/statusbar/i3internet) | 0 | ||||
| -rwxr-xr-x | .scripts/statusbar/mailbox (renamed from .scripts/statusbar/i3mail) | 0 | ||||
| -rwxr-xr-x | .scripts/statusbar/memory (renamed from .scripts/statusbar/i3mem) | 0 | ||||
| -rwxr-xr-x | .scripts/statusbar/music (renamed from .scripts/statusbar/i3mpd) | 0 | ||||
| -rwxr-xr-x | .scripts/statusbar/news (renamed from .scripts/statusbar/i3news) | 4 | ||||
| -rwxr-xr-x | .scripts/statusbar/pacpackages (renamed from .scripts/statusbar/i3pacman) | 0 | ||||
| -rwxr-xr-x | .scripts/statusbar/torrent | 26 | ||||
| -rwxr-xr-x | .scripts/statusbar/volume (renamed from .scripts/statusbar/i3volume) | 0 | ||||
| -rwxr-xr-x | .scripts/statusbar/weather (renamed from .scripts/statusbar/i3weather) | 0 | ||||
| -rwxr-xr-x | .scripts/tools/dmenupass | 2 | ||||
| -rwxr-xr-x | .scripts/tools/lmc | 13 | ||||
| -rwxr-xr-x | .scripts/tools/podentr | 6 | ||||
| -rwxr-xr-x | .scripts/tools/queueandnotify | 18 |
26 files changed, 95 insertions, 80 deletions
diff --git a/.scripts/cron/newsup b/.scripts/cron/newsup index 81c9b01..598cced 100755 --- a/.scripts/cron/newsup +++ b/.scripts/cron/newsup @@ -1,18 +1,16 @@ #!/bin/sh - # Set as a cron job to check for new RSS entries for newsboat. -# Note that newsboat cannot be opened during the sync and this -# sync cannot run while another instance of newsboat is open. +# If newsboat is open, sends it an "R" key to refresh. ping -q -t 1 -c 1 `ip r | grep -m 1 default | cut -d ' ' -f 3` >/dev/null || exit -note "Updating RSS feeds..." "$PIX/rss.gif" +/usr/bin/notify-send -i "$PIX/rss.gif" "Updating RSS feeds..." + +pgrep -x newsboat >/dev/null && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --name newsboat)" R && exit echo 🔃 > ~/.config/newsboat/.update pkill -RTMIN+6 i3blocks - /usr/bin/newsboat -x reload rm -f ~/.config/newsboat/.update pkill -RTMIN+6 i3blocks - -note "RSS feed update complete." "$PIX/rss.gif" +/usr/bin/notify-send -i "$PIX/rss.gif" "RSS feed update complete." diff --git a/.scripts/i3cmds/displayselect b/.scripts/i3cmds/displayselect index a8cf2f5..c9a2bd9 100755 --- a/.scripts/i3cmds/displayselect +++ b/.scripts/i3cmds/displayselect @@ -45,3 +45,5 @@ esac feh --bg-scale "$HOME/.config/wall.png" # Re-remap keys if keyboard added (for laptop bases) remaps +# Restart dunst to ensure proper location on screen +pgrep -x dunst >/dev/null && killall dunst && setsid dunst & diff --git a/.scripts/i3cmds/samedir b/.scripts/i3cmds/samedir index 7d65838..88845fc 100755 --- a/.scripts/i3cmds/samedir +++ b/.scripts/i3cmds/samedir @@ -1,27 +1,5 @@ #!/bin/sh -# i3 thread: https://faq.i3wm.org/question/150/how-to-launch-a-terminal-from-here/?answer=152#post-id-152 - -CMD=$TERMINAL -CWD='' - -# Get window ID -ID=$(xdpyinfo | grep focus | cut -f4 -d " ") - -# Get PID of process whose window this is -PID=$(xprop -id "$ID" | grep -m 1 PID | cut -d " " -f 3) - -# Get last child process (shell, vim, etc) -if [ -n "$PID" ]; then - TREE=$(pstree -lpA "$PID" | tail -n 1) - PID=$(echo "$TREE" | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g') - - # If we find the working directory, run the command in that directory - if [ -e "/proc/$PID/cwd" ]; then - CWD=$(readlink /proc/"$PID"/cwd) - fi -fi -if [ -n "$CWD" ]; then - cd "$CWD" && "$CMD" -else - "$CMD" -fi +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/.scripts/i3cmds/showclip b/.scripts/i3cmds/showclip index 7b3aeee..5764487 100755 --- a/.scripts/i3cmds/showclip +++ b/.scripts/i3cmds/showclip @@ -10,6 +10,6 @@ clip=$(xclip -o -selection clipboard) prim=$(xclip -o -selection primary) [ "$prim" != "" ] && notify-send "<b>Clipboard:</b> -$prim" -[ "$clip" != "" ] && notify-send "<b>Primary:</b> $clip" +[ "$clip" != "" ] && notify-send "<b>Primary:</b> +$prim" diff --git a/.scripts/i3cmds/td-toggle b/.scripts/i3cmds/td-toggle index 4eb6652..6489626 100755 --- a/.scripts/i3cmds/td-toggle +++ b/.scripts/i3cmds/td-toggle @@ -2,7 +2,7 @@ # If transmission-daemon is running, will ask to kill, else will ask to start. -[ ! -f /usr/bin/transmission-daemon ] && echo "Transmission not installed." && exit +[ ! -f /usr/bin/transmission-daemon ] && notify-send "Transmission daemon not installed." && exit if pgrep -x transmission-da >/dev/null ; then diff --git a/.scripts/i3cmds/tutorialvids b/.scripts/i3cmds/tutorialvids index d5fee01..2743bfc 100755 --- a/.scripts/i3cmds/tutorialvids +++ b/.scripts/i3cmds/tutorialvids @@ -2,17 +2,17 @@ vidlist=" status bar https://www.youtube.com/watch?v=gKumet6b-WY feh -i3 -mutt https://www.youtube.com/watch?v=2U3vRbF7v5A -ncmpcpp https://www.youtube.com/watch?v=sZIEdI9TS2U -newsboat https://www.youtube.com/watch?v=dUFCRqs822w -ranger https://www.youtube.com/watch?v=L6Vu7WPkoJo -zathura https://www.youtube.com/watch?v=V_Iz4zdyRM4 +st (terminal) https://www.youtube.com/watch?v=9H75enWM22k +i3 (window manager) https://www.youtube.com/watch?v=GKviflL9XeI +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 https://www.youtube.com/watch?v=hvc-pHjbhdE +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 " - -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//')" +mpv "$(echo "$vidlist" | grep -P "^$(echo "$vidlist" | grep "https:" | sed 's/\t.*//g' | dmenu -i -p "Learn about what? (ESC to cancel)" -l 5 | awk '{print $1}')\s" | sed 's/.*\t//')" diff --git a/.scripts/statusbar/i3battery b/.scripts/statusbar/battery index b485d9a..b2634e6 100755 --- a/.scripts/statusbar/i3battery +++ b/.scripts/statusbar/battery @@ -1,6 +1,9 @@ #!/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 @@ -14,21 +17,19 @@ esac capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit status=$(cat /sys/class/power_supply/"$1"/status) -if [ "$capacity" -ge 80 ]; then - color="#b8bb26" -elif [ "$capacity" -ge 60 ]; then - color="#ebdbb2" -elif [ "$capacity" -ge 40 ]; then - color="#fabd2f" -elif [ "$capacity" -ge 20 ]; then - color="#fe8019" +if [ "$capacity" -ge 75 ]; then + color="$color10" +elif [ "$capacity" -ge 50 ]; then + color="$color15" +elif [ "$capacity" -ge 25 ]; then + color="$color11" else - color="#fb4934" + color="$color9" warn="❗" fi [ -z $warn ] && warn=" " -[ "$status" = "Charging" ] && color="#FFF" +[ "$status" = "Charging" ] && color="$color15" 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/$/%/')" diff --git a/.scripts/statusbar/i3date b/.scripts/statusbar/clock index caed51a..caed51a 100755 --- a/.scripts/statusbar/i3date +++ b/.scripts/statusbar/clock diff --git a/.scripts/statusbar/i3cpu b/.scripts/statusbar/cpu index 7dbdc1f..fc9d617 100755 --- a/.scripts/statusbar/i3cpu +++ b/.scripts/statusbar/cpu @@ -9,4 +9,4 @@ $(ps axch -o cmd:15,%cpu --sort=-%cpu | head)" ;; - % is of single core." ;; esac -sensors | awk '/^temp1/ {print $2}' +sensors | awk '/Core 0/ {print $3}' diff --git a/.scripts/statusbar/i3disk b/.scripts/statusbar/disk index 3a12394..3a12394 100755 --- a/.scripts/statusbar/i3disk +++ b/.scripts/statusbar/disk diff --git a/.scripts/statusbar/i3help b/.scripts/statusbar/help index eacb15b..eacb15b 100755 --- a/.scripts/statusbar/i3help +++ b/.scripts/statusbar/help diff --git a/.scripts/statusbar/i3mpdupdate b/.scripts/statusbar/i3mpdupdate deleted file mode 100755 index 646b49e..0000000 --- a/.scripts/statusbar/i3mpdupdate +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -[ "$(pgrep -x i3mpdupdate | wc -l)" -gt 2 ] && exit - -while : ; do - pgrep -x mpd || exit - mpc idle > /dev/null - pkill -RTMIN+11 i3blocks ; -done diff --git a/.scripts/statusbar/i3torrent b/.scripts/statusbar/i3torrent deleted file mode 100755 index 603ff01..0000000 --- a/.scripts/statusbar/i3torrent +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -case $BLOCK_BUTTON in - 1) $TERMINAL -e transmission-remote-cli -esac - -transmission-remote -l | grep % | sed -e "s/.*100%.*/Z/g;s/.*Idle.*/A/g;s/.*%.*/M/g" | sort -h | uniq -c | sed -e "s/Z/🌱/g;s/M/⬇️/g;s/A/⌛️/g" | awk '{print $2, $1}' | tr '\n' ' ' | sed -e "s/ $//g" diff --git a/.scripts/statusbar/i3internet b/.scripts/statusbar/internet index e26e633..e26e633 100755 --- a/.scripts/statusbar/i3internet +++ b/.scripts/statusbar/internet diff --git a/.scripts/statusbar/i3mail b/.scripts/statusbar/mailbox index bb72c5d..bb72c5d 100755 --- a/.scripts/statusbar/i3mail +++ b/.scripts/statusbar/mailbox diff --git a/.scripts/statusbar/i3mem b/.scripts/statusbar/memory index 40705c4..40705c4 100755 --- a/.scripts/statusbar/i3mem +++ b/.scripts/statusbar/memory diff --git a/.scripts/statusbar/i3mpd b/.scripts/statusbar/music index ef3a6c3..ef3a6c3 100755 --- a/.scripts/statusbar/i3mpd +++ b/.scripts/statusbar/music diff --git a/.scripts/statusbar/i3news b/.scripts/statusbar/news index 9a036f5..3c471a0 100755 --- a/.scripts/statusbar/i3news +++ b/.scripts/statusbar/news @@ -6,7 +6,7 @@ case $BLOCK_BUTTON in 1) setsid "$TERMINAL" -e newsboat ;; - 2) setsid newsup >/dev/null ;; + 2) setsid newsup >/dev/null & exit ;; 3) pgrep -x dunst >/dev/null && notify-send "<b>📰 News module:</b> - Shows unread news items - Shows 🔃 if updating with \`newsup\` @@ -15,4 +15,4 @@ case $BLOCK_BUTTON in <b>Note:</b> Only one instance of newsboat (including updates) may be running at a time." ;; esac -echo "$(newsboat -x print-unread | awk '{ print $1}' | sed s/^0$//g)$(cat ~/.config/newsboat/.update 2>/dev/null)" + cat ~/.config/newsboat/.update 2>/dev/null || echo "$(newsboat -x print-unread | awk '{ print $1}' | sed s/^0$//g)$(cat ~/.config/newsboat/.update 2>/dev/null)" diff --git a/.scripts/statusbar/i3pacman b/.scripts/statusbar/pacpackages index 1207e2c..1207e2c 100755 --- a/.scripts/statusbar/i3pacman +++ b/.scripts/statusbar/pacpackages diff --git a/.scripts/statusbar/torrent b/.scripts/statusbar/torrent new file mode 100755 index 0000000..06ddd3e --- /dev/null +++ b/.scripts/statusbar/torrent @@ -0,0 +1,26 @@ +#!/bin/sh + +transmission-remote -l | grep % | + sed " # This first sed command is to ensure a desirable order with sort + s/.*Stopped.*/A/g; + s/.*Seeding.*/Z/g; + s/.*100%.*/N/g; + s/.*Idle.*/B/g; + s/.*%.*/M/g" | + sort -h | uniq -c | sed " # Now we replace the standin letters with icons. + s/A/🛑/g; + s/B/⌛️/g; + s/M/🔽/g; + s/N/✅/g; + s/Z/🌱/g" | awk '{print $2, $1}' | tr '\n' ' ' | sed -e "s/ $//g" + +case $BLOCK_BUTTON in + 1) $TERMINAL -e transmission-remote-cli ;; + 3) pgrep -x dunst >/dev/null && notify-send "<b>Torrent module:</b> +🛑: paused +⏳: waiting +🔽: downloading +✅: done +🌱: done and seeding" ;; +esac + diff --git a/.scripts/statusbar/i3volume b/.scripts/statusbar/volume index 26e5a17..26e5a17 100755 --- a/.scripts/statusbar/i3volume +++ b/.scripts/statusbar/volume diff --git a/.scripts/statusbar/i3weather b/.scripts/statusbar/weather index a6c8d75..a6c8d75 100755 --- a/.scripts/statusbar/i3weather +++ b/.scripts/statusbar/weather diff --git a/.scripts/tools/dmenupass b/.scripts/tools/dmenupass new file mode 100755 index 0000000..4fc464f --- /dev/null +++ b/.scripts/tools/dmenupass @@ -0,0 +1,2 @@ +#!/bin/sh +dmenu -fn Monospace-18 -sb "#d79921" -sf "#1d2021" -nf "#000000" -nb "#000000" -p "$1" <&- && echo diff --git a/.scripts/tools/lmc b/.scripts/tools/lmc index 45cfcd9..18cf2c2 100755 --- a/.scripts/tools/lmc +++ b/.scripts/tools/lmc @@ -1,16 +1,13 @@ #!/bin/sh - # A general audio interface for LARBS. -newvol="pkill -RTMIN+10 i3blocks" - [ -z "$2" ] && num="2" || num="$2" case "$1" in - u*) pulsemixer --change-volume +"$num" ; $newvol ;; - d*) pulsemixer --change-volume -"$num" ; $newvol ;; - m*) pulsemixer --toggle-mute ; $newvol ;; - truemute) pulsemixer --mute ; $newvol ;; + 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 ;; @@ -41,3 +38,5 @@ All of these commands, except for \`truemute\`, \`prev\` and \`play\` can be tru i.e. \`lmc r\` for \`lmc restart\`. EOF esac + +pkill -RTMIN+10 i3blocks diff --git a/.scripts/tools/podentr b/.scripts/tools/podentr new file mode 100755 index 0000000..13ab4a8 --- /dev/null +++ b/.scripts/tools/podentr @@ -0,0 +1,6 @@ +#!/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/.scripts/tools/queueandnotify b/.scripts/tools/queueandnotify new file mode 100755 index 0000000..332668f --- /dev/null +++ b/.scripts/tools/queueandnotify @@ -0,0 +1,18 @@ +#!/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}')" + 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." +done < "$queuefile" + +echo > "$queuefile" |
