Update 2024-12-23 21:31 OpenBSD/amd64-t14

This commit is contained in:
c0dev0id 2024-12-23 21:31:59 +01:00
parent 31c62ae69a
commit b86b992a6a
2 changed files with 86 additions and 5 deletions

View File

@ -1,3 +1,84 @@
#!/bin/sh #!/bin/sh
[ -z $1 ] && doas wsconsctl -n display.brightness \
|| doas wsconsctl display.brightness=$1 # devices
_primary=$(xrandr | grep -v ^Screen | head -1 | cut -d" " -f1)
_max_res=$(xrandr | grep "^ " | head -1 | xargs | cut -d" " -f1)
_con_dev=$(xrandr | grep " connected" | grep -v "$_primary" | cut -d" " -f1 | xargs)
_dis_dev=$(xrandr | grep "disconnected" | cut -d" " -f1 | xargs)
if [ "$1" == "auto" ]
then
xrandr --output $_primary --auto
fi
if [ "$1" == "mirror" ]
then
for _dev in $_con_dev
do
xrandr --output $_dev --same-as $_primary
done
fi
_loop() {
set -x
for _dev in $1
do xrandr --output $_dev $2
done
}
[ "$1" == "left" ] \
&& _loop "$_con_dev" "--left-of $_primary"
[ "$1" == "right" ] \
&& _loop "$_con_dev" "--right-of $_primary"
[ "$1" == "above" ] \
&& _loop "$_con_dev" "--above $_primary"
[ "$1" == "auto" ] \
&& _loop "$_con_dev $_primary" "--auto"
[ "$1" == "off" ] \
&& _loop "$_con_dev" "--off"
[ "$1" == "fullhd" ] \
&& xrandr --output $_primary --mode "1920x1080"
[ "$1" == "hd" ] \
&& xrandr --output $_primary --mode "1280x720"
[ "$1" == "max" ] \
&& xrandr --output $_primary --mode "$_max_res"
if [ "$1" == "b" ]
then
[ -z "$2" ] \
&& doas wsconsctl -n display.brightness \
|| doas wsconsctl display.brightness=$2
fi
[ "$1" == "r" ] && [ -n "$2" ] \
&& xrandr --output $_primary --mode "$2"
if [ -z "$1" ]
then
echo "usage: res [mode]"
echo " auto - sets prefered mode for all connected displays"
echo " left - put screen left of primary screen"
echo " right - put screen right of primary screen"
echo " above - put screen above of primary screen"
echo " off - turn all connected screens off (except primary)"
echo " fullhd - set primary display resolution to FullHD (1920x1080)"
echo " hd - set primary display resolution to HD (1280x720)"
echo " max - set primary display to highest resolution ($_max_res)"
echo " r <res> - set primary display resolution"
echo " b <%> - display / set screen brightness"
echo
echo "Primary: $_primary"
echo "Connected: $_con_dev"
echo "Disconnected: $_dis_dev"
echo "Brightness: $(doas wsconsctl -n display.brightness)%"
echo
fi
exit 0

View File

@ -57,7 +57,7 @@ done
### ###
### FUNCTIONS ### FUNCTIONS
### ###
# fetches remote file list # fetches remote file list
remote_list() { remote_list() {
@ -86,8 +86,8 @@ copy_and_print() {
### MAIN PROGRAM ### MAIN PROGRAM
### ###
# HANDLE CASE: "STDIN" # HANDLE CASE: "standard input"
# do: upload with provided or generated filename # upload with provided or generated filename
if [[ ! -t 0 ]] if [[ ! -t 0 ]]
then then
fname="$1" fname="$1"