summaryrefslogtreecommitdiff
path: root/.local/bin/dock
blob: 6414c78b3f953f9d6debb9fe05d9d9facd6196cb (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash

main () {
    if [ ! -n "$1" ]; then
        help
    fi

    while [ -n "$1" ]; do # while loop starts
        case "$1" in
            -d) 
                dock; break ;;
            -u) 
                undock; break ;;
            -h|--help)
                help ;;
            *) 
                usage; echo "error: unrecognized arguments: $1" ; exit 1 ;;
        esac
        shift
    done
}

usage () {
    echo "usage: dock [options]"
}

help () {
    usage
    echo
    echo "Toggle laptop between regular and 'docked' modes"
    echo
    echo "options:"
    echo "  -h, --help            show this help message and exit"
    echo "  -d                    dock laptop"
    echo "  -u                    undock laptop"
}

dock () { 
    echo "docking..." 

    if ! xrandr | grep -q "HDMI-1 connected" ; then
        echo "error: HDMI not connected"; exit 1
    fi

    xrandr --output HDMI-1 --mode 2560x1440 --rate 70 --primary --output eDP-1 --off 
    nitrogen --save --set-centered Pictures/wallpapers/wave-center-docked.png
    betterlockscreen -u Pictures/wallpapers/wave-center-docked.png
}

undock () {
    echo "undocking..." 
    xrandr --output eDP-1 --mode 1920x1080 --primary --output HDMI-1 --off
    nitrogen --save --set-centered Pictures/wallpapers/wave-center.png
    betterlockscreen -u Pictures/wallpapers/wave-center.png
}

main "$@"