i3-resurrect icon indicating copy to clipboard operation
i3-resurrect copied to clipboard

Programs running in urxvt not saved

Open danhab99 opened this issue 3 years ago • 8 comments

Describe the bug

I work pretty much completely using CLI programs like vim. My default terminal emulator is Urxvt. i3-resurrect doesn't retain the cwd or program that urxvt was running.

To Reproduce Steps to reproduce the behavior:

  1. Install my dotfiles
  2. Setup a urxvt window running vim and some other program like a node script on workspace "2"
  3. Run i3-resurrect save -w 2
  4. Attempt to restore workspace 2 like this: i3-resurrect restore -w 2
  5. Programs don't restore

Expected behavior A clear and concise description of what you expected to happen.

Programs are rerun in accordance to its cmdline

Screenshots

  • idk what to show -

System information (please complete the following information):

  • Linux distribution: Manjaro Linux x86_64 (5.10.49-1-MANJARO)
  • i3-resurrect version (output of i3-resurrect --version): i3-resurrect, version 1.4.3
  • i3 version (output of i3 -v): i3 version 4.19.1 (2021-02-01) © 2009 Michael Stapelberg and contributors
  • Python version (output of python -V): Python 3.9.6

Additional context Add any other context about the problem here.

Layout:

{
  "border": "normal",
  "current_border_width": -1,
  "floating": "auto_off",
  "fullscreen_mode": 0,
  "geometry": {
    "x": 0,
    "y": 0,
    "width": 0,
    "height": 0
  },
  "layout": "splitv",
  "marks": [],
  "name": "2",
  "orientation": "vertical",
  "percent": null,
  "scratchpad_state": "none",
  "sticky": false,
  "type": "workspace",
  "workspace_layout": "default",
  "nodes": [
    {
      "border": "normal",
      "current_border_width": -1,
      "floating": "auto_off",
      "fullscreen_mode": 0,
      "geometry": {
        "x": 0,
        "y": 0,
        "width": 0,
        "height": 0
      },
      "layout": "splith",
      "marks": [],
      "name": null,
      "orientation": "horizontal",
      "percent": 0.8,
      "scratchpad_state": "none",
      "sticky": false,
      "type": "con",
      "workspace_layout": "default",
      "nodes": [
        {
          "border": "normal",
          "current_border_width": -1,
          "floating": "auto_off",
          "fullscreen_mode": 0,
          "geometry": {
            "x": 0,
            "y": 0,
            "width": 0,
            "height": 0
          },
          "layout": "splitv",
          "marks": [],
          "name": null,
          "orientation": "vertical",
          "percent": 0.65,
          "scratchpad_state": "none",
          "sticky": false,
          "type": "con",
          "workspace_layout": "default",
          "nodes": [
            {
              "border": "pixel",
              "current_border_width": 0,
              "floating": "auto_off",
              "fullscreen_mode": 0,
              "geometry": {
                "x": 0,
                "y": 0,
                "width": 840,
                "height": 520
              },
              "layout": "splith",
              "marks": [],
              "name": "NERD_tree_1 - (~/Documents/node/cryptochan) - VIM",
              "orientation": "none",
              "percent": 1.0,
              "scratchpad_state": "none",
              "sticky": false,
              "type": "con",
              "workspace_layout": "default",
              "swallows": [
                {
                  "class": "^URxvt$",
                  "instance": "^urxvt$"
                }
              ]
            }
          ]
        },
        {
          "border": "pixel",
          "current_border_width": 0,
          "floating": "auto_off",
          "fullscreen_mode": 0,
          "geometry": {
            "x": 0,
            "y": 0,
            "width": 840,
            "height": 520
          },
          "layout": "splith",
          "marks": [],
          "name": "dan@dan-81c9: ~/Documents/node/cryptochan",
          "orientation": "none",
          "percent": 0.35,
          "scratchpad_state": "none",
          "sticky": false,
          "type": "con",
          "workspace_layout": "default",
          "swallows": [
            {
              "class": "^URxvt$",
              "instance": "^urxvt$"
            }
          ]
        }
      ]
    },
    {
      "border": "pixel",
      "current_border_width": 0,
      "floating": "auto_off",
      "fullscreen_mode": 0,
      "geometry": {
        "x": 0,
        "y": 0,
        "width": 840,
        "height": 520
      },
      "layout": "splith",
      "marks": [],
      "name": "yarn dev",
      "orientation": "none",
      "percent": 0.19999999999999998,
      "scratchpad_state": "none",
      "sticky": false,
      "type": "con",
      "workspace_layout": "default",
      "swallows": [
        {
          "class": "^URxvt$",
          "instance": "^urxvt$"
        }
      ]
    }
  ]
}

Programs:


[
  {
    "command": [
      "/usr/bin/urxvt"
    ],
    "working_directory": "/home/dan"
  },
  {
    "command": [
      "/usr/bin/urxvt"
    ],
    "working_directory": "/home/dan"
  },
  {
    "command": [
      "/usr/bin/urxvt"
    ],
    "working_directory": "/home/dan"
  }
]

This is the project I was working on incase you were wondering.

danhab99 avatar Jul 23 '21 17:07 danhab99

Looks somewhat similar to #96

Expected behavior Programs are rerun in accordance to its cmdline

Would you mind showing the original cmdline of these processes? You can find this by running the following command:

hexdump -C /proc/$(xprop _NET_WM_PID | cut -d ' ' -f3)/cmdline

Then click on one of the urxvt windows, and paste the output here.

JonnyHaystack avatar Jul 30 '21 14:07 JonnyHaystack

All 3 of these outputs are from different tiles. Is this a urxvt issue?

00000000  75 72 78 76 74 00                                 |urxvt.|
00000006
00000000  75 72 78 76 74 00                                 |urxvt.|
00000006
00000000  75 72 78 76 74 00                                 |urxvt.|
00000006

danhab99 avatar Jul 30 '21 16:07 danhab99

Uh sorry should've asked before but can you also show the output of ls -l /proc/$(xprop _NET_WM_PID | cut -d ' ' -f3)/cwd

JonnyHaystack avatar Jul 30 '21 21:07 JonnyHaystack

Oh I also forgot to ask, have you added the urxvt window class as a terminal in the i3-resurrect config? See https://github.com/JonnyHaystack/i3-resurrect#terminals

Been a while since I've been deep in the code or changed my config so I totally forgot this was a thing.. The terminal emulator's cwd doesn't change, but the shell's cwd does. So you need to add it to that list in the config so that i3-resurrect knows to look at the shell subprocess for the cwd instead of the terminal emulator process.

JonnyHaystack avatar Aug 04 '21 20:08 JonnyHaystack

@JonnyHaystack JonnyHaystack

Uh sorry should've asked before but can you also show the output of ls -l /proc/$(xprop _NET_WM_PID | cut -d ' ' -f3)/cwd

lrwxrwxrwx 1 dan dan 0 Sep  8 16:34 /proc/422021/cwd -> /home/dan

danhab99 avatar Sep 08 '21 20:09 danhab99

Did you check that you have done according to my last comment and added it as a terminal? That should fix any problem with working directory being restored. Also I'm not really understanding the problem. Programs running inside your shell aren't normally going to be restored, that's not how it works. If you manually launched the terminal emulator passing in a command to execute directly e.g. if I ran something like alacritty -e tmux a from rofi or from another shell, that would create an alacritty window that launches tmux and attaches to my last session. i3-resurrect can save and restore this no problem because the full command line was passed in from the start, so it's saved in the process cmdline. However, if you start a terminal/shell and later launch another program inside it, e.g. vim, that would not be saved to the cmdline of the shell or terminal emulator so i3-resurrect has no way of knowing to restore it. It's not feasible to look at every subprocess of every subprocess and figure out how to restore everything for arbitrary programs, especially with multi threaded programs etc.

JonnyHaystack avatar Sep 09 '21 06:09 JonnyHaystack

Your suggestion solved it for me in kitty. Any reason not to add more terminals to the default list ?

teto avatar Oct 02 '21 22:10 teto

@teto I didn't want to go adding things that I haven't tested, but yeah I should really add more

JonnyHaystack avatar Oct 02 '21 23:10 JonnyHaystack