Pietrucci-Blacher / notion-snap-reborn

Remake of Notion-snap
61 stars 5 forks source link

Window size not saved after closing and opening #122

Open slavid opened 4 months ago

slavid commented 4 months ago

Hi, thanks for the work on this!

I am running Pop!_OS on Gnome 42 and every time I launch Notion it opens maximized and it I click on restore it restores to a tiny-sized window. I can resize it to a normal size, but every time I close the app, upon relaunching, the same thing will happen. I don't mind the app opening full size, as long as clicking restore brings it to my custom sized windows (just like with other Snap installed apps).

Is there any sort of config file I could edit to fix this?

slavid commented 1 month ago

A little bit of a workaround that I did this morning:

I've created a bash script at ~/.local/bin/ called launch-notion-windowed.sh with this content:

#/bin/bash

notion-snap-reborn %U &

while [ -z $(pgrep -f notion-snap-reborn | head -1) ]
do
    sleep 0.5
done

PID=$(pgrep -f notion-snap-reborn | head -1)

H_SIZE=0
V_SIZE=0
while [ $H_SIZE -ne 1920 ] || [ $V_SIZE -ne 1080 ]; do

    wmctrl -r $(wmctrl -p -l | grep $PID | awk '{print substr($0, index($0,$5))}') -b remove,maximized_vert,maximized_horz
    wmctrl -r $(wmctrl -p -l | grep $PID | awk '{print substr($0, index($0,$5))}') -e 0,320,150,1920,1080

    H_SIZE=$(wmctrl -pGl | grep $PID | awk '{print $6}')
    V_SIZE=$(wmctrl -pGl | grep $PID | awk '{print $7}')

    H_SIZE=${H_SIZE:-0}
    V_SIZE=${V_SIZE:-0}

    sleep 0.5
done

What this does is launching Notion, uses wmctrl (which has to be installed) find the Notion window by its PID and then remove the properties of being maximized both horizontally and vertically.

Then positions the window in 320px to the right and 150px down (from 0,0 upper corner left) with a size of 1920x1080 (I have a monitor with 2560x1440 resolution so it is right about the center of the screen).

And placed a Notion Windowed.desktop file at ~/.local/share/applications:

[Desktop Entry]
Name=Notion
Exec=~/.local/bin/launch-notion-windowed.sh &
Terminal=false
Type=Application
Icon=/snap/notion-snap-reborn/current/meta/gui/icon.png
StartupWMClass=Notion
Comment=A snap of Notion
Categories=Utility;

This way, although not perfect, I can launch Notion in windowed mode with the custom size that I want.