2025-08-21 04:54:00
feyor.sh

I have a slight problem wherein every time I start up a game of NetHack, I completely loose touch with my surroundings for hours on end.
Thankfully The DevTeam Thinks Of Everything and there’s a solution that allows communication with the outside world without breaking immersion: the mail daemon!
If compiled with -DMAIL
and OPTIONS=mail
is set in your runtime configuration (the default on Linux), NetHack will periodically check a user specified mbox file (MAIL
) for new mail, and upon receiving an email a mail daemon will spawn in and deliver a scroll of mail to the player.
Upon reading this scroll a mail program (MAILREADER
) will be executed, which hopefully allows you to read your mail.
I use the Lisp window port to play NetHack (the way God intended), and I really don’t like leaving Emacs, so let’s figure out how to integrate this feature with mu4e.
mu uses maildir, not mbox, so I decided to write a cron job that periodically converts my maildir to mbox format.
An important insight is that NetHack never checks the contents of the mailbox file, just the mtime
.
Therefore all our script needs to do is check if our maildir contains any messages received within the last
minutes, and if so touch the mbox file.
Python
import os
import mailbox
from datetime import datetime, timedelta
import pathlib
MAILDIR = os.path.expanduser("~/Mail/personal/INBOX")
MBOX = "/tmp/nh.mbox"
maildir = mailbox.Maildir(MAILDIR)
for msg in maildir:
if datetime.fromtimestamp(msg.get_date()) > datetime.now() - timedelta(minutes=5):
pathlib.Path(MBOX).touch()
break
maildir.close()
Next, we need a script that will open up mu4e.
Bash
emacsclient -n --eval "(progn (require 'mu4e) (mu4e-context-switch nil \"Personal\") (mu4e-search-bookmark \"maildir:/personal/INBOX AND flag:unread\"))"
I’m using emacsclient instead of plain old emacs partly because only one process at a time can hold the lock on mu’s database, so I don’t want to spin up another Emacs process.
It’s also worth mentioning that my emacsclient is wrapped such that it opens a new frame if invoked outside of Emacs and reuses the current frame if invoked from within Emacs, so this behaves as you would expect, even if I’m using e.g. the curses port in a separate terminal.
Bash
export _t='-c'
exec "/nix/store/...-emacs/bin/.emacsclient-wrapped" "${_t/${INSIDE_EMACS:+*}/-u}" -a /nix/store/...-emacs/Applications/Emacs.app/Contents/MacOS/Emacs "$@"
Here’s some riveting gameplay footage of dungeon level 1:

Keep your files stored safely and securely with the SanDisk 2TB Extreme Portable SSD. With over 69,505 ratings and an impressive 4.6 out of 5 stars, this product has been purchased over 8K+ times in the past month. At only $129.99, this Amazon’s Choice product is a must-have for secure file storage.
Help keep private content private with the included password protection featuring 256-bit AES hardware encryption. Order now for just $129.99 on Amazon!
Help Power Techcratic’s Future – Scan To Support
If Techcratic’s content and insights have helped you, consider giving back by supporting the platform with crypto. Every contribution makes a difference, whether it’s for high-quality content, server maintenance, or future updates. Techcratic is constantly evolving, and your support helps drive that progress.
As a solo operator who wears all the hats, creating content, managing the tech, and running the site, your support allows me to stay focused on delivering valuable resources. Your support keeps everything running smoothly and enables me to continue creating the content you love. I’m deeply grateful for your support, it truly means the world to me! Thank you!
BITCOIN bc1qlszw7elx2qahjwvaryh0tkgg8y68enw30gpvge Scan the QR code with your crypto wallet app |
DOGECOIN D64GwvvYQxFXYyan3oQCrmWfidf6T3JpBA Scan the QR code with your crypto wallet app |
ETHEREUM 0xe9BC980DF3d985730dA827996B43E4A62CCBAA7a Scan the QR code with your crypto wallet app |
Please read the Privacy and Security Disclaimer on how Techcratic handles your support.
Disclaimer: As an Amazon Associate, Techcratic may earn from qualifying purchases.