Categories
Code

ox-tagfilter-js version 1.0

I’ve just released version 1.0 of ox-tagfilter-js, after finally adding a search box to the UI. If you are an Org-mode user and publish org-exported HTML documents from your org-files, you might find this extension useful. It allows you to quickly filter document content, based on tags and heading text, using a web UI.

I use it to lookup stuff in my «digital brain», a growing huge journal of private notes that I maintain as an org-file. The org-file is automatically published to the web, and so I can read and search it easily from anywhere, including with my mobile phone.

Categories
Security

Signing out of account.microsoft.com

I have an account at Microsoft that I use occasionally from the web. After logging in and choosing «No» to the «Stay signed in?»-question, here is how signing out of account.microsoft.com works1:

  1. I click «Log off» from the top right account menu.
  2. I land on a page me telling me that I’ve been logged off. (It also tells me it is a good idea to close all browser windows.)
  3. I navigate back to account.microsoft.com by typing it in the address bar.
  4. I am right back in my Microsoft account overview, with no login steps required. So I guess I wasn’t signed out after all !

Now, I repeat steps 1 through 4, but at step 2 I actually restart my browser, like the dialogue advises. In one instance, this worked, and I was in fact properly logged out afterwords, but another time it didn’t, and I still had a session. And you better make sure to close all tabs/windows – simply closing the tab/window used for the Microsoft service is certainly not sufficient.

Lastly, sometimes I just get this message:

No, I am not «still signed in to some applications». This is simply a broken, slow and enshittified web experience created by one of the greatest big tech enshittifiers.

Take from this anecdotal evidence whatever you like, but I know I am not logging in to Microsoft services on devices that I don’t own or trust. The web logout flow is unreliable and broken, so better go delete all cookies manually, across several Microsoft-domains2, if you actually want to ensure your session is killed from the client side. Alternatively, make sure to always use a temporary incognito browser session.

  1. On Firefox v127.0.2, clean user profile with no extensions and no setting adjustments, Ubuntu 22.04. ↩︎
  2. At least live.com, login.microsoftonline.com, microsoft.com and account.microsoft.com. ↩︎
Categories
Code Linux

Handling OS events in Emacs Lisp

Emacs can access files on any remote server running an ssh or SFTP service, assuming that an ssh client is installed on the host where Emacs runs. I use this extensively, since I run my own personal home servers available over the internet. On those servers, I have files and resources that I access all time, from anywhere.

/ssh:server.example.com:~/myfile.txt

Opening this path in Emacs will automatically open an ssh-connection to server.example.com and transparently allow editing of myfile.txt. Emacs uses the TRAMP package (Transparent Remote Access, Multiple Protocols) to provide this functionality.

TRAMP is designed to re-use existing ssh-connections for accessing multiple resources (on the same server). When using a laptop, where network conditions change and the system is frequently suspended, such persistent connections tend to hang for a while after the operating system has resumed operation, which can block Emacs. This is annoying, especially when I’d like to access a remote file immediately, and ssh hasn’t yet detected that its TCP connection has become unusable.

TRAMP provides a convenient function to clean up all existing connections, aptly named tramp-cleanup-all-connections, which I want to automatically call when the operating system wakes up from a suspended state or if the network changes.

Detecting operating system events on Linux

If running in a typical Linux environment, you can make Emacs listen for DBUS system bus events. Check out my packages nm.el and upower.el for code which reacts to networking and power management events.

For example, to automatically clean up remote connections whenever network connects or re-connects, the following code would work (requires that NetworkManager is used by Linux distro):

(load-file "/path/to/nm.el")
(add-hook 'nm-connected-hook 'tramp-cleanup-all-connections)
(nm-enable)

Or to do the same whenever the machine resumes from suspend:

(load-file "/path/to/upower.el")
(add-hook 'upower-resume-hook 'tramp-cleanup-all-connections)
(upower-enable)

Detecting resume by using system clock

I also use Emacs on Windows sometimes, in a WSL environment where DBUS is not available. But we can still detect if the machine has been resumed in a generic manner, by observing the system clock:

(defvar clock-jump-detector-hook nil
  "Functions to run when a system clock jump is detected.")
(defvar clock-jump-detector-threshold (* 5 60)
  "Minimum time skip (in seconds) to consider
it a system clock jump. When it is detected that
the system clock jumps with more than this number of seconds, then hooks in `clock-jump-detector-hook'
are run.")

(setq clock-jump-detector-time (current-time))
(defun clock-jump-detector ()
  (let ((time-passed (float-time (time-since clock-jump-detector-time))))
    (setq clock-jump-detector-time (current-time))
    (when (> time-passed clock-jump-detector-threshold)
      (message "Clock jump of %f seconds detected, running hooks .." time-passed)
      (run-hooks 'clock-jump-detector-hook))))
(run-at-time t 15 'clock-jump-detector)

The code records the current time every 15 seconds, and if a time jump beyond a threshold is detected (a «clock jump»), then all functions in hook-variable clock-jump-detector-hook are invoked.

By having Emacs listen for operating system events over DBUS and invoking functions in hook-variables, you can make anything happen in a loosely coupled fashion.