scripts

Various scripts for UNIX-like systems
git clone https://git.tronto.net/scripts
Download | Log | Files | Refs | README

commit c5d101ab2c9db3b1a001cb56953cb90b24f8fdcf
parent 2c065927ff405b2d8b2eec6fc1fbee9c4f93e0a8
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Mon, 19 Jun 2023 10:09:47 +0200

Added notify

Diffstat:
MMakefile | 1+
Mbattery-checknow | 2+-
Mconfig-backup | 2+-
Mdmenu-unmount | 3++-
Anotify | 36++++++++++++++++++++++++++++++++++++
Mstatus | 10++++++----
Mxwallpaper-random-notify | 2+-
7 files changed, 48 insertions(+), 8 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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)