aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorSylvain Herlédan <sylvain.herledan@hrafnagud.info>2017-06-03 12:52:03 +0200
committerSylvain Herlédan <sylvain.herledan@hrafnagud.info>2017-06-03 12:52:03 +0200
commite33ad4f128fb8fef2119cf2c71371eaf9c19bd29 (patch)
tree1fe625b20799889724aad507b8bac0a77258b9ca /bin
downloaddotfiles-e33ad4f128fb8fef2119cf2c71371eaf9c19bd29.tar.gz
dotfiles-e33ad4f128fb8fef2119cf2c71371eaf9c19bd29.tar.bz2
dotfiles-e33ad4f128fb8fef2119cf2c71371eaf9c19bd29.zip
Initial setup with basic tools: vim/dein, tmux, st, tup, X
Diffstat (limited to 'bin')
-rwxr-xr-xbin/log_notifications.sh5
-rwxr-xr-xbin/notify.sh23
-rwxr-xr-xbin/sshot.sh31
3 files changed, 59 insertions, 0 deletions
diff --git a/bin/log_notifications.sh b/bin/log_notifications.sh
new file mode 100755
index 0000000..2b187db
--- /dev/null
+++ b/bin/log_notifications.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+echo "${@}" \
+ | sed -r 's/IT Message from (\w+)\s*(.+) emblem-important CRITICAL/\1> \2/' \
+ >> "/tmp/notifications.log"
diff --git a/bin/notify.sh b/bin/notify.sh
new file mode 100755
index 0000000..9271b67
--- /dev/null
+++ b/bin/notify.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+set -o nounset
+set -o errexit
+set -o pipefail
+
+readonly PROGNAME="$(basename "${0}")";
+readonly PROGDIR="$(readlink -m "$(dirname "${0}")")";
+readonly ARGS="${@}";
+
+function main()
+{
+ local username="${1}"; shift;
+ local message="${@}";
+ local userid=$(id -u "${username}");
+ sudo -u ${username} \
+ DISPLAY=":0" \
+ DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${userid}/bus" \
+ notify-send -u critical -a IT "Message from tech" "${message}"
+}
+
+main ${ARGS}
+exit 0
diff --git a/bin/sshot.sh b/bin/sshot.sh
new file mode 100755
index 0000000..426d323
--- /dev/null
+++ b/bin/sshot.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+set -o nounset
+set -o errexit
+set -o pipefail
+
+readonly PRONAME="$(basename "${0}")";
+readonly PROGDIR="$(readlink -f "$(dirname "${0}")")";
+readonly ARGS="${@}";
+
+call_scrot()
+{
+ local dst_dir="${1}"; shift;
+ scrot '%Y-%m-%d-%T_$wx$h_scrot.png' -e 'mv $f '"${dst_dir}" ${@}
+ notify-send "Screenshot saved to ${dst_dir}/$(ls -rt1 "${dst_dir}" | tail -1)"
+}
+
+main()
+{
+ if [ ${#} -eq 0 ];
+ then
+ >&2 echo "You must at least provide the path of the directory where "
+ >&2 echo "screenshots will be saved"
+ exit 1
+ fi
+
+ call_scrot ${@};
+}
+
+main ${ARGS}
+exit 0