Skip to content

Instantly share code, notes, and snippets.

@grauwoelfchen
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grauwoelfchen/3d64c13cf473667123d6 to your computer and use it in GitHub Desktop.
Save grauwoelfchen/3d64c13cf473667123d6 to your computer and use it in GitHub Desktop.
Stumpish notification via X-session for root for ${PACKAGE} and ${LOGFILE} for `emerge`
#!/bin/sh
if [ $# -lt 1 ]; then
echo "Usage: `basename $0` 'text' ['text']" >&2
exit 2
fi
STUMPISH=/usr/local/bin/stumpish
if [ ${#2} -lt 1 ]; then
LEN=${#1}
MES="
| $(printf "%-${LEN}s" $1) |
"
else
LOG="$(echo $2 | sed 's/.*:\(.*\.log\)$/\1/')"
LEN=$((${#1} > ${#LOG} ? ${#1} : ${#LOG}))
MES="
| $(printf "%-${LEN}s" $1) |
| $(printf "%-${LEN}s" $LOG) |
"
fi
SPACE=$(printf "%${LEN}s")
LINE="+-$(echo "${SPACE}" | sed 's/ /\-/g')-+"
su -c "exec env DISPLAY='$DISPLAY' XAUTHORITY='$XAUTHORITY' '$SHELL' -c \"$STUMPISH echo '^1*$LINE
| $SPACE |$MES| $SPACE |
$LINE
'\" >/dev/null 2>&1"
@grauwoelfchen
Copy link
Author

% xroot-stumpish 'package name' 'log file name'

+--------------------+
|  package name      |
|  log file name     |
+--------------------+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment