https://bugs.kde.org/show_bug.cgi?id=436318

--- Comment #181 from Patrick O'Callaghan <pocallag...@gmail.com> ---
I currently have a set of apps in Autostart, but it's still annoying to have to
manually move windows onto the right desktops after logging in. As a partial
workaround, I wrote a couple of scripts using kdotool (see your local KDE
repo). They can occasionally give strange error messages, and don't do anything
for window positions within a desktop because that doesn't seem to be possible,
but I thought I'd post them here in case anyone finds them useful. Note that I
invoke them manually. There may be a way to automate this, but I haven't found
it. (Simple login/logout scripts are not the answer).:

Save:
--------
#!/bin/bash
# Save desktop state of selected windows
# pocallag...@gmail.com - 22/11/2024

# FIXME: assumes all the window names are distinct
# and restored on restarting

SAVE_FILE=$HOME/.save_desktops

true > "$SAVE_FILE"     # Zero the file

apps=(dolphin firefox evolution konsole)

for app in "${apps[@]}"
do
        for d in $(kdotool search "$app")
        do
#               cn=$(kdotool getwindowclassname $d)
#               [ "$cn" = plasmashell ] && continue     # Plasma has no desktop
                dt=$(kdotool get_desktop_for_window "$d")
                wn=$(kdotool getwindowname "$d")
                echo "$dt $wn" >> "$SAVE_FILE"
        done
done
---------
Restore:
---------
#!/bin/bash
# Restore the virtual desktops of saved windows
# pocallag...@gmail.com - 23/11/2024

SAVE_FILE=$HOME/.save_desktops

cat "$SAVE_FILE"|while read dt wn ; do
        window=$(kdotool search "$wn")
        [ "$window"x = x ] && continue
        kdotool set_desktop_for_window "$window" "$dt"
done
------

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to