#!/bin/bash # KWin window-layout script, on Plasma hosts only. Dry run by default; pass # `yes` to apply. set -euo pipefail # shellcheck source-path=SCRIPTDIR # shellcheck source=lib.sh source "$(dirname "$0")/lib.sh" "$@" # KWin counterpart of the hammerspoon window shortcuts, on Plasma hosts only. # Linking installs the script but KWin runs only those enabled in kwinrc; the # reconfigure makes a running session pick it up without a re-login, and is # allowed to fail when no KWin is running. --print-reply is what detects that: # without it dbus-send exits 0 as soon as the call is sent, even to a session # bus with no KWin on it. kwin_script="sz-window-layout" if command -v kwin_wayland >/dev/null && command -v kwriteconfig6 >/dev/null then link "$config_dir/kwin/$kwin_script" "$HOME/.local/share/kwin/scripts/$kwin_script" if [[ -n "${is_dry_run}" ]] then echo "Will set: kwinrc [Plugins] ${kwin_script}Enabled=true" else kwriteconfig6 --file kwinrc --group Plugins --key "${kwin_script}Enabled" true dbus-send --session --print-reply --dest=org.kde.KWin /KWin org.kde.KWin.reconfigure >/dev/null 2>&1 \ || yellow "KWin not reachable; $kwin_script loads at next login" fi fi