diff --git a/.bin/scr b/.bin/scr index 562ee9c..1b2ab34 100755 --- a/.bin/scr +++ b/.bin/scr @@ -1,3 +1,84 @@ #!/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 - 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 diff --git a/.bin/upload b/.bin/upload index 6c38df9..97d1d8a 100755 --- a/.bin/upload +++ b/.bin/upload @@ -57,7 +57,7 @@ done ### ### FUNCTIONS -### +### # fetches remote file list remote_list() { @@ -86,8 +86,8 @@ copy_and_print() { ### MAIN PROGRAM ### -# HANDLE CASE: "STDIN" -# do: upload with provided or generated filename +# HANDLE CASE: "standard input" +# upload with provided or generated filename if [[ ! -t 0 ]] then fname="$1"