I have a laptop with multi-monitor setup, one is HDMI and the other is VGA. I have the energy saving setting set to dim screen after 5 min and switch screen off after 10 min, with suspends set to never. I lock my PC and after 10 had passed, when I re-login all open windows will moved to the laptop screen! I would like to keep all windows in place without having to reorder them each time. Is there a solution to this?

System Information:

  • List item

  • OS: Kubuntu 18.04 64-bit

  • KDE Plasma Version: 5.12.6
  • Graphics Card: Intel Corporation Skylake GT2 [HD Graphics 520] (rev 07)

Use this simple shellscript before and after suspend:

# Get the coordinates of the active window's
#    top-left corner, and the window's size.
# This can be saved & loaded

    wmctrl -l -G > /dev/shm/winposs
    while read -r id g x y w h host app;do
        IFS=" ," read ta tb a b c d <<<$(xprop -id "$id" _NET_FRAME_EXTENTS 2>/dev/null)
        [ -z $d ] && continue
        wmctrl -i -r $id -e "$g,$((x-$d)),$((y-$c)),$((w+$d+$b)),$((h+$c+$a))" 2>/dev/null
    done < /dev/shm/winposs

case $1 in
    get) echo getting window positions
    set) echo setting window positions
    run) getpos
    *) echo "Usage: ${0##*/}"' [get|set|run <command>]'
| improve this answer | |
  • i think this script has a syntax error on line 11, but i cant figure out how ti fix it! – Waqleh Sep 18 '18 at 8:22
  • 1
    Replace first sh to bash. – Ipor Sircer Sep 18 '18 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.