From c5d101ab2c9db3b1a001cb56953cb90b24f8fdcf Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 19 Jun 2023 10:09:47 +0200 Subject: Added notify --- Makefile | 1 + battery-checknow | 2 +- config-backup | 2 +- dmenu-unmount | 3 ++- notify | 36 ++++++++++++++++++++++++++++++++++++ status | 10 ++++++---- xwallpaper-random-notify | 2 +- 7 files changed, 48 insertions(+), 8 deletions(-) create mode 100755 notify diff --git a/Makefile b/Makefile index 939db4a..daf7c2a 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,7 @@ SCRIPTS = addressgrep \ ffmpeg-facecam \ mail-compose \ mergepdf \ + notify \ open-file \ open-stdin \ open-url \ diff --git a/battery-checknow b/battery-checknow index eb6335e..bde1ae2 100755 --- a/battery-checknow +++ b/battery-checknow @@ -4,7 +4,7 @@ # Requires: battery-status, notify-battery file="${XDG_DATA_HOME:-$HOME/.local/share}/batterystatus" -notify=herbe +notify="notify push" low=20 crit=15 diff --git a/config-backup b/config-backup index ef25940..8d38791 100755 --- a/config-backup +++ b/config-backup @@ -6,7 +6,7 @@ folder=$HOME/box/configbackups dotfiles=".bash_profile .bashrc .profile .inputrc .mblaze .nexrc .tmux.conf .xinitrc" config="colors fontconfig git imv msmtp zathura" -src="dmenu dwm herbe st" +src="dmenu dwm st st-lightbg" share="gmni" mkdir -p $folder/config $folder/home $folder/share $folder/src diff --git a/dmenu-unmount b/dmenu-unmount index 57f0c41..2771ecc 100755 --- a/dmenu-unmount +++ b/dmenu-unmount @@ -6,7 +6,8 @@ # Requires: udevil, dmenu (or similar), notify-send or similar (optional) menu=dmenu -writeout=herbe +#writeout=notify-send +writeout="notify push" while getopts "m:w:" opt; do case "$opt" in diff --git a/notify b/notify new file mode 100755 index 0000000..f3d996e --- /dev/null +++ b/notify @@ -0,0 +1,36 @@ +#!/bin/sh + +# Simple notification manager. +# Notifications are sent to a log file together with a time stamp. +# Requires: xroot-update (optional) + +# Usage: notify [push MESSAGE | clean | edit | show] + +update=xroot-update +file="${XDG_DATA_HOME:-.local/share}/notify" +date=$(date +'%H:%M') + +usage() { + echo "Usage: notify [push MESSAGE | clean | edit | show]" +} + +touch "$file" +case "$1" in + push) + echo "(Notified $date) $2" >> "$file" + $update + ;; + clean) + printf "" > "$file" + $update + ;; + edit) + $EDITOR "$file" + ;; + show) + cat "$file" + ;; + *) + usage + ;; +esac diff --git a/status b/status index 10b43f9..abd9bad 100755 --- a/status +++ b/status @@ -26,14 +26,16 @@ else battery="No battery" fi -#network=$(nmcli device status | head -n 2 | tail -n 1 | awk '{print "Network: " $4}') # NetworkManager has a dreadful command line interface # It makes cry every time # pls help -network="Network: $(nmcli device status | head -n 2 | tail -n 1 | sed 's/ *$//' | sed 's/.* //')" +nwline="$(nmcli device status | head -n 2 | tail -n 1)" +nwclean="$(echo "$nwline" | sed 's/ *$//' | sed 's/.* //')" +network="Network: $nwclean" -events=$(sdep-list past | wc -l) +noticount=$(notify show | wc -l) printf "$network$sep$volume$sep$battery$sep$date$sep$time" -[ "$events" != "0" ] && printf "$sep$events TODO task(s)" +[ "$noticount" = "1" ] && printf "$sep$(notify show)" +[ "$noticount" -gt "1" ] && printf "${sep}Unread notifications: $noticount" printf "\n" diff --git a/xwallpaper-random-notify b/xwallpaper-random-notify index b59a59f..6ab3d56 100755 --- a/xwallpaper-random-notify +++ b/xwallpaper-random-notify @@ -4,7 +4,7 @@ # Requires: xwallpaper (or feh), notify-send or similar (optional) #notify=notify-send -notify=herbe +notify="notify push" folder=~/pictures/wallpapers pic=$(ls $folder | sort -R | head -1) -- cgit v1.3