linux-window-session-manager icon indicating copy to clipboard operation
linux-window-session-manager copied to clipboard

Cannot save session

Open curiousercreative opened this issue 3 years ago • 10 comments

:ghost: Brief Description

Saving session with som applications fails

:pancakes: Action version

lwsm save SESSION_NAME

Steps To Reproduce

Steps to reproduce the behavior:

  1. Open lots of apps (Tilix, Nautilus, Gedit perhaps the culprits)
  2. lwsm save SESSION_NAME

:police_car: Expected behavior

Session should be saved and later restored by lwsm restore SESSON_NAME

:heavy_plus_sign: Additional context

Pop!_OS 20.04, 20.10 Kernel 5.8, 5.11

Here's the stdout from a save after I removed the re-throw of the exception (so that it would proceed with save and throw all exceptions):

lwsm save common-energy
lwsm 4.0.5 --> save Tue Jul 06 2021 10:18:06 GMT-0400 (Eastern Daylight Time)

 Trying alternative guessing approach for "gnome".....
ERR: findDesktopFile() cant find file "gnome-calendar.desktop"! Searched desktopFileLocations: [
  '{home}/.local/share/applications',
  '{home}/.gnome/apps',
  '/usr/share/applications',
  '/usr/local/share/applications',
  '/usr/share/app-install',
  '{home}/.config/autostart',
  '/var/lib/snapd/desktop/applications',
  '/var/lib/flatpak/app',
  '/var/lib/flatpak/exports/share/applications',
  '{home}/.local/share/flatpak/exports/share/applications',
  '/snap/bin',
  '{home}/.local/share/applications',
  '{home}/.gnome/apps',
  '/usr/share/applications',
  '/usr/local/share/applications',
  '/usr/share/app-install',
  '{home}/.config/autostart',
  '/var/lib/snapd/desktop/applications',
  '/var/lib/flatpak/app',
  '/var/lib/flatpak/exports/share/applications',
  '/snap/bin'
]
ERR: findDesktopFile() cant find file "tilix.desktop"! Searched desktopFileLocations: [
  '{home}/.local/share/applications',
  '{home}/.gnome/apps',
  '/usr/share/applications',
  '/usr/local/share/applications',
  '/usr/share/app-install',
  '{home}/.config/autostart',
  '/var/lib/snapd/desktop/applications',
  '/var/lib/flatpak/app',
  '/var/lib/flatpak/exports/share/applications',
  '{home}/.local/share/flatpak/exports/share/applications',
  '/snap/bin',
  '{home}/.local/share/applications',
  '{home}/.gnome/apps',
  '/usr/share/applications',
  '/usr/local/share/applications',
  '/usr/share/app-install',
  '{home}/.config/autostart',
  '/var/lib/snapd/desktop/applications',
  '/var/lib/flatpak/app',
  '/var/lib/flatpak/exports/share/applications',
  '/snap/bin'
]
ERR: findDesktopFile() cant find file "chromium-browser.desktop"! Searched desktopFileLocations: [
  '{home}/.local/share/applications',
  '{home}/.gnome/apps',
  '/usr/share/applications',
  '/usr/local/share/applications',
  '/usr/share/app-install',
  '{home}/.config/autostart',
  '/var/lib/snapd/desktop/applications',
  '/var/lib/flatpak/app',
  '/var/lib/flatpak/exports/share/applications',
  '{home}/.local/share/flatpak/exports/share/applications',
  '/snap/bin',
  '{home}/.local/share/applications',
  '{home}/.gnome/apps',
  '/usr/share/applications',
  '/usr/local/share/applications',
  '/usr/share/app-install',
  '{home}/.config/autostart',
  '/var/lib/snapd/desktop/applications',
  '/var/lib/flatpak/app',
  '/var/lib/flatpak/exports/share/applications',
  '/snap/bin'
]
ERR: findDesktopFile() cant find file "gedit.desktop"! Searched desktopFileLocations: [
  '{home}/.local/share/applications',
  '{home}/.gnome/apps',
  '/usr/share/applications',
  '/usr/local/share/applications',
  '/usr/share/app-install',
  '{home}/.config/autostart',
  '/var/lib/snapd/desktop/applications',
  '/var/lib/flatpak/app',
  '/var/lib/flatpak/exports/share/applications',
  '{home}/.local/share/flatpak/exports/share/applications',
  '/snap/bin',
  '{home}/.local/share/applications',
  '{home}/.gnome/apps',
  '/usr/share/applications',
  '/usr/local/share/applications',
  '/usr/share/app-install',
  '{home}/.config/autostart',
  '/var/lib/snapd/desktop/applications',
  '/var/lib/flatpak/app',
  '/var/lib/flatpak/exports/share/applications',
  '/snap/bin'
]
ERR: findDesktopFile() cant find file "gedit.desktop"! Searched desktopFileLocations: [
  '{home}/.local/share/applications',
  '{home}/.gnome/apps',
  '/usr/share/applications',
  '/usr/local/share/applications',
  '/usr/share/app-install',
  '{home}/.config/autostart',
  '/var/lib/snapd/desktop/applications',
  '/var/lib/flatpak/app',
  '/var/lib/flatpak/exports/share/applications',
  '{home}/.local/share/flatpak/exports/share/applications',
  '/snap/bin',
  '{home}/.local/share/applications',
  '{home}/.gnome/apps',
  '/usr/share/applications',
  '/usr/local/share/applications',
  '/usr/share/app-install',
  '{home}/.config/autostart',
  '/var/lib/snapd/desktop/applications',
  '/var/lib/flatpak/app',
  '/var/lib/flatpak/exports/share/applications',
  '/snap/bin'
]
ERR: findDesktopFile() cant find file "mattermost.desktop"! Searched desktopFileLocations: [
  '{home}/.local/share/applications',
  '{home}/.gnome/apps',
  '/usr/share/applications',
  '/usr/local/share/applications',
  '/usr/share/app-install',
  '{home}/.config/autostart',
  '/var/lib/snapd/desktop/applications',
  '/var/lib/flatpak/app',
  '/var/lib/flatpak/exports/share/applications',
  '{home}/.local/share/flatpak/exports/share/applications',
  '/snap/bin',
  '{home}/.local/share/applications',
  '{home}/.gnome/apps',
  '/usr/share/applications',
  '/usr/local/share/applications',
  '/usr/share/app-install',
  '{home}/.config/autostart',
  '/var/lib/snapd/desktop/applications',
  '/var/lib/flatpak/app',
  '/var/lib/flatpak/exports/share/applications',
  '/snap/bin'
]
ERR: findDesktopFile() cant find file "tilix.desktop"! Searched desktopFileLocations: [
  '{home}/.local/share/applications',
  '{home}/.gnome/apps',
  '/usr/share/applications',
  '/usr/local/share/applications',
  '/usr/share/app-install',
  '{home}/.config/autostart',
  '/var/lib/snapd/desktop/applications',
  '/var/lib/flatpak/app',
  '/var/lib/flatpak/exports/share/applications',
  '{home}/.local/share/flatpak/exports/share/applications',
  '/snap/bin',
  '{home}/.local/share/applications',
  '{home}/.gnome/apps',
  '/usr/share/applications',
  '/usr/local/share/applications',
  '/usr/share/app-install',
  '{home}/.config/autostart',
  '/var/lib/snapd/desktop/applications',
  '/var/lib/flatpak/app',
  '/var/lib/flatpak/exports/share/applications',
  '/snap/bin'
]
Generic Error in Meta Wrapper ERR: findDesktopFile() cant find file "gnome-calendar.desktop"! Searched desktopFileLocations: undefined
Generic Error in Meta Wrapper ERR: findDesktopFile() cant find file "tilix.desktop"! Searched desktopFileLocations: undefined
Generic Error in Meta Wrapper ERR: findDesktopFile() cant find file "chromium-browser.desktop"! Searched desktopFileLocations: undefined
Generic Error in Meta Wrapper ERR: findDesktopFile() cant find file "gedit.desktop"! Searched desktopFileLocations: undefined
Generic Error in Meta Wrapper ERR: findDesktopFile() cant find file "gedit.desktop"! Searched desktopFileLocations: undefined
Generic Error in Meta Wrapper ERR: findDesktopFile() cant find file "mattermost.desktop"! Searched desktopFileLocations: undefined
Generic Error in Meta Wrapper ERR: findDesktopFile() cant find file "tilix.desktop"! Searched desktopFileLocations: undefined

 Trying alternative guessing approach for "Gnome-calendar".....

 Trying alternative guessing approach for "Tilix".....

 Trying alternative guessing approach for "Chromium-browser".....

 Trying alternative guessing approach for "Gedit".....

 Trying alternative guessing approach for "Gedit".....

 Trying alternative guessing approach for "Mattermost".....

 Trying alternative guessing approach for "Tilix".....
ERR _guessFilePath() null
(node:930146) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'stack' of null
    at _catchGenericErr$1 (/home/curiouser/.nvm/versions/node/v14.16.0/lib/node_modules/linux-window-session-manager/dist/index.js:1084:61)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:930146) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 8)
(node:930146) [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.

 Alternative guessing approach for "Gedit" SUCCESS -> /usr/bin/gedit

 Alternative guessing approach for "Gedit" SUCCESS -> /usr/bin/gedit
ERR _guessFilePath() null
(node:930146) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'stack' of null
    at _catchGenericErr$1 (/home/curiouser/.nvm/versions/node/v14.16.0/lib/node_modules/linux-window-session-manager/dist/index.js:1084:61)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:930146) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 9)

 Alternative guessing approach for "Tilix" SUCCESS -> tilix

 Alternative guessing approach for "Gnome-calendar" SUCCESS -> /usr/bin/gnome-calendar

 Alternative guessing approach for "gnome" SUCCESS -> /usr/bin/nautilus
Generic Error in Main Handler TypeError: Cannot read property 'stack' of null
    at _catchGenericErr$1 (/home/curiouser/.nvm/versions/node/v14.16.0/lib/node_modules/linux-window-session-manager/dist/index.js:1084:61)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) TypeError: Cannot read property 'stack' of null
    at _catchGenericErr$1 (/home/curiouser/.nvm/versions/node/v14.16.0/lib/node_modules/linux-window-session-manager/dist/index.js:1084:61)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
Generic Error in Main Handler TypeError: Cannot read property 'stack' of null
    at _catchGenericErr$1 (/home/curiouser/.nvm/versions/node/v14.16.0/lib/node_modules/linux-window-session-manager/dist/index.js:1084:61)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) TypeError: Cannot read property 'stack' of null
    at _catchGenericErr$1 (/home/curiouser/.nvm/versions/node/v14.16.0/lib/node_modules/linux-window-session-manager/dist/index.js:1084:61)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:930146) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 9)
(node:930146) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 8)

 Alternative guessing approach for "Tilix" SUCCESS -> tilix
saveSessionForDisplayToDb: no session file present yet for "common-energy", creating a new one...
SAVED SESSION: common-energy

curiousercreative avatar Jul 06 '21 14:07 curiousercreative

Thanks for opening this up. Did you try going through the troubleshooting section for the apps that are not working?

johannesjo avatar Jul 07 '21 10:07 johannesjo

@johannesjo it's been a little while since I worked around this, so I can't recall if any of the troubleshooting was effective. FWIW, all of my apps open with my workaround...

curiousercreative avatar Jul 07 '21 13:07 curiousercreative

@johannesjo it would be a separate PR, but I have added this mapping to my config file for user installed flatpak Chromium: "chromium-browser.Chromium-browser": "org.chromium.Chromium.desktop"

curiousercreative avatar Jul 07 '21 13:07 curiousercreative

Looking at the logs I wonder why there are not desktop files found with the standard method. Maybe they are stored in a different location on your system? Would be good to know, so we can add it to the searched locations.

johannesjo avatar Jul 08 '21 10:07 johannesjo

@johannesjo it seems to find them as they are all restored. Or does alternative guessing approach mean looking for something other than desktop files? I believe the desktop locations including Chromium are standard search locations already. I only need that rule because the desktop file name doesn't seem to match the window name. Would it be helpful for me to send you a session file? I haven't looked at it very closely, but it doesn't seem to have any sensitive info in it...

curiousercreative avatar Jul 08 '21 15:07 curiousercreative

Or does alternative guessing approach mean looking for something other than desktop files?

Yes. It's a bit complicated. The first method uses the commands from the apps desktop files, which could contain additional startup params. The alternative approach checks /proc/${win.wmPid}/cmdline. Not really sure what all the implications are tbh, but I vaguely remember that the alternative approach didn't work for every app as expected.

Yes please. A session file would be helpful. If you don't want to post it here, you can also send it to [email protected] (though I would prefer to have it here ;)).

johannesjo avatar Jul 09 '21 13:07 johannesjo

@johannesjo here it is. I notice multiple entries for apps for different display sizes/arrangements, but I was receiving the errors with clean sessions with a singly display size.

{
  "name": "common-energy",
  "displaysCombinations": [
    {
      "id": "6912x2160",
      "windowList": [
        {
          "windowId": "0x3400007",
          "windowIdDec": 54525959,
          "wmCurrentDesktopNr": 0,
          "states": [],
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 5567,
          "wmClassName": "gnome-calendar.Gnome-calendar",
          "x": 3790,
          "y": 378,
          "width": 1822,
          "height": 1840,
          "simpleName": "Gnome-calendar",
          "executableFile": "/usr/bin/gnome-calendar"
        },
        {
          "windowId": "0x4200001",
          "windowIdDec": 69206017,
          "states": [
            "_NET_WM_STATE_MAXIMIZED_HORZ",
            "_NET_WM_STATE_MAXIMIZED_VERT"
          ],
          "wmCurrentDesktopNr": 0,
          "wmTitle": "WTF UTF8_STRING",
          "wmClassName": "atom.Atom",
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 5597,
          "x": 0,
          "y": 54,
          "width": 3840,
          "height": 2106,
          "simpleName": "Atom",
          "executableFile": "atom.desktop",
          "desktopFilePath": "/usr/share/applications/atom.desktop"
        },
        {
          "windowId": "0x6a00005",
          "windowIdDec": 111149061,
          "states": [],
          "wmCurrentDesktopNr": 0,
          "wmTitle": "WTF UTF8_STRING",
          "wmClassName": "slack.Slack",
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 2,
          "x": 5533,
          "y": 432,
          "width": 1379,
          "height": 1728,
          "simpleName": "Slack",
          "executableFile": "com.slack.Slack.desktop",
          "desktopFilePath": "/home/curiouser/.local/share/flatpak/exports/share/applications/com.slack.Slack.desktop"
        },
        {
          "windowId": "0x3c00010",
          "windowIdDec": 62914576,
          "states": [],
          "wmCurrentDesktopNr": 0,
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 5579,
          "wmClassName": "Mail.Thunderbird",
          "x": 3840,
          "y": 432,
          "width": 1708,
          "height": 1728,
          "simpleName": "Thunderbird",
          "executableFile": "thunderbird.desktop",
          "desktopFilePath": "/usr/share/applications/thunderbird.desktop"
        },
        {
          "windowId": "0x4c0001b",
          "windowIdDec": 79691803,
          "states": [],
          "wmCurrentDesktopNr": 0,
          "wmTitle": "WTF UTF8_STRING",
          "wmClassName": "chromium-browser.Chromium-browser",
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 2,
          "x": 0,
          "y": 54,
          "width": 2415,
          "height": 2106,
          "simpleName": "Chromium-browser",
          "executableFile": "org.chromium.Chromium.desktop",
          "desktopFilePath": "/home/curiouser/.local/share/flatpak/exports/share/applications/org.chromium.Chromium.desktop"
        },
        {
          "windowId": "0x3600078",
          "windowIdDec": 56623224,
          "states": [
            "_NET_WM_STATE_FOCUSED"
          ],
          "wmCurrentDesktopNr": 0,
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 7818,
          "wmClassName": "tilix.Tilix",
          "x": 2358,
          "y": 8,
          "width": 1534,
          "height": 2200,
          "simpleName": "Tilix",
          "executableFile": "tilix"
        }
      ]
    },
    {
      "id": "7456x2466",
      "windowList": [
        {
          "windowId": "0x2a000a8",
          "windowIdDec": 44040360,
          "states": [],
          "wmCurrentDesktopNr": 0,
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 5188,
          "wmClassName": "tilix.Tilix",
          "x": 2902,
          "y": 8,
          "width": 1534,
          "height": 2514,
          "simpleName": "Tilix",
          "executableFile": "tilix"
        },
        {
          "windowId": "0x3a00007",
          "windowIdDec": 60817415,
          "wmCurrentDesktopNr": 0,
          "states": [],
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 6758,
          "wmClassName": "gnome-calendar.Gnome-calendar",
          "x": 4332,
          "y": 688,
          "width": 1790,
          "height": 1836,
          "simpleName": "Gnome-calendar",
          "executableFile": "/usr/bin/gnome-calendar"
        },
        {
          "windowId": "0x4200007",
          "windowIdDec": 69206023,
          "states": [
            "_NET_WM_STATE_MAXIMIZED_HORZ",
            "_NET_WM_STATE_MAXIMIZED_VERT"
          ],
          "wmCurrentDesktopNr": 0,
          "wmTitle": "WTF UTF8_STRING",
          "wmClassName": "atom.Atom",
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 6771,
          "x": 0,
          "y": 54,
          "width": 4384,
          "height": 2412,
          "simpleName": "Atom",
          "executableFile": "atom.desktop",
          "desktopFilePath": "/usr/share/applications/atom.desktop"
        },
        {
          "windowId": "0x5c00005",
          "windowIdDec": 96468997,
          "states": [],
          "wmCurrentDesktopNr": 0,
          "wmTitle": "WTF UTF8_STRING",
          "wmClassName": "slack.Slack",
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 2,
          "x": 6070,
          "y": 738,
          "width": 1381,
          "height": 1727,
          "simpleName": "Slack",
          "executableFile": "com.slack.Slack.desktop",
          "desktopFilePath": "/home/curiouser/.local/share/flatpak/exports/share/applications/com.slack.Slack.desktop"
        },
        {
          "windowId": "0x3e00010",
          "windowIdDec": 65011728,
          "states": [],
          "wmCurrentDesktopNr": 0,
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 6753,
          "wmClassName": "Mail.Thunderbird",
          "x": 4384,
          "y": 738,
          "width": 1692,
          "height": 1716,
          "simpleName": "Thunderbird",
          "executableFile": "thunderbird.desktop",
          "desktopFilePath": "/usr/share/applications/thunderbird.desktop"
        },
        {
          "windowId": "0x200005",
          "windowIdDec": 2097157,
          "states": [
            "_NET_WM_STATE_FOCUSED"
          ],
          "wmTitle": "WTF UTF8_STRING",
          "wmClassName": "chromium-browser.Chromium-browser",
          "wmCurrentDesktopNr": 0,
          "wmType": "_NET_WM_WINDOW_TYPE_NORMAL",
          "wmPid": 2,
          "x": 0,
          "y": 54,
          "width": 2954,
          "height": 2412,
          "simpleName": "Chromium-browser",
          "executableFile": "org.chromium.Chromium.desktop",
          "desktopFilePath": "/home/curiouser/.local/share/flatpak/exports/share/applications/org.chromium.Chromium.desktop"
        }
      ]
    }
  ]
}

curiousercreative avatar Jul 11 '21 19:07 curiousercreative

Thank you!

Would you mind posting also the output of locate gedit.desktop (from root)?

johannesjo avatar Jul 12 '21 11:07 johannesjo

Would you mind posting also the output of locate gedit.desktop (from root)?

@johannesjo just now seeing this, sorry! I had to install locate (sudo apt install mlocate on debian/ubuntu/pop-os) but here's the output:

$ sudo locate gedit.desktop
/usr/share/app-install/desktop/gedit:gedit.desktop
/usr/share/applications/org.gnome.gedit.desktop

curiousercreative avatar Dec 10 '21 15:12 curiousercreative

Thanks. How you can work around this is to manually provide a mapping for gedit in the main config file under ~/.config/lwsm/config.json. There under the key WM_CLASS_AND_EXECUTABLE_FILE_MAP you should add "gedit.Gedit": "org.gnome.gedit.desktop",.

johannesjo avatar Dec 12 '21 17:12 johannesjo