diff options
| author | Igor Soarez <igor@soarez.org> | 2026-09-17 19:45:23 +0100 |
|---|---|---|
| committer | Igor Soarez <igor@soarez.org> | 2026-09-17 19:45:23 +0100 |
| commit | 13cc065ec014b86369dfe4ad60d1a43fa06fd251 (patch) | |
| tree | 684690c61b7b59758c2aac132c65b81c86de0608 /link/kwin.sh | |
dotfiles
Shell, editor and terminal configuration, the tools that go with them, and
szecret, an age-based secret manager whose store lives elsewhere.
History restarts here. What came before was not written to be read by
anyone else, and carried machine names, addresses and an encrypted secret
store; it is kept privately instead. What is left is meant to be safe on
any machine, including one whose owner is not me: see CLAUDE.md for the
rule it is written to.
Diffstat (limited to 'link/kwin.sh')
| -rwxr-xr-x | link/kwin.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/link/kwin.sh b/link/kwin.sh new file mode 100755 index 0000000..409bd57 --- /dev/null +++ b/link/kwin.sh @@ -0,0 +1,30 @@ +#!/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 |
