blob: 409bd57bebc4fa65ab38162032b5368f23a648d6 (
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
|
#!/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
|