From ee9abce060008087bfbc8353e3571af095fcf5e7 Mon Sep 17 00:00:00 2001 From: adam <56338480+adastx@users.noreply.github.com> Date: Thu, 6 Oct 2022 20:19:44 +0200 Subject: script: dock - for toggling laptop docked setup --- .local/bin/dock | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 .local/bin/dock 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 "$@" -- cgit v1.2.3-70-g09d2