From aa6c19665c133d61b9f99fac74e63d84712aa928 Mon Sep 17 00:00:00 2001 From: David Runge Date: Sat, 25 Feb 2017 01:25:59 +0100 Subject: user/postpone-screensaver.service: Moving executable to /usr/bin. scripts/{postpone-screensaver,update-motd}: moving to bin subfolder for better distinction from scripts. --- bin/postpone-screensaver | 43 ++++++++++++++++++++++++++++++++++++++++ bin/update-motd | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100755 bin/postpone-screensaver create mode 100755 bin/update-motd (limited to 'bin') diff --git a/bin/postpone-screensaver b/bin/postpone-screensaver new file mode 100755 index 0000000..7ece93d --- /dev/null +++ b/bin/postpone-screensaver @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# Script to adjust dpms settings when running certain programs, +# that don't use fullscreen, but should not be "blanked" in between. + +export DISPLAY=:0.0 + +blankoff=0 +programs=( ${programs} ) +# loop all programs and check for running instances +for i in "${programs[@]}" +do + pid=$(pidof -x $i) + re='^[0-9]+$' + if [[ $pid =~ $re ]]; then + echo "$i running ($pid)" + blankoff=1 + fi +done + +# if valuable programs are running, don't use screen blanking +if [ $blankoff -gt 0 ]; then + echo "Some program requires screensaver to be off." + # print currently set values for screensaver timeout to tmp file + echo "s $(xset q|grep timeout|awk '{print $2}') $(xset q|grep timeout|awk '{print $4}')" > $adjust_dpms + echo "dpms $(xset q|grep Standby|awk '{print $2}') $(xset q|grep Standby|awk '{print $4}') $(xset q|grep Standby|awk '{print $6}')" >> $adjust_dpms + # disable screensaver and dpms + xset s off + xset -dpms +else + xsetq=$(xset q|grep timeout|awk '{print $2}') + # if the timeout is still 0, set it to its former value, or just switch on screensaver/dpms again + if [[ $xsetq -eq 0 ]];then + if [[ -f "$adjust_dpms" ]];then + xset $(head -n1 $adjust_dpms) + xset $(tail -n1 $adjust_dpms) + rm -rf $adjust_dpms + else + xset +dpms + xset s on + fi + fi +fi + diff --git a/bin/update-motd b/bin/update-motd new file mode 100755 index 0000000..8fe4c81 --- /dev/null +++ b/bin/update-motd @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# get the hostname +if [ -s /etc/motd.name ]; then + cat /etc/motd.name > /tmp/motd +elif [ -x /usr/bin/banner ]; then + cat /etc/hostname | banner -w 80 > /tmp/motd +else + cat /etc/hostname > /tmp/motd +fi +echo >> /tmp/motd + +# get additional info +if [ -s /etc/motd.info ]; then + cat /etc/motd.info >> /tmp/motd + echo >> /tmp/motd +fi + +# get currently running kernel version +uname -a >> /tmp/motd +echo >> /tmp/motd + +# update package cache +pacman -Sy 2>&1 > /dev/null +pacman -Qu > /tmp/updates +# show updatable packages +if [ -s /tmp/updates ]; then + echo "Package updates available:" >> /tmp/motd + cat /tmp/updates >> /tmp/motd + echo >> /tmp/motd +fi + +if [ -x /usr/bin/arch-audit ]; then + arch-audit -uf "%n|%c" >> /tmp/cves + if [ -s /tmp/cves ]; then + echo "Security updates needed:" >> /tmp/motd + cat /tmp/cves >> /tmp/motd + fi +else + echo "Install arch-audit for information on CVEs." >> /tmp/motd +fi + +# move all to /etc/motd +if [ -x /usr/bin/lolcat ]; then + lolcat /tmp/motd > /etc/motd +else + cat /tmp/motd > /etc/motd +fi + -- cgit v1.2.3-54-g00ecf