maximize_kde.sh 1.3 KB

1234567891011121314151617181920212223242526
  1. #!/bin/bash
  2. # maximize_kde.sh - a Konsole window maximized by a KWin script, for the pause-on-maximized check on Plasma (Konsole has
  3. # no maximize option, KWin 6 scripts have workspace.activeWindow.setMaximize). Runs until it is killed.
  4. konsole -e sleep 100000 &
  5. terminal=$!
  6. trap 'kill $terminal 2>/dev/null' EXIT
  7. sleep 4
  8. script=$(mktemp /tmp/lwe-maximize-XXXXXX.js)
  9. echo 'workspace.activeWindow.setMaximize(true, true);' > "$script"
  10. # KWin 6.4 hands a new script the id of a loaded one after any script was unloaded (it numbers by count), "run" then
  11. # starts that one again: load under more names until the id is a free one
  12. live=$(gdbus introspect --session --dest org.kde.KWin --object-path /Scripting | grep -o 'node Script[0-9]*' | tr -dc '0-9\n')
  13. names=()
  14. for attempt in 0 1 2 3; do
  15. name=lwe-maximize-test-$attempt
  16. id=$(gdbus call --session --dest org.kde.KWin --object-path /Scripting --method org.kde.kwin.Scripting.loadScript "$script" "$name" | tr -dc '0-9')
  17. names+=("$name")
  18. echo "$live" | grep -qx "$id" || break
  19. done
  20. gdbus call --session --dest org.kde.KWin --object-path "/Scripting/Script$id" --method org.kde.kwin.Script.run >/dev/null
  21. sleep 2
  22. for name in "${names[@]}"; do
  23. gdbus call --session --dest org.kde.KWin --object-path /Scripting --method org.kde.kwin.Scripting.unloadScript "$name" >/dev/null
  24. done
  25. rm -f "$script"
  26. wait $terminal