summaryrefslogtreecommitdiff
path: root/scripts/Scripts/screentool
blob: 9e41fd7b735541cf28e5a74d27b822ade833fb5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
DMENU="rofi -dmenu -i"
XRANDR="xrandr"

set -e

displays=$(xrandr | awk -F ' ' '/ connected/ {print $1}')

echo "Found displays ${displays}"

# Prompt for display
chosen=$(echo ${displays} | tr " " "\n" | $DMENU -p "output")

# get action
action=$(printf "auto\noff" | $DMENU -p "action")

if [ "$action" = "off" ]; then
    set -x
    $XRANDR --output $chosen --off
    exit 0
fi

# Get position
where=$(printf "left-of\nright-of\nbelow\nabove\nsame" | $DMENU -p "position")

if [ "$where" = "same" ]; then
    set -x
    $XRANDR --output $chosen --auto
    exit 0
fi

other=$(echo ${displays} | tr " " "\n" | $DMENU -p "other")

set -x
$XRANDR --output $chosen --auto --${where} $other