Checking for mu lock

47 views
Skip to first unread message

Ben Mezger

unread,
Aug 5, 2021, 2:14:42 PM8/5/21
to mu-di...@googlegroups.com

Greetings,

I wonder if there is a way I can check whether mu is currently locked
(in use). AFAIK mu creates a lock file, which I believe is located in
$HOME/.mu/xapian/flintlock, but it seems that when I quit mu4e that file
still persists.

I am asking because I have a script which runs mu every N minutes, but
that fails when I have mu4e opened, so ideally I would like to check for
the lock file before running my script.

Any thoughts?

---
Ben Mezger

Andrew Fontaine

unread,
Aug 5, 2021, 2:46:18 PM8/5/21
to mu-di...@googlegroups.com, Ben Mezger

"Ben Mezger" <m...@benmezger.nl> writes:

> I am asking because I have a script which runs mu every N minutes, but
> that fails when I have mu4e opened, so ideally I would like to check for
> the lock file before running my script.
>
> Any thoughts?

I have a similar script that utilizes the emacs daemon to update the
index instead:

#+begin_src

emacsclient --eval '(mu4e-update-index)'

#+end_src

I think this would expect you to only use mu4e in the daemon though, so
it may not work for you. It might also be usable as a fallback command
though!

--

Andrew Fontaine

Ben Mezger

unread,
Aug 5, 2021, 4:47:37 PM8/5/21
to Andrew Fontaine, mu-di...@googlegroups.com

I was reading this [1] documentation, and it seems there is a way to
check the lock file by using the xapian-delve command:

$ xapian-delve ~/.cache/mu/xapian
UUID = d741098b-7ed7-4ec4-bd10-9aa49b7e2f81
number of documents = 17462
average document length = 1726.78
document length lower bound = 20
document length upper bound = 411552
highest document id ever used = 17462
has positional information = true
revision = 5
currently open for writing = true

When mu4e is closed, it sets "currently open for writing = false", so we
can simply grep that or further search the documentation as there might be
a command which does it by return code, so we don't need to grep the string.

Though I don't use mu4e in the daemon, this seems like an interesting
approach. Currently, I have a script which simply runs from time to time
in order to index everything.

[1] - https://xapian.org/docs/admin_notes.html#inspecting-a-database
[2] - https://github.com/benmezger/dotfiles/blob/main/dot_bin/executable_syncmail.tmpl
Kind regards,
Met een vriendelijke groet,
Atenciosamente,

Ben Mezger

https://seds.nl
https://github.com/benmezger

Andrew Fontaine

unread,
Aug 7, 2021, 2:40:25 PM8/7/21
to Ben Mezger, mu-di...@googlegroups.com

"Ben Mezger" <m...@benmezger.nl> writes:

> I was reading this [1] documentation, and it seems there is a way to
> check the lock file by using the xapian-delve command:
>
> $ xapian-delve ~/.cache/mu/xapian
> UUID = d741098b-7ed7-4ec4-bd10-9aa49b7e2f81
> number of documents = 17462
> average document length = 1726.78
> document length lower bound = 20
> document length upper bound = 411552
> highest document id ever used = 17462
> has positional information = true
> revision = 5
> currently open for writing = true
>
> When mu4e is closed, it sets "currently open for writing = false", so we
> can simply grep that or further search the documentation as there might be
> a command which does it by return code, so we don't need to grep the string.

This seems like a fine approach as well.

> Though I don't use mu4e in the daemon, this seems like an interesting
> approach. Currently, I have a script which simply runs from time to time
> in order to index everything.

This would also work if you start the daemon with (server-start) while
in emacs, and then the script could be:

#+begin_src

mu index && emacsclient --eval '(mu4e-update-index)'

#+end_src

I think grepping the output of xapian-delve is really only helpful as it
avoids the bad return code, but still doesn't update the mu index in the
end, so you would have to update manually within emacs anyway.

--

Andrew Fontaine
afontaine.dev

Reply all
Reply to author
Forward
0 new messages