diff --git a/bin/displayctl b/bin/displayctl index 73cafed..99de76f 100755 --- a/bin/displayctl +++ b/bin/displayctl @@ -1,8 +1,17 @@ #!/bin/sh -DISPLAY_STATUS=$(xrandr | grep DP-2) -if [ "$DISPLAY_STATUS" = *"1440x3440"* ]; then - xrandr --output DP-2 --off -else - init_displays -fi +# unused for now, repurposing for ddcutil control +#DISPLAY_STATUS=$(xrandr | grep DP-2) +# +#if [ "$DISPLAY_STATUS" = *"1440x3440"* ]; then +# xrandr --output DP-2 --off +#else +# init_displays +#fi + +case $1 in + "brightness") + ddcutil setvcp 10 $2;; + "contrast") + ddcutil setvcp 12 $2;; +esac diff --git a/bin/st-power b/bin/st-power index f1ad8df..81e0513 100755 --- a/bin/st-power +++ b/bin/st-power @@ -2,13 +2,24 @@ # for UPS monitoring with NUT # -#POWER="$(upsc titanium-power@localhost | grep ups.realpower: | awk '{print $2}')W" -#CHARGE="$(upsc titanium-power@localhost | grep battery.charge: | awk '{print $2}')%" -#if [ "$CHARGE" = "100%" ]; then -# echo $POWER -#else -# echo "$CHARGE $POWER" -#fi +DATA_CMD="upsc ups@localhost" + +# on debian and freebsd, ups.realpower is not available. +# calculate load in watts with load percent and max output instead. +MAX_OUTPUT=$($DATA_CMD | grep ups.realpower.nominal: | awk '{print $2}') +LOAD_VALUE=$($DATA_CMD | grep ups.load: | awk '{print $2}') +LOAD_PERCENT=$(echo "scale=2; $LOAD_VALUE/100" | bc) +POWER=$(echo "scale=0; $LOAD_PERCENT*$MAX_OUTPUT" | bc) + +# "round" to integer. just removes decimal and whatevers after. +POWER="${POWER%.*} W" +CHARGE="$($DATA_CMD | grep battery.charge: | awk '{print $2}')%" + +if [ "$CHARGE" = "100%" ]; then + echo $POWER +else + echo "$CHARGE $POWER" +fi # for battery monitoring everywhere else # @@ -17,14 +28,9 @@ #CURRENT=$(cat /sys/class/power_supply/BAT*/current_now) #POWER=$(echo "scale=2; $VOLTAGE*$CURRENT/1000000000000" | bc) -# freebsd -#CHARGE=$(acpiconf -i 0 | grep "Remaining capacity" | awk '{print $3}') -#POWER_RAW=$(acpiconf -i 0 | grep "Present rate:" | awk '{print $3}') -#POWER="$(echo "scale=1; $POWER_RAW/1000" | bc)W" - # if it is present, just divide it to watts (from micro watts on thinkpads, perhaps something else on other platforms) -POWER=$(cat /sys/class/power_supply/BAT*/power_now) -POWER="$(echo "scale=2; $POWER/1000000" | bc)W" -CHARGE="$(cat /sys/class/power_supply/BAT*/capacity)%" +#POWER=$(cat /sys/class/power_supply/BAT*/power_now) +#POWER="$(echo "scale=2; $POWER/1000000" | bc)W" +#CHARGE="$(cat /sys/class/power_supply/BAT*/capacity)%" -echo "$CHARGE $POWER" +#echo "$CHARGE $POWER"