From fa92087bb7d9b05fee48f0af39db289d345bc173 Mon Sep 17 00:00:00 2001 From: Tovi Jaeschke-Rogers Date: Tue, 22 Oct 2024 11:53:42 +1030 Subject: [PATCH] feat: add brightness-up/down scripts --- .config/aliasrc | 4 ++-- .config/zsh/.zshrc | 6 +++++- .local/bin/brightness-down | 24 ++++++++++++++++++++++++ .local/bin/brightness-up | 24 ++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 3 deletions(-) create mode 100755 .local/bin/brightness-down create mode 100755 .local/bin/brightness-up diff --git a/.config/aliasrc b/.config/aliasrc index 20b0d4a..121a794 100644 --- a/.config/aliasrc +++ b/.config/aliasrc @@ -6,8 +6,8 @@ alias ls="ls --color=auto" alias ll="ls -G -alh" alias vim='nvim' alias grep='grep --color=auto' -alias vz='nvim ~/.zshrc && source ~/.zshrc' -alias va='nvim ~/.config/aliasrc && source ~/.zshrc' +alias vz="nvim ${ZDOTDIR}/.zshrc && source ${ZDOTDIR}/.zshrc" +alias va="nvim ~/.config/aliasrc && source ${ZDOTDIR}.zshrc" alias sz='source ~/.zshrc' alias c="xclip -selection clipboard" alias v="xclip -selection clipboard -o" diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 973209e..e8fd1e0 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -46,7 +46,11 @@ if [[ $(uname) == 'Darwin' ]]; then fi autoload -Uz compinit -compinit +if [[ -f "${ZDOTDIR}/.zcompdump" && "${ZDOTDIR}/.zcompdump" -nt "${ZDOTDIR}/.zshrc" ]]; then + compinit +else + compinit -C +fi # Auto complete case insensitive zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' diff --git a/.local/bin/brightness-down b/.local/bin/brightness-down new file mode 100755 index 0000000..1149655 --- /dev/null +++ b/.local/bin/brightness-down @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e + +# Define the backlight device +BACKLIGHT_DEVICE="/sys/class/backlight/intel_backlight" +DECREMENT=300 # Adjust this to the value you want to increase + +# Get the current and max brightness +current_brightness=$(cat "$BACKLIGHT_DEVICE/brightness") +max_brightness=$(cat "$BACKLIGHT_DEVICE/max_brightness") + +# Calculate new brightness value +new_brightness=$((current_brightness - DECREMENT)) + +# Ensure it doesn't exceed the maximum brightness +if [ "$new_brightness" -gt "$max_brightness" ]; then + new_brightness=$max_brightness +fi + +# Set the new brightness +echo "$new_brightness" > "$BACKLIGHT_DEVICE/brightness" + +notify-send "Brightness increased to $new_brightness" diff --git a/.local/bin/brightness-up b/.local/bin/brightness-up new file mode 100755 index 0000000..6d9920e --- /dev/null +++ b/.local/bin/brightness-up @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e + +# Define the backlight device +BACKLIGHT_DEVICE="/sys/class/backlight/intel_backlight" +INCREMENT=300 # Adjust this to the value you want to increase + +# Get the current and max brightness +current_brightness=$(cat "$BACKLIGHT_DEVICE/brightness") +max_brightness=$(cat "$BACKLIGHT_DEVICE/max_brightness") + +# Calculate new brightness value +new_brightness=$((current_brightness + INCREMENT)) + +# Ensure it doesn't exceed the maximum brightness +if [ "$new_brightness" -gt "$max_brightness" ]; then + new_brightness=$max_brightness +fi + +# Set the new brightness +echo "$new_brightness" > "$BACKLIGHT_DEVICE/brightness" + +notify-send "Brightness increased to $new_brightness"