1

I use the Evince pdf reader on WSL2, but it isn't remembering the last visited page. Every time I open a pdf file, it starts from the first page in a small window with the message:

chen@4-726:~/Documents/latex/notes/physics/tokamak$ Gdk-Message: 11:43:25.750: Unable to load hand2 from the cursor theme
Gdk-Message: 11:43:25.925: Unable to load hand2 from the cursor theme
Gdk-Message: 11:43:26.153: Unable to load hand2 from the cursor theme

I read a post saying that evince should store reading histories in ~/.local/share/gvfs-metadata/home, but I don't see folder gvfs-metadata in WSL2.

Then another comment says:

If evince is compiled without gvfs-support it does not remembers the history or last opened page.

So how can I get gvfs-support for WSL2 and make Evince remember reading history?


ps my system inforation

All my system seems to have the newest version:

Device name 1-039-11
Processor AMD Ryzen 9 5900X 12-Core Processor 3.70 GHz
Installed RAM 32.0 GB
Device ID D3418E8A-2C8C-4EC2-A836-7ABF7E5D9D51
Product ID 00330-71450-76029-AAOEM
System type 64-bit operating system, x64-based processor
Pen and touch No pen or touch input is available for this display

Edition Windows 11 Pro
Version 21H2
Installed on ‎1/‎11/‎2022
OS build 22000.708
Experience Windows Feature Experience Pack 1000.22000.708.0

Linux 1-039-11 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

            .-/+oossssoo+/-.               chen@1-039-11 
        `:+ssssssssssssssssss+:`           ------------- 
      -+ssssssssssssssssssyyssss+-         OS: Ubuntu 22.04 LTS on Windows 10 x86_64 
    .ossssssssssssssssssdMMMNysssso.       Kernel: 5.10.102.1-microsoft-standard-WSL2 
   /ssssssssssshdmmNNmmyNMMMMhssssss/      Uptime: 20 hours, 28 mins 
  +ssssssssshmydMMMMMMMNddddyssssssss+     Packages: 1922 (dpkg) 
 /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/    Shell: bash 5.1.16 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Theme: Adwaita [GTK3] 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   Icons: Adwaita [GTK3] 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   Terminal: terminator 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   CPU: AMD Ryzen 9 5900X (24) @ 3.700GHz 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   GPU: 3448:00:00.0 Microsoft Corporation Device 008e 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Memory: 529MiB / 15952MiB 
 /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/
  +sssssssssdmydMMMMMMMMddddyssssssss+                             
   /ssssssssssshdmNNNNmyNMMMMhssssss/                              
    .ossssssssssssssssssdMMMNysssso.
      -+sssssssssssssssssyyyssss+-
        `:+ssssssssssssssssss+:`
            .-/+oossssoo+/-.


John Chen
  • 85
  • 6
  • 1
    You've done some good research there. The gvfs hint is almost certainly the key. I should be able to test and write up an answer for you fairly soon. – NotTheDr01ds Jun 06 '22 at 11:39
  • 1
    You don't mention your Linux distribution, though. I'm going to assume Ubuntu, but it's best to include that information (and your Windows version) in WSL questions. Thanks! – NotTheDr01ds Jun 06 '22 at 11:41

1 Answers1

0
Short answer:

Assuming that you are using Ubuntu:

sudo apt install gvfs
dbus-launch evince <file.pdf>

Scroll to a location in the PDF, then exit Evince and:

dbus-launch evince <file.pdf>

It should now open to the previous location.

More detail:

You are absolutely right that Evince uses GVfs (the Gnome Virtual File System) to store its bookmarks.

There are a few reasons why this doesn't work (by default) on WSL:

  • GVfs isn't installed by default on most WSL distributions.

  • GVfs requires a user-session D-Bus instance. D-Bus is, to take the simple definition from a much more complicated page:

    a simple way for applications to talk to one another

    makes it simple and reliable to code a "single instance" application or daemon, and to launch applications and daemons on demand when their services are needed

    So Evince uses D-Bus to launch-or-attach-to a single instance of the GVfs daemon, and then uses GVfs to store the bookmark.

  • But that D-Bus instance is normally set up for you by Systemd (and/or PAM) on login.

  • And WSL doesn't really have the concept of a "login" (you typically never need to enter a password when starting WSL). WSL also doesn't support Systemd out of the box.

All of this combines to mean that (in a default WSL installation) Evince isn't going to keep track of your last location/bookmark.

Installing GVfs is the first step.

Then, you have two options:

  • dbus-launch evince each time you start, as in the example above.

  • Or, when you start WSL, use:

    wsl ~ -e dbus-launch bash # Or your preferred shell
    

    That will start your Bash shell in a D-Bus user session, and then simply doing evince <file.pdf> will open to the last location.

You can see some of what is happening by running ps -efH between each command. You'll see that dbus-launch bash will start a D-Bus process, but not much else. Then running evince will also start up on-demand GVfs processes.

NotTheDr01ds
  • 17,574
  • 4
  • 44
  • 81