#!/bin/sh # # SPDX-FileCopyrightText: 2023 Daniel Kalak # SPDX-License-Identifier: Apache-2.0 # # how to install: # rename this file to setroot # move it somewhere in your $PATH # change it to executable with chmod +x setroot # # dependencies: # amixer (install as alsa-utils) # brightnessctl # scrot # xdg-user-dir (install as xdg-user-dirs) # xsetroot (install as xorg-xsetroot) case "$1" in screenshot) pictures="$(xdg-user-dir PICTURES)" scrot "${pictures:?}/%Y-%m-%d.%H-%M-%S.png" msg='Screenshot taken!' ;; volup ) amixer sset Master 1%+ ;; voldown ) amixer sset Master 1%- ;; voltoggle) amixer sset Master toggle ;; micup ) amixer sset Capture 1%+ ;; micdown ) amixer sset Capture 1%- ;; mictoggle) amixer sset Capture toggle ;; lightup ) brightnessctl s +1% ;; lightdown) brightnessctl s 1%- ;; esac title="$(date -R | sed 's/:.. / /')" charge="$(cat /sys/class/power_supply/BAT0/capacity)" flow="$(cat /sys/class/power_supply/BAT0/status | cut -c1)" title="B $charge $flow | $title" amixer_filter='s/.*\[\([0-9]*\)%\].*\[\(on\|off\)\].*/\1 \2/p; T; q' vol="$(amixer sget Master | sed -n "$amixer_filter")" mic="$(amixer sget Capture | sed -n "$amixer_filter")" light="$((100 * $(brightnessctl g) / $(brightnessctl m)))" title="L $light | M $mic | V $vol | $title" if [ "$msg" ] then title="$msg | $title" { sleep 1; sh "$0"; } & fi xsetroot -name "$title"