summaryrefslogtreecommitdiff
path: root/.local/bin/dock
blob: ada7b64edecd5e38deb83e32468063ddb6a8362f (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
58
#!/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 "Dock or undock laptop"
    echo
    echo "options:"
    echo "  -h, --help            show this help message and exit"
    echo "  -d                    dock"
    echo "  -u                    undock"
}

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

    barpos -b
    xrandr --output HDMI-1 --mode 2560x1440 --rate 70 --primary
    xrandr --output eDP-1 --off 
    xwallpaper --center $XDG_CONFIG_HOME/wallpaper/bg 
    betterlockscreen -u $XDG_CONFIG_HOME/wallpaper/lock &>/dev/null &
}

undock () {
    barpos -t
    xrandr --output eDP-1 --mode 1920x1080 --primary
    xrandr --output HDMI-1 --off
    xwallpaper --center $XDG_CONFIG_HOME/wallpaper/bg 
    betterlockscreen -u $XDG_CONFIG_HOME/wallpaper/lock &>/dev/null &
}

main "$@"