From 113f1951f99aebdf5099cb2956c67edb16630138 Mon Sep 17 00:00:00 2001 From: Hugo Thunnissen Date: Sun, 24 Jun 2018 19:34:07 +0200 Subject: [PATCH] Implement brightness function keys --- bin/brightness.bash | 59 +++ config/openbox/environment | 1 + config/openbox/rc.xml | 765 +++++++++++++++++++++++++++++++++++++ setup.bash | 31 +- 4 files changed, 855 insertions(+), 1 deletion(-) create mode 100755 bin/brightness.bash create mode 100755 config/openbox/environment create mode 100644 config/openbox/rc.xml diff --git a/bin/brightness.bash b/bin/brightness.bash new file mode 100755 index 0000000..a40881f --- /dev/null +++ b/bin/brightness.bash @@ -0,0 +1,59 @@ +#!/bin/bash +## +# Change brightness and show a notification + +multiply-by-10-and-strip-decimals() { + declare number="$1" + bc <<<"10 * $number" | sed 's/\..*$//g' +} + +current-brightness() { + xrandr --current --verbose | grep -Pom 1 '(?<=Brightness: ).*' +} + +bar() { + declare -i count="$1" + [[ $count -eq 0 ]] && return 0 + printf '─' + ((count--)) + bar "$count" +} + +prefix-with-zero-point() { + echo "0.$1" +} + +current-output() { + xrandr --query | grep -Po '^.*(?= connected)' +} + +set-brightness() { + declare output="$1" brightness="$2" + xrandr --output "$output" --brightness "$brightness" +} + +notify-brightness() { + notify-send.sh \ + --replace-file=$HOME/.cache/clopper-ob/brightness.id \ + " $(bar $((3 * $(multiply-by-10-and-strip-decimals $(current-brightness)))))" +} + +increase-brightness() { + if [[ $(multiply-by-10-and-strip-decimals $(current-brightness)) -ge 10 ]]; then + return 0 + fi + + set-brightness "$(current-output)" "$(bc <<<"$(current-brightness) + 0.1")" +} + +decrease-brightness() { + set-brightness "$(current-output)" "$(bc <<<"$(current-brightness) - 0.1")" +} + +if [[ $1 == '+' ]]; then + increase-brightness +elif [[ $1 == '-' ]]; then + decrease-brightness +fi + +notify-brightness diff --git a/config/openbox/environment b/config/openbox/environment new file mode 100755 index 0000000..2e9fb9f --- /dev/null +++ b/config/openbox/environment @@ -0,0 +1 @@ +export PATH="$HOME/.local/share/clopper-ob/bin:$HOME/.local/share/clopper-ob/notify-send.sh:$PATH" \ No newline at end of file diff --git a/config/openbox/rc.xml b/config/openbox/rc.xml new file mode 100644 index 0000000..ce2f323 --- /dev/null +++ b/config/openbox/rc.xml @@ -0,0 +1,765 @@ + + + + + + + + 10 + 20 + + + + yes + + no + + yes + + no + + 200 + + no + + + + + Smart + +
yes
+ + Primary + + 1 + +
+ + + Clearlooks + NLIMC + + yes + yes + + sans + 8 + + bold + + normal + + + + sans + 8 + + bold + + normal + + + + sans + 9 + + normal + + normal + + + + sans + 9 + + normal + + normal + + + + sans + 9 + + bold + + normal + + + + sans + 9 + + bold + + normal + + + + + + + 4 + 1 + + + + 875 + + + + + yes + Nonpixel + + Center + + + + + 10 + + 10 + + + + + + + 0 + 0 + 0 + 0 + + + + TopLeft + + 0 + 0 + no + Above + + Vertical + + no + 300 + + 300 + + Middle + + + + + C-g + + + + + brightness.bash + + + + + + brightness.bash - + + + + + + leftno + + + rightno + + + upno + + + downno + + + leftno + + + rightno + + + upno + + + downno + + + 1 + + + 2 + + + 3 + + + 4 + + + + + + + + + + + + + + + + client-menu + + + + scrot -s + + + + + + + + + + + + + + + + + + + + + + + + yesyes + + + + + + + + + + + + right + + + + + left + + + + + up + + + + + down + + + + + + + + true + Konqueror + + kfmclient openProfile filemanagement + + + + + scrot + + + + + 1 + + 500 + + 400 + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + previous + + + next + + + previous + + + next + + + previous + + + next + + + + + + + + + + + + + + no + + + + + + + + + + + yes + + + + + + + + + + + + + + + + + + + + + + + + + client-menu + + + + + + top + + + + + + left + + + + + + right + + + + + + bottom + + + + + + client-menu + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + client-menu + + + + + client-menu + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + vertical + + + horizontal + + + + + + + + + + + + + + + + + previous + + + next + + + + previous + + + next + + + previous + + + next + + + + + + + + + + + + + + + + client-list-combined-menu + + + root-menu + + + + + + previous + + + next + + + previous + + + next + + + + + + + + + + /var/lib/openbox/debian-menu.xml + menu.xml + 200 + + no + + 100 + + 400 + + yes + + yes + + + + + + + +
diff --git a/setup.bash b/setup.bash index 5d1a043..1ab4b2a 100755 --- a/setup.bash +++ b/setup.bash @@ -16,7 +16,6 @@ install-apt-dependencies() { sudo apt-get update && \ sudo apt-get install xcompmgr openbox albert plank dunst numix-icon-theme-circle set +x - } are-in-path() { @@ -31,6 +30,13 @@ install-dependencies() { if ! are-in-path xcompmgr openbox dunst || ! [[ -d /usr/share/icons/Numix-Circle ]]; then install-apt-dependencies fi + + declare notify_send_dir='' + notify_send_dir="$(local-dir)/applications/notify-send.sh" + if ! [[ -d "$notify_send_dir" ]]; then + mkdir -p "$notify_send_dir" + git clone git@github.com:vlevit/notify-send.sh.git "$notify_send_dir" + fi } here() { @@ -92,10 +98,33 @@ add-ppas() { add-ppa-if-not-added 'numix/ppa' } +cache-dir() { + echo "$HOME/.cache/clopper-ob" +} + +local-dir() { + echo "$HOME/.local/share/clopper-ob" +} + +create-cache-dir() { + mkdir -p "$(cache-dir)" +} + +create-local-dir() { + mkdir -p "$(local-dir)" +} + +copy-bins() { + cp -r "$(here)/bin" "$(local-dir)/" +} + setup-openbox-for-user() { add-ppas install-dependencies copy-config + create-cache-dir + create-local-dir + copy-bins add-custom-startup echo "=> Finished"