cem-utils

Random utilities
git clone git://git.ckyln.com/~cem/cem-utils.git
Log | Files | Refs | README

commit 21ed098100502d28c726473219c9d51d5afef411
parent eba83b3aeabd6d07710b9925ce517971f9ce93fb
Author: Cem Keylan <cem@ckyln.com>
Date:   Tue, 11 Feb 2020 12:58:03 +0300

add dwm-notify-send

Diffstat:
MREADME.md | 20++++++++++++++++++++
Adwm-notify-send/Makefile | 9+++++++++
Adwm-notify-send/kill-notification | 3+++
Adwm-notify-send/notify-send | 31+++++++++++++++++++++++++++++++
4 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -57,5 +57,25 @@ This will create /etc/zzz.d/resume/99-onresume and You can add user hooks to ~/.onsuspend and ~/.onresume to get them working. + +dwm-notify-send +--------------- + +A simple notify-send command to use dwm's bar for +displaying notification. It must work with every bar +that uses the WMNAME function, but I have only tested +it on dwm bar. + +The delimiter ('-' by default) can be edited from the +`NOTIFY_SEND_DELIMETER` environment variable. This way +you can also make use of the second bar, if it exists. + +**Dependencies** + +* A bar with WMNAME function. +* xsetroot +* timeout +* POSIX sh + [1]: http://git.vuxu.org/runit-void/tree/zzz [2]: https://github.com/bahamas10/zzz-user-hooks diff --git a/dwm-notify-send/Makefile b/dwm-notify-send/Makefile @@ -0,0 +1,9 @@ +PREFIX = /usr/local +BINDIR = ${PREFIX}/bin + +install: + install -Dm755 -t ${DESTDIR}${BINDIR} notify-send kill-notification + +uninstall: + rm -f ${DESTDIR}${BINDIR}/notify-send \ + ${DESTDIR}${BINDIR}/kill-notification diff --git a/dwm-notify-send/kill-notification b/dwm-notify-send/kill-notification @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +kill $(cat /tmp/notify-$(id -u)) diff --git a/dwm-notify-send/notify-send b/dwm-notify-send/notify-send @@ -0,0 +1,31 @@ +#!/bin/sh +[ "$1" ] || { +cat <<EOF +usage: ${0##*/} [-t seconds] [-u arg (ignored)] title description + +POSIX sh replacement for notify-send(1) on dwm(1) + +You can change the delimiter ('-' by default) from your environment +by adding a NOTIFY_SEND_DELIMITER variable. This way you can also +make use of the two bar patches on dwm. + +EOF +exit 1 +} +# O="$(getop -l app-name: +while getopts 't:u:' flag ; do + case "$flag" in + t) TIME=$OPTARG ; shift 2 ;; + u) _=$OPTARG ; shift 2 ;; + *) printf '%s is not supported\n' "$flag" ; exit 1 ;; + esac +done + +# +NOTIFY_SEND_DELIMITER="${NOTIFY_SEND_DELIMITER--}" +TIME=${TIME-3} + +# This is the way we display notifications. You may +# not like it, but this is what peak performance looks like + +timeout "$TIME" sh -c "printf \"\$\$\" > /tmp/notify-$(id -u) ; while :; do xsetroot -name ' $1 $NOTIFY_SEND_DELIMITER $2 ' ; done" &