2

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)
2

Use this simple shellscript before and after suspend:

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

getpos(){
    wmctrl -l -G > /dev/shm/winposs
}
setpos(){
    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
         getpos
    ;;
    set) echo setting window positions
         setpos
    ;;
    run) getpos
         shift
         ${@}
         setpos
    ;;
    *) echo "Usage: ${0##*/}"' [get|set|run <command>]'
    ;;
esac
  • 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.