From 964b463e67fce19ecac9da278233ea4645f95fdd Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Sat, 27 Aug 2022 14:08:12 -0400 Subject: Add blocks for dwm --- .local/bin/dwmbar/dwmb-cider | 20 ++++++++++++++++++++ .local/bin/dwmbar/dwmb-mail | 4 ++-- .local/bin/dwmbar/dwmb-rss | 35 +++++++++++++++++++++++++++++++++++ .local/bin/dwmbar/dwmb-todoist | 22 ++++++++++++++++++++++ .local/bin/dwmbar/dwmb-torrents | 18 ++++++++++++++++++ .local/bin/dwmbar/dwmb-volume | 22 ++++++++++++++++++++++ .local/bin/dwmbar/dwmb-vpn | 14 +++++++------- .sfeed/sfeedrc | 1 + 8 files changed, 127 insertions(+), 9 deletions(-) create mode 100755 .local/bin/dwmbar/dwmb-cider create mode 100755 .local/bin/dwmbar/dwmb-rss create mode 100755 .local/bin/dwmbar/dwmb-todoist create mode 100755 .local/bin/dwmbar/dwmb-torrents create mode 100755 .local/bin/dwmbar/dwmb-volume create mode 120000 .sfeed/sfeedrc diff --git a/.local/bin/dwmbar/dwmb-cider b/.local/bin/dwmbar/dwmb-cider new file mode 100755 index 0000000..ab9845e --- /dev/null +++ b/.local/bin/dwmbar/dwmb-cider @@ -0,0 +1,20 @@ +#!/bin/sh + +icon=" " + +# # Will minimize the block if nothing is in that file +# expand=$(test -s $HOME/.cache/dwmb-cider-min && echo true || echo false) + + + +case "$(playerctl status)" in + Paused) echo "$icon" ;; + Playing) echo "$icon $(cat ~/.config/Cider/Plugins/gh_525515699/dist/title.txt )" ;; + *) echo "" ;; +esac + +case $BUTTON in + 1) killall sfeed_curses || st -t rss -e sfeed_curses $HOME/.sfeed/feeds/* ;; + 3) playerctl play-pause;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac diff --git a/.local/bin/dwmbar/dwmb-mail b/.local/bin/dwmbar/dwmb-mail index 9c7e4fa..d495f6b 100755 --- a/.local/bin/dwmbar/dwmb-mail +++ b/.local/bin/dwmbar/dwmb-mail @@ -15,6 +15,6 @@ esac unread="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/*/*/new/* -type f | wc -l 2>/dev/null)" -pidof mbsync >/dev/null 2>&1 && icon=" " +pidof mbsync >/dev/null 2>&1 && icon="  " -[ "$unread" = "0" ] && [ "$icon" = "" ] || echo "  $unread $icon" +[ "$unread" = "0" ] && [ "$icon" = "" ] || echo "  $unread$icon" diff --git a/.local/bin/dwmbar/dwmb-rss b/.local/bin/dwmbar/dwmb-rss new file mode 100755 index 0000000..07b993f --- /dev/null +++ b/.local/bin/dwmbar/dwmb-rss @@ -0,0 +1,35 @@ +#!/bin/sh +cd "$HOME/.sfeed" || exit 1 + +LC_ALL=C awk -F '\t' ' +# URL file: amount of fields is 1. +NF == 1 { + u[$1] = 1; # lookup table of URLs + next; +} +# feed file: check by URL or id. +{ + total++; + if (u[$3] || u[$6]) + read++ +} +END { + feedcount=(total - read - 1) + if (feedcount == 0) + print "" + else + print "  " (feedcount) + # print "Unread: " (total - read) + # print "Read: " read + # print "Total: " total +} +' urls feeds/* + +case $BUTTON in + 1) killall sfeed_curses || st -t rss -e sfeed_curses $HOME/.sfeed/feeds/* ;; + 3) notify-send -a " News" "Updating..." && \ + sfeed_update && notify-send -a " News" "Done!" \ + || notify-send -a " News" "Something happened..." + sleep 0.2 && kill -37 $(pidof dwmblocks) ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac diff --git a/.local/bin/dwmbar/dwmb-todoist b/.local/bin/dwmbar/dwmb-todoist new file mode 100755 index 0000000..69a59a0 --- /dev/null +++ b/.local/bin/dwmbar/dwmb-todoist @@ -0,0 +1,22 @@ +#!/bin/sh + +touch ~/.cache/todoist + +ping -c1 1.1.1.1 >/dev/null 2>&1 && curl -X GET \ + https://api.todoist.com/rest/v1/tasks \ + -H "Authorization: Bearer $(pass Todoist/API)" |\ + jq ".[]|select(.completed == false)|select(.project_id == 2250555849)" |\ + grep '"id"' | wc -l > ~/.cache/todoist + +num=$(cat ~/.cache/todoist) + +printf "  $num " + +case $BUTTON in + 1) dropdowntoggle todoist nvim +"Todoist" && \ + kill -39 $(pidof dwmblocks) ;; + 2) notify-send -a " Todoist" "- Left click to open Todoist.Nvim + - Right click to open todoist in your web browser" ;; + 3) setsid $BROWSER "https://todoist.com/app/today" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac diff --git a/.local/bin/dwmbar/dwmb-torrents b/.local/bin/dwmbar/dwmb-torrents new file mode 100755 index 0000000..11c0792 --- /dev/null +++ b/.local/bin/dwmbar/dwmb-torrents @@ -0,0 +1,18 @@ +#!/bin/sh + +status="$(btcli list -aif "%t\n" )" + +starting="$( echo "$status" | grep -c "+" - )" +stopping="$( echo "$status" | grep -c "-" - )" +innactive="$(echo "$status" | grep -c "I" - )" +seeding="$( echo "$status" | grep -c "S" - )" +leeching="$( echo "$status" | grep -c "L" - )" + +# [ "$starting" == "0" ] || echo "Starting: $starting" +# [ "$stopping" == "0" ] || echo "Stopping: $stopping" +[ "$innactive" == "0" ] || echo "Innactive: $innactive" +[ "$seeding" == "0" ] || seed=" $seeding" +[ "$leeching" == "0" ] || down=" $leeching" + +echo "$down $seed" + diff --git a/.local/bin/dwmbar/dwmb-volume b/.local/bin/dwmbar/dwmb-volume new file mode 100755 index 0000000..422c6e6 --- /dev/null +++ b/.local/bin/dwmbar/dwmb-volume @@ -0,0 +1,22 @@ +#!/bin/sh + +# Low volume threshold (for the icon to change) +low="50" + +# High volume icon +icon=" " + +# Get the percentage +vol="$(amixer sget Master | tail -n 1 | sed "s/.*\[\([0-9]*\)%\]/\1/")" + +# Change to low volume icon if below threshold +[[ "$vol" -lt "$low" ]] && \ +icon=" " + +# Change to muted icon if necessary +echo $vol | grep off &>/dev/null && icon=" " + +echo " $icon$(echo $vol | sed "s/\s\[.*//")%" + +#    + diff --git a/.local/bin/dwmbar/dwmb-vpn b/.local/bin/dwmbar/dwmb-vpn index eb5e925..d134a37 100755 --- a/.local/bin/dwmbar/dwmb-vpn +++ b/.local/bin/dwmbar/dwmb-vpn @@ -4,13 +4,13 @@ vpnstatus="$(piactl get connectionstate)" case "$vpnstatus" in - Disconnected) icon=" " ;; - Connecting) icon="  " ;; - Connected) icon=" " ;; - Interrupted) icon="  " ;; - Reconnecting) icon="  " ;; - DisconnectingToReconnect) icon="  ";; - Disconnecting) icon="  " ;; + Disconnected) icon="" ;; + Connecting) icon=" " ;; + Connected) icon="" ;; + Interrupted) icon=" " ;; + Reconnecting) icon=" " ;; + DisconnectingToReconnect) icon=" ";; + Disconnecting) icon=" " ;; esac # case "$vpnstatus" in diff --git a/.sfeed/sfeedrc b/.sfeed/sfeedrc new file mode 120000 index 0000000..b07c0d3 --- /dev/null +++ b/.sfeed/sfeedrc @@ -0,0 +1 @@ +/home/master/Dropbox/sync/sfeedrc \ No newline at end of file -- cgit v1.2.3