aoe2de protocol handler for Linux
Overview
The url using a custom protocol aoe2de://1/12394872348
can be used by Age of Empires 2: Definitive Edition to directly join or spectate a game. This behavior can be established in GNU/Linux with some easy customization.
Making the protocol links work
-
Modify
xdg-open
.By default,
xdg-open
does not recognize protocolaoe2de://
as a URL because of the digit. It treats the protocol as a file instead of a url, so I had to modify/usr/bin/xdg-open
:sudo sed -i.bup -r -e '/grep -q.\*:alpha:.\*then/s/:alpha:/:alnum:/g;' /usr/bin/xdg-open
Alternatively, you just need to modify the regular expression inside function to use alnum:
# Returns true if argument is a file:// URL or path is_file_url_or_path() { if echo "$1" | grep -q '^file://' \ || ! echo "$1" | egrep -q '^[[:alnum:]+\.\-]+:'; then return 0 else return 1 fi }
-
Establish script to run
AOEURLHelper.exe
.I named it
~/bin/aoe2de-protocol
. -
Establish desktop file with mimetype handler.
I named mine
~/.local/share/applications/aoe2de-protocol.desktop
.[Desktop Entry] Name=AOEURLHelper Comment=Load url for Age of Empires 2: Definitive Edition Exec=aoe2de-protocol %u Icon=steam_icon_813780 Terminal=false Type=Application Categories=Game; MimeType=x-scheme-handler/aoe2de;
-
Ensure this desktop file is used with xdg-open.
Run these commands.
$ xdg-mime default aoe2de-protocol.desktop x-scheme-handler/aoe2de $ xdg-mime query default x-scheme-handler/aoe2de aoe2de-protocol.desktop
-
Configure Firefox-based web browser to use this application for links of this protocol.
In
about:config
, set a new booleannetwork.protocol-handler.expose.aoe2de
=false
. Then visit one of the lobby browsers (below) and find a join link. Select the link, and choose your new .desktop file.The first time, it failed. When I tried again, the web browser showed the second menu item named "AOEURLHelper" which is what I put in that "Name" field and it did invoke my shell script and then try to join the game.
Additional thoughts
The xdg-open aoe2de://0/123412341234
invocation works when the game is not already running, and when the game is already running. Of course, due to how long it takes the game to load, loading a aoe2de link loads faster if the game is already running.
Protocol description
This is not a specification because I don't know of any that has been published.
aoe2de://0/126811196
This link tries to join game id 126811196. You can learn your game id when you are the host, from the button in the upper-right of the lobby screen.
aoe2de://1/123498272
The top virtual directory /1/
indicates that the program should try to spectate the match.
Lobby browsers
If these are working at any given moment, here are a few that I found:
References
Weblinks
- xdg - Create a custom URL Protocol Handler - Unix & Linux Stack Exchange
- linux - Ubuntu custom URL protocol handler - Stack Overflow
- [RESOLVED] AoE2.net Spectate button no longer working. Someone please help me!!! | AoEZone - The International Age of Empires Community
- Running a second program inside a proton prefix. : linux_gaming
- Set custom protocol handler in Firefox? - Stack Overflow
- Register protocol - MozillaZine Knowledge Base
Comments