update;repurpose displayctl
This commit is contained in:
@ -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
|
||||
|
||||
38
bin/st-power
38
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"
|
||||
|
||||
Reference in New Issue
Block a user