M install.sh => install.sh +3 -1
@@ 66,6 66,8 @@ curl -SsfLo ~/.zsh/completions/_docker-compose https://raw.githubusercontent.com
mkdir -p ~/.local/share/xfce4/terminal/colorschemes
curl -SsfLo ~/.local/share/xfce4/terminal/colorschemes/gruvbox-dark.theme 'https://raw.githubusercontent.com/morhetz/gruvbox-contrib/master/xfce4-terminal/gruvbox-dark.theme'
-./applymime.sh
+cd "$DOTFILES_DIR"
+sh ./install_dpmsconf.sh
+sh ./applymime.sh
exit 0
A install_dpmsconf.sh => install_dpmsconf.sh +10 -0
@@ 0,0 1,10 @@
+#!/bin/sh
+
+# install dpmsconf cronjob for the current user
+
+if [ $(crontab -l 2>/dev/null | wc -l) -eq 0 ] ; then
+ # user has no crontab
+ echo '*/5 * * * * apply-dpms' | crontab -
+else
+ (crontab -l | grep -v "apply-dpms" ; echo '*/5 * * * * apply-dpms') | crontab -
+fi
A overlay/bin/apply-dpms => overlay/bin/apply-dpms +56 -0
@@ 0,0 1,56 @@
+#!/bin/sh
+
+set -e
+set -u
+
+CFG_FILE="$HOME/.config/dpmsconf"
+DEFAULT=20
+
+# Configure DPMS settings to one of several profiles
+
+# if no profile specified, then read CFG_FILE, which should be TSV with
+# either AC or BAT as column 0, and a profile as column 1
+
+# A profile may be either the string 'never', which means to never sleep the
+# monitor, or a number of minutes before blanking
+
+# if "printcfg" is used as the profile, then CFG_FILE is printed to standard
+# out and the DPMS settings are unchanged
+
+if [ $# -eq 0 ] ; then
+ if [ -e "$CFG_FILE" ] ; then
+ if acpi -a | grep "on-line" > /dev/null 2>&1 ; then
+ # on AC
+ config="$(cat "$CFG_FILE" | grep AC | cut -f2)"
+ else
+ # on battery
+ config="$(cat "$CFG_FILE" | grep BAT | cut -f2)"
+ fi
+ else
+ echo "no profile specified, and no $CFG_FILE" 1>&2
+ exit 1
+ fi
+else
+ config="$1"
+fi
+
+# not sure this does much on modern systems, but in theory it turns of the
+# bell, whatever that is.
+xset b off
+
+case "$config" in
+ never)
+ xset dpms 0 0 0
+ ;;
+ [0-9]*)
+ timeout=$(expr $config '*' 60)
+ xset dpms $timeout $timeout $timeout
+ ;;
+ printcfg)
+ echo "$CFG_FILE"
+ ;;
+ *)
+ echo "Invalid DPMS configuration '$config'" 1>&2
+ exit 1
+ ;;
+esac
D overlay/bin/configure-dpms => overlay/bin/configure-dpms +0 -37
@@ 1,37 0,0 @@
-#!/bin/sh
-
-set -e
-set -u
-
-# Configure DPMS settings to one of several profiles
-
-CONFIGURATION="$1"
-
-echo "Setting DPMS configuration to $CONFIGURATION"
-
-# not sure this does much on modern systems, but in theory it turns of the
-# bell, whatever that is.
-xset b off
-
-case "$CONFIGURATION" in
- docked)
- # 15 * 60 = 900
- # 30 * 60 = 1800
- # 45 * 60 = 2700
- xset dpms 900 1800 2700
- ;;
- undocked)
- # 3 * 60 = 180
- # 6 * 60 = 360
- # 9 * 60 = 540
- xset dpms 180 360 540
- ;;
- nosleep)
- echo "monitor will never sleep, remember to re-enable sleep when you are done"
- xset dpms 0 0 0
- ;;
- *)
- echo "Invalid DPMS configuration '$CONFIGURATION'"
- exit 1
- ;;
-esac
A overlay/bin/dpmsconf => overlay/bin/dpmsconf +50 -0
@@ 0,0 1,50 @@
+#!/bin/sh
+
+set -e
+set -u
+
+config_file="$(apply-dpms printcfg)"
+
+ac_choices="5!10!15!30!60!never"
+bat_choices="$ac_choices"
+
+# set default to current values, if any
+if [ -e "$config_file" ] ; then
+ ac_current="$(cat "$config_file" | awk '$1 ~ /AC/ {print($2)}')"
+ bat_current="$(cat "$config_file" | awk '$1 ~ /BAT/ {print($2)}')"
+
+ if [ -z "$ac_current" ] ; then
+ echo "" # no current AC config
+ elif echo "$ac_choices" | grep "$ac_current" > /dev/null 2>&1 ; then
+ ac_choices="$(echo "$ac_choices" | sed 's/'"$ac_current"'/^'"$ac_current"'/g')"
+ else
+ ac_choices="$(echo "$ac_choices!^$ac_current")"
+ fi
+
+ if [ -z "$bat_current" ] ; then
+ echo "" # no current BAT config
+ elif echo "$bat_choices" | grep "$bat_current" > /dev/null 2>&1 ; then
+ bat_choices="$(echo "$bat_choices" | sed 's/'"$bat_current"'/^'"$bat_current"'/g')"
+ else
+ bat_choices="$(echo "$bat_choices!^$bat_current")"
+ fi
+else
+ ac_choices="$(echo "$ac_choices" | sed 's/60/^60/g')"
+ bat_choices="$(echo "$bat_choices" | sed 's/10/^10/g')"
+fi
+
+choice="$(yad --form --title "DPMS Profile" \
+ --text "Configure DPMS profile" \
+ --field="On AC":CB \
+ "$ac_choices" \
+ --field="On Battery":CB \
+ "$bat_choices")"
+
+ac_profile="$(echo "$choice" | awk -F '|' '{print $1}')"
+bat_profile="$(echo "$choice" | awk -F '|' '{print $2}')"
+
+
+printf "AC\t$ac_profile\n" > "$config_file"
+printf "BAT\t$bat_profile\n" >> "$config_file"
+
+apply-dpms