From 2a2dc0a0217ba257502e1aae576aa56a4921239a Mon Sep 17 00:00:00 2001 From: M1dgard Date: Mon, 30 Apr 2018 17:19:00 +0200 Subject: [PATCH] Clean up and document --- README.md | 3 ++- i3/README.md | 15 +++++++++++++++ i3/backlight.sh | 21 +++++++++++++++++++-- i3/battery.sh | 3 +++ i3/config | 5 +++-- i3/{screens.sh => monitors.sh} | 0 i3/{screen_config => monitors_config} | 0 i3/terminal.sh | 7 ++++--- 8 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 i3/README.md rename i3/{screens.sh => monitors.sh} (100%) rename i3/{screen_config => monitors_config} (100%) diff --git a/README.md b/README.md index da9c56e..bbdb4c1 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,12 @@ The Arch Linux package to install is between parentheses. * i3-gaps ([community/i3-gaps](https://www.archlinux.org/packages/community/x86_64/i3-gaps/)) * Rofi ([community/rofi](https://www.archlinux.org/packages/community/x86_64/rofi/)) * Polybar ([aur/polybar](https://aur.archlinux.org/packages/polybar)) -* python-notify2 ([aur/python-notify2](https://aur.archlinux.org/packages/python-notify2/)) +* python-notify2 ([aur/python-notify2](https://aur.archlinux.org/packages/python-notify2/)) * Mozilla's Fira fonts ([community/otf-fira-mono](https://www.archlinux.org/packages/community/x86_64/otf-fira-mono/) and [community/otf-fira-sans](https://www.archlinux.org/packages/community/x86_64/otf-fira-sans/)). I might change this soon if I play with some patched Fira derivates * xfce4-terminal ([extra/xfce4-terminal](https://www.archlinux.org/packages/extra/x86_64/xfce4-terminal/), but you can choose your own terminal of course if you want) * NeoVim ([community/neovim](https://www.archlinux.org/packages/community/x86_64/neovim/)) * acpilight ([aur/acpilight](https://aur.archlinux.org/packages/acpilight/), an xbacklight replacement that directly uses the kernel's API, works without X) +* xrandr and arandr ([extra/xorg-xrandr](https://www.archlinux.org/packages/extra/x86_64/xorg-xrandr/) and [community/arandr](https://www.archlinux.org/packages/community/any/arandr/)) * unclutter ([community/unclutter](https://www.archlinux.org/packages/community/x86_64/unclutter/), hide the mouse when it hasn't moved for some time) * driver for your video card that supports GLX diff --git a/i3/README.md b/i3/README.md new file mode 100644 index 0000000..d8b0e06 --- /dev/null +++ b/i3/README.md @@ -0,0 +1,15 @@ +# i3 configuration and some general desirable Desktop Environment scripts + +## `backlight.sh` + +Control screen brightness in a logarithmic fashion. Linear backlight control just annoys me: I want fine-grained control over low brightnesses and quickly change the value at high brightnesses. + +It assumes the minimum brightness is 0 (light off) and the maximum brightness is 100. This is the behaviour of [acpilight](https://github.com/wavexx/acpilight/), a replacement for xorg-xbacklight (which doesn't work on my laptop for some reason). + +Use `backlight.sh up` or `backlight.sh down` to increase or decrease the backlight brightess. If you want to adjust the speed with which it changes, adjust `change_percent` in the script. + +## `screens.sh` + +Toggle between screen configurations. The script is pretty ad-hoc. It detects which configuration you're in and switches to the next desirable one. + +## `terminal.sh` diff --git a/i3/backlight.sh b/i3/backlight.sh index 9101bda..e1e2708 100755 --- a/i3/backlight.sh +++ b/i3/backlight.sh @@ -1,5 +1,22 @@ #!/bin/bash +# Control screen brightness in a logarithmic fashion. Linear backlight control +# just annoys me: I want fine-grained control over low brightnesses and quickly +# change the value at high brightnesses. +# +# We assume the minimum brightness is 0 (light off) and the maximum brightness +# is 100. This is the behaviour of +# [acpilight](https://github.com/wavexx/acpilight/), a replacement for +# xorg-xbacklight (which doesn't work on my laptop for some reason). +# +# Use `backlight.sh up` or `backlight.sh down` to increase or decrease the +# backlight brightess. If you want to adjust the speed with which it changes, +# adjust `change_percent` below. + + +# Multiply the current brightness by this percentage. This has to be an integer +change_percent=162 + # Don't start a new transition if the previous one isn't done yet pgrep -u $UID -x xbacklight >/dev/null && exit @@ -7,11 +24,11 @@ pgrep -u $UID -x xbacklight >/dev/null && exit current_brightness=$(xbacklight -get) case $1 in up) - target=$((current_brightness * 15 / 10)) + target=$((current_brightness * $change_percent / 100)) [ $target -ne $current_brightness ] || target=$((target + 1)) ;; down) - target=$((current_brightness * 10 / 15)) + target=$((current_brightness * 100 / $change_percent)) [ $target -ne $current_brightness ] || target=$((target - 1)) ;; esac diff --git a/i3/battery.sh b/i3/battery.sh index 8421e75..b6f38ad 100755 --- a/i3/battery.sh +++ b/i3/battery.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Legacy battery monitor. I'm writing a better one, I should publish it some +# time. + level_critical=5 level_low=10 level_low_max_backlight=8 diff --git a/i3/config b/i3/config index 57a3d99..c7b059b 100644 --- a/i3/config +++ b/i3/config @@ -82,9 +82,10 @@ bindsym Mod1+l exec --no-startup-id i3lock --image="$HOME/Pictures/background/Re # start a terminal bindsym $mod+Return exec $term bindsym $mod+KP_Enter exec $term -bindsym XF86Calculator exec "$termexec --zoom 3 -x bash -c 'exec-with-shortcut; zsh'" bindsym Ctrl+Mod4+t exec --no-startup-id "notify-send -a 'i3' -u normal 'You'\''re on i3, $usertitle.' 'Don'\''t try to Ctrl+Alt+T me. Use $mod+Enter like a real $usertype.'" bindsym Ctrl+Mod1+t exec --no-startup-id "notify-send -a 'i3' -u normal 'You'\''re on i3, $usertitle.' 'Don'\''t try to Ctrl+Alt+T me. Use $mod+Enter like a real $usertype.'" +# start a terminal and execute the command `exec-with-shortcut` from your PATH in it +bindsym XF86Calculator exec "$termexec --zoom 3 -x bash -c 'exec-with-shortcut; zsh'" # start web browser set $browser TZ=UTC firefox @@ -96,7 +97,7 @@ bindsym XF86MyComputer exec $filemanager # change display layout bindsym $mod+XF86Display exec arandr -bindsym XF86Display exec --no-startup-id $HOME/.config/i3/screens.sh +bindsym XF86Display exec --no-startup-id $HOME/.config/i3/monitors.sh ############################# diff --git a/i3/screens.sh b/i3/monitors.sh similarity index 100% rename from i3/screens.sh rename to i3/monitors.sh diff --git a/i3/screen_config b/i3/monitors_config similarity index 100% rename from i3/screen_config rename to i3/monitors_config diff --git a/i3/terminal.sh b/i3/terminal.sh index 4faa2a6..8a4b402 100755 --- a/i3/terminal.sh +++ b/i3/terminal.sh @@ -1,8 +1,9 @@ #!/bin/bash -# If a window with a path in its title is focused, open a terminal with that location as working directory. -# Like this, terminals are opened in the same directory as the currently focused one, if no command is running. -# This is very hackish, but it works. +# If a window with a path in its title is focused, open a terminal with that +# location as working directory. Like this, terminals are opened in the same +# directory as the currently focused one, if no command is running. This is +# very hackish, but it works. if [[ $(xtitle) =~ (^| )(~?)(/.*) ]]; then path="${BASH_REMATCH[3]}"