johannesjo / gnome-shell-extension-window-session-manager

An indicator that let's you save and restore your open apps and the window positions and arrangements over multiple real and virtual displays.
MIT License
91 stars 18 forks source link

Doesn't work if firefox has multiple windows #11

Closed ydixon closed 5 years ago

ydixon commented 6 years ago

It seems to create new windows instead of restoring them to the original position.

johannesjo commented 6 years ago

Hm I just checked and it seems to run fine for me.

Could you maybe run the tool from the command line (https://github.com/johannesjo/linux-window-session-manager) and post the output here?

ydixon commented 6 years ago

If I open firefox first, and then run lwsm restore.

[dickson@localhost ~]$ lwsm restore
Status: "gnome-terminal-server.Gnome-terminal" is running: true 5 0
Status: "gnome-terminal-server.Gnome-terminal" is running: true 5 0
Status: "gnome-terminal-server.Gnome-terminal" is running: true 5 0
Status: "sublime_text.Sublime_text" is running: true 2 0
Status: "sublime_text.Sublime_text" is running: true 2 0
Status: "gnome-terminal-server.Gnome-terminal" is running: true 5 0
Status: "nautilus.Nautilus" is running: true 1 0
Status: "gnome-terminal-server.Gnome-terminal" is running: true 5 0
Status: "Navigator.Firefox" is running: true 6 0
Status: "Navigator.Firefox" is running: true 6 0
Status: "Navigator.Firefox" is running: true 6 0
Status: "Navigator.Firefox" is running: true 6 0
Status: "Navigator.Firefox" is running: true 6 0
Status: "Navigator.Firefox" is running: true 6 0
Wait for all applications to start
All applications started
Restoring window position for "gnome-terminal-server.Gnome-terminal"
Restoring window position for "gnome-terminal-server.Gnome-terminal"
Restoring window position for "gnome-terminal-server.Gnome-terminal"
Restoring window position for "sublime_text.Sublime_text"
Restoring window position for "sublime_text.Sublime_text"
Restoring window position for "gnome-terminal-server.Gnome-terminal"
Restoring window position for "nautilus.Nautilus"
Restoring window position for "gnome-terminal-server.Gnome-terminal"
Restoring window position for "Navigator.Firefox"
Restoring window position for "Navigator.Firefox"
Restoring window position for "Navigator.Firefox"
Restoring window position for "Navigator.Firefox"
Restoring window position for "Navigator.Firefox"
Restoring window position for "Navigator.Firefox"
RESTORED SESSION: DEFAULT

I'm guessing the window-ids are changed everytime you launch firefox which cause the script unable to restore them?

If I run lwsm restore without opening firefox first, it will open a bunch of blank firefox windows.

[dickson@localhost ~]$ lwsm restore
Status: "Navigator.Firefox" is running: false 6 0
Starting: firefox.desktop
Status: "Navigator.Firefox" is running: false 6 0
Starting: firefox.desktop
Status: "Navigator.Firefox" is running: false 6 0
Starting: firefox.desktop
Status: "Navigator.Firefox" is running: false 6 0
Starting: firefox.desktop
Status: "Navigator.Firefox" is running: false 6 0
Starting: firefox.desktop
Status: "Navigator.Firefox" is running: false 6 0
Starting: firefox.desktop
Status: "gnome-terminal-server.Gnome-terminal" is running: true 5 0
Status: "gnome-terminal-server.Gnome-terminal" is running: true 5 0
Status: "gnome-terminal-server.Gnome-terminal" is running: true 5 0
Status: "sublime_text.Sublime_text" is running: true 2 0
Status: "sublime_text.Sublime_text" is running: true 2 0
Status: "gnome-terminal-server.Gnome-terminal" is running: true 5 0
Status: "nautilus.Nautilus" is running: true 1 0
Status: "gnome-terminal-server.Gnome-terminal" is running: true 5 0
Wait for all applications to start
All applications started
An error occurred TypeError: Cannot read property 'windowId' of undefined
    at savedWindowList.forEach (/usr/lib/node_modules/linux-window-session-manager/lib/index.js:439:55)
    at Array.forEach (<anonymous>)
    at updateWindowIds (/usr/lib/node_modules/linux-window-session-manager/lib/index.js:434:19)
    at closeAllWindowsIfSet.then.then.then.then.then.then (/usr/lib/node_modules/linux-window-session-manager/lib/index.js:196:11)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
Generic Error in Main Handler TypeError: Cannot read property 'windowId' of undefined
    at savedWindowList.forEach (/usr/lib/node_modules/linux-window-session-manager/lib/index.js:439:55)
    at Array.forEach (<anonymous>)
    at updateWindowIds (/usr/lib/node_modules/linux-window-session-manager/lib/index.js:434:19)
    at closeAllWindowsIfSet.then.then.then.then.then.then (/usr/lib/node_modules/linux-window-session-manager/lib/index.js:196:11)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7) TypeError: Cannot read property 'windowId' of undefined
    at savedWindowList.forEach (/usr/lib/node_modules/linux-window-session-manager/lib/index.js:439:55)
    at Array.forEach (<anonymous>)
    at updateWindowIds (/usr/lib/node_modules/linux-window-session-manager/lib/index.js:434:19)
    at closeAllWindowsIfSet.then.then.then.then.then.then (/usr/lib/node_modules/linux-window-session-manager/lib/index.js:196:11)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
(node:14927) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'windowId' of undefined
    at savedWindowList.forEach (/usr/lib/node_modules/linux-window-session-manager/lib/index.js:439:55)
    at Array.forEach (<anonymous>)
    at updateWindowIds (/usr/lib/node_modules/linux-window-session-manager/lib/index.js:434:19)
    at closeAllWindowsIfSet.then.then.then.then.then.then (/usr/lib/node_modules/linux-window-session-manager/lib/index.js:196:11)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
(node:14927) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14927) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
johannesjo commented 6 years ago

Tank you. Sorry for bothering you again, but I also would need the output of locate firefox.desktop, its contents and the contents of the file ~/.lwsm/sessionData/DEFAULT.json.

ydixon commented 6 years ago
[dickson@localhost tmp]$ locate firefox.desktop
/usr/share/applications/firefox.desktop
[dickson@localhost tmp]$ cat ~/.lwsm/sessionData/DEFAULT.json
{
  "name": "DEFAULT",
  "displaysCombinations": [
    {
      "id": "1920x1080;2560x1440",
      "windowList": [
        {
          "windowId": " 0x3000006",
          "windowIdDec": 50331654,
          "wmCurrentDesktopNr": 6,
          "states": [],
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 4780,
          "wmClassName": "gnome-terminal-server.Gnome-terminal",
          "x": 1928,
          "y": 220,
          "width": 734,
          "height": 434,
          "simpleName": "Gnome-terminal",
          "executableFile": "gnome-terminal"
        },
        {
          "windowId": "0x30009d4",
          "windowIdDec": 50334164,
          "wmCurrentDesktopNr": 7,
          "states": [],
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 4780,
          "wmClassName": "gnome-terminal-server.Gnome-terminal",
          "x": 1973,
          "y": 265,
          "width": 734,
          "height": 434,
          "simpleName": "Gnome-terminal",
          "executableFile": "gnome-terminal"
        },
        {
          "windowId": "0x3000a0e",
          "windowIdDec": 50334222,
          "wmCurrentDesktopNr": 7,
          "states": [],
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 4780,
          "wmClassName": "gnome-terminal-server.Gnome-terminal",
          "x": 1990,
          "y": 959,
          "width": 734,
          "height": 434,
          "simpleName": "Gnome-terminal",
          "executableFile": "gnome-terminal"
        },
        {
          "windowId": "0x2e00003",
          "windowIdDec": 48234499,
          "states": [],
          "wmCurrentDesktopNr": 4,
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 10620,
          "wmClassName": "sublime_text.Sublime_text",
          "x": 3456,
          "y": 67,
          "width": 1024,
          "height": 1373,
          "simpleName": "Sublime_text",
          "executableFile": "sublime_text.desktop",
          "desktopFilePath": "/usr/share/applications/sublime_text.desktop"
        },
        {
          "windowId": "0x2e0002b",
          "windowIdDec": 48234539,
          "states": [],
          "wmCurrentDesktopNr": 5,
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 10620,
          "wmClassName": "sublime_text.Sublime_text",
          "x": 1920,
          "y": 67,
          "width": 1536,
          "height": 1373,
          "simpleName": "Sublime_text",
          "executableFile": "sublime_text.desktop",
          "desktopFilePath": "/usr/share/applications/sublime_text.desktop"
        },
        {
          "windowId": "0x3004348",
          "windowIdDec": 50348872,
          "wmCurrentDesktopNr": 5,
          "states": [],
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 4780,
          "wmClassName": "gnome-terminal-server.Gnome-terminal",
          "x": 1965,
          "y": 223,
          "width": 734,
          "height": 434,
          "simpleName": "Gnome-terminal",
          "executableFile": "gnome-terminal"
        },
        {
          "windowId": "0x3200007",
          "windowIdDec": 52428807,
          "states": [],
          "wmCurrentDesktopNr": 5,
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 5120,
          "wmClassName": "nautilus.Nautilus",
          "x": 3430,
          "y": 674,
          "width": 1076,
          "height": 757,
          "simpleName": "Nautilus",
          "executableFile": "nautilus"
        },
        {
          "windowId": "0x3007507",
          "windowIdDec": 50361607,
          "wmCurrentDesktopNr": 4,
          "states": [
            "_NET_WM_STATE_FOCUSED"
          ],
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 4780,
          "wmClassName": "gnome-terminal-server.Gnome-terminal",
          "x": 2166,
          "y": 360,
          "width": 734,
          "height": 434,
          "simpleName": "Gnome-terminal",
          "executableFile": "gnome-terminal"
        },
        {
          "windowId": "0x2400010",
          "windowIdDec": 37748752,
          "wmCurrentDesktopNr": 4,
          "states": [],
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 15961,
          "wmClassName": "Navigator.Firefox",
          "x": 1920,
          "y": 27,
          "width": 1536,
          "height": 1410,
          "simpleName": "Firefox",
          "executableFile": "firefox.desktop",
          "desktopFilePath": "/usr/share/applications/firefox.desktop"
        },
        {
          "windowId": "0x2400030",
          "windowIdDec": 37748784,
          "states": [],
          "wmCurrentDesktopNr": 4,
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 15961,
          "wmClassName": "Navigator.Firefox",
          "x": 2688,
          "y": 27,
          "width": 1792,
          "height": 1410,
          "simpleName": "Firefox",
          "executableFile": "firefox.desktop",
          "desktopFilePath": "/usr/share/applications/firefox.desktop"
        },
        {
          "windowId": "0x2400051",
          "windowIdDec": 37748817,
          "states": [],
          "wmCurrentDesktopNr": 7,
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 15961,
          "wmClassName": "Navigator.Firefox",
          "x": 2688,
          "y": 27,
          "width": 1792,
          "height": 1410,
          "simpleName": "Firefox",
          "executableFile": "firefox.desktop",
          "desktopFilePath": "/usr/share/applications/firefox.desktop"
        },
        {
          "windowId": "0x240003b",
          "windowIdDec": 37748795,
          "states": [],
          "wmCurrentDesktopNr": 5,
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 15961,
          "wmClassName": "Navigator.Firefox",
          "x": 2688,
          "y": 27,
          "width": 1792,
          "height": 1410,
          "simpleName": "Firefox",
          "executableFile": "firefox.desktop",
          "desktopFilePath": "/usr/share/applications/firefox.desktop"
        },
        {
          "windowId": "0x2400046",
          "windowIdDec": 37748806,
          "states": [
            "_NET_WM_STATE_FULLSCREEN"
          ],
          "wmCurrentDesktopNr": 4,
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 15961,
          "wmClassName": "Navigator.Firefox",
          "x": 0,
          "y": 0,
          "width": 1920,
          "height": 1080,
          "simpleName": "Firefox",
          "executableFile": "firefox.desktop",
          "desktopFilePath": "/usr/share/applications/firefox.desktop"
        },
        {
          "windowId": "0x2400025\n",
          "windowIdDec": 37748773,
          "wmCurrentDesktopNr": 6,
          "states": [],
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 15961,
          "wmClassName": "Navigator.Firefox",
          "x": 2688,
          "y": 27,
          "width": 1792,
          "height": 1410,
          "simpleName": "Firefox",
          "executableFile": "firefox.desktop",
          "desktopFilePath": "/usr/share/applications/firefox.desktop"
        }
      ]
    }
  ]
johannesjo commented 6 years ago

Thank you very much! I think i found the issue. It was actually a problem with the algorithm checking for all windows being started, which didn't account for firefox case, where all windows share the same id for some reason.

https://github.com/johannesjo/linux-window-session-manager/commit/b1ac5db4d7cf1bfe6683a7ae1b5effc1c6b7515c