diff options
author | adam <56338480+adastx@users.noreply.github.com> | 2022-10-06 20:19:44 +0200 |
---|---|---|
committer | adam <56338480+adastx@users.noreply.github.com> | 2022-10-06 20:19:44 +0200 |
commit | ee9abce060008087bfbc8353e3571af095fcf5e7 (patch) | |
tree | c36e0be4e408ed0de859cc5afd9163b942f9d6ad /.local | |
parent | 5fa25fdac5c759789469afc7c52eb8ec41d79b5f (diff) |
script: dock - for toggling laptop docked setup
Diffstat (limited to '.local')
-rwxr-xr-x | .local/bin/dock | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/.local/bin/dock b/.local/bin/dock new file mode 100755 index 0000000..6414c78 --- /dev/null +++ b/.local/bin/dock @@ -0,0 +1,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 "$@" |