From 77c58e5f982729e4b6e58687016c05adb1400a54 Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Tue, 22 Mar 2022 12:28:39 +0100 Subject: [PATCH] Add backlight script --- .config/sxhkd/sxhkdrc | 4 +-- .config/vim/vimrc | 2 ++ .local/bin/backlight | 43 ++++++++++++++++++++++++++++ .local/bin/rankmirrors-personal-pref | 2 +- 4 files changed, 48 insertions(+), 3 deletions(-) create mode 100755 .local/bin/backlight diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index 5fd7415..fbce014 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -49,9 +49,9 @@ XF86AudioLowerVolume # mpc toggleoutput XF86MonBrightnessUp - xbacklight -inc 5 + backlight -inc 5 XF86MonBrightnessDown - [ $(xbacklight -get | cut -d'.' -f 1) -ge 10 ] && xbacklight -dec 5 + backlight -dec 5 super + v freetube "$(xclip -o -selection clipboard)" diff --git a/.config/vim/vimrc b/.config/vim/vimrc index ec06ee4..ce7181a 100644 --- a/.config/vim/vimrc +++ b/.config/vim/vimrc @@ -187,3 +187,5 @@ let g:move_key_modifier = 'C' let g:indentLine_char_list = ['|', '¦', '┆', '┊'] let g:vim_markdown_conceal = 0 + +let g:rustfmt_autosave = 1 diff --git a/.local/bin/backlight b/.local/bin/backlight new file mode 100755 index 0000000..953b52d --- /dev/null +++ b/.local/bin/backlight @@ -0,0 +1,43 @@ +#!/bin/bash +set -e + +path="/sys/class/backlight/intel_backlight" + +current_abs=$(cat "$path/actual_brightness") +max_abs=$(cat "$path/max_brightness") + +percent=$(( max_abs / 100 )) +current=$(( current_abs / percent )) +new="$current" + +change=$2 + +if [ "$1" = "-get" ] +then + echo "$current" + exit 0 +fi + +if [ "$1" = "-inc" ] +then + new=$(( current + change )) +fi +if [ "$1" = "-dec" ] +then + new=$(( current - change )) +fi +if [ "$1" = "-set" ] +then + new=$2 +fi + +if [ "$new" -lt 10 ] +then + new=10 +fi +if [ "$new" -gt 100 ] +then + new=100 +fi + +echo "$(( new * percent ))" | tee "$path/brightness" diff --git a/.local/bin/rankmirrors-personal-pref b/.local/bin/rankmirrors-personal-pref index 33cd785..cb93aea 100755 --- a/.local/bin/rankmirrors-personal-pref +++ b/.local/bin/rankmirrors-personal-pref @@ -2,4 +2,4 @@ echo "#Server = https://archive.archlinux.org/repos/$(date +"%Y/%m/%d")/\$repo/os/\$arch" -curl -Ls "https://archlinux.org/mirrorlist/?country=AT&country=BE&country=CZ&country=DK&country=FI&country=FR&country=DE&country=IT&country=LU&country=NL&country=PL&protocol=https&ip_version=4" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 25 - +curl -Ls "https://archlinux.org/mirrorlist/?country=AT&country=BE&country=CZ&country=DK&country=FI&country=FR&country=DE&country=IT&country=LU&country=NL&country=PL&protocol=https&ip_version=4" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors