#!/bin/bash # A script to manage screen brightness on my machine # Depends on: bash, brightnessctl, libnotify # By David Penkowoj, 2024-09-16 memfile="/tmp/$(whoami)-brightness.memtxt" monitor_id="amdgpu_bl2" bctl() { brightnessctl --device="$monitor_id" "$@" } notify_brightness() { current="$(brightness get)" max="$(bctl m)" notify-send -u low -r "110" "Screen brightness: $(( current * 100 / max ))%" } case "$1" in "up") bctl set +5% notify_brightness ;; "down") bctl set 5-% notify_brightness ;; "get") printf "%s\n" "$(bctl | grep -Eo "[0-9]+" | head -n 2 | tail -n 1)" ;; *) printf "[ Error ] Usage: brightness [up|down|get]" exit 1 ;; esac