WINE / Linux logoff macro

Hardcore WINE / Linux game players REJOICE!!!

What is it? A simple macro that runs on Linux / WINE that allows you to hit one key and logoff. It's much easier than <alt> F4 because you press just one key (which you choose) AND it returns you to the character selection screen instead of entirely closing the game client, which saves time, instead of reloading the game. It also may be safer / faster than <alt> F4.

Thanks to ionface there are 2 options to choose from. Both use the linux utility program xbindkeys.
The first approach (from me) sends the command "/exit" to the game.
The second approach (from ionface) disconnects the tcp connection using iptables. This is probably faster but involves some potential security issues - more discussion needed by experts.

-----COMMON TO BOTH----- - using xbindkeys
xbindkeys has a standard configuration file .xbindkeysrc where we will place our script.
The general format is:

"do this command" (which for us depends on method 1 or 2. The command is inside quotes.)
mykey (whatever key you bind - I like this key in the corner ` and the config file uses its name: grave

-----METHOD 1----------
It does this by sending the command "/exit" to the game when we press our key, so the client logs out the character and goes to the selection screen.

It depends on two programs: xbindkeys and xdotool. I leave it up to the user to install these programs on their linux version, but they are very common linux utilities.

Put the following in your .xbindkeysrc file (and the quoted line is all one long line and the quotes also go in the file). Change grave to whatever you prefer.

"xdotool key --delay 0 --window $( xdotool search --limit 1 --all --pid $( pgrep PathOfExile.exe ) --name Path ) Return slash e x i t Return"
grave

Grave ` is the name of the key that I like. You can change it to whatever you prefer, e.g. z for a regular letter. After editing and saving the file run xbindkeys which runs in the background until you kill it (e.g. killall xbindkeys) and constantly scans for that keypress.

The command does 3 things:
a) Find the path of exile game process id
b) Find the window id that it is using
c) Send /exit as a command to that window

I just figured out all this today, and while decent at Linux, am by no means an expert. Ideally I would prefer a direct logout from the TCP connection with killcx, but couldn't get it to work. I haven't tested this very much yet. Hopefully some smart people will move the ball forward. ionface has already has provided the answer: Method 2 -- Thanks!!!

-----METHOD 2---------- Thanks to ionface
This methods sends a new rule to iptables which logs out the client. After a brief pause, the rule is deleted so that the client can reconnect.
In the .xbindkeysrc the new command to do this is:

"iptables -I INPUT -p tcp --sport 6112 --tcp-flags PSH,ACK PSH,ACK -j REJECT --reject-with tcp-reset; sleep 1; iptables -D INPUT -p tcp --sport 6112 --tcp-flags PSH,ACK PSH,ACK -j REJECT --reject-with tcp-reset"

The security issue is the following: To do this, the iptables command requires root access. Here is where some knowledge of Linux security is needed. One solution is to add iptables to sudo. The other is to run xbindkeys itself as root. This also means having a config file of /root/.xbindkeysrc that is used, instead of /home/$USERNAME/.xbindkeysrc. Another option is to put the iptables commands inside a bash script and call it from .xbindkeys with "env -i /home/$USERNAME/MY_SCRIPT.sh Suggestions / comments / security issue discussion welcome.

Thanks very much to ionface for Method 2. Method 1 is a nice intro to scripting/interacting with the client. Method 2 is an intro to manipulating iptables.

Good luck and if I have time, I will try to answer any questions or feedback in this thread. Be safe and have fun!

Thanks to GGG for this awesome game, and please advise if this macro breaks any rules.
Last edited by CookieTough2 on May 31, 2016, 11:30:42 PM
Last bumped on Sep 22, 2024, 10:44:57 AM
The following should work for most systems:
"
sudo iptables -I INPUT -p tcp --sport 6112 --tcp-flags PSH,ACK PSH,ACK -j REJECT --reject-with tcp-reset

This does the job of informing the server of a disconnection pretty fast. Spoofing a FIN packet using killcx takes a bit more time.

Delete the previous rule:
"
sudo iptables -D INPUT -p tcp --sport 6112 --tcp-flags PSH,ACK PSH,ACK -j REJECT --reject-with tcp-reset


You should allow these commands in /etc/sudoers, the following works for me since I put my user account in the "games" group:
"
%games ALL=(ALL) NOPASSWD: /sbin/iptables -I INPUT -p tcp --sport 6112 --tcp-flags PSH\,ACK PSH\,ACK -j REJECT --reject-with tcp-reset, /sbin/iptables -D INPUT -p tcp --sport 6112 --tcp-flags PSH\,ACK PSH\,ACK -j REJECT --reject-with tcp-reset

Another option would be to put this in a root access only script, and to sudo the script, but I opted to not do that because it would make another bash shell load before calling the iptables command.

The fastest way to close the connection would probably be to have the file descriptor for the socket on-hand, then force close the socket from a program already loaded into memory, but that would require a restart to PoE, because I don't think that will be very clean and the process wouldn't be able to use the socket anymore. Alt+F4 would be almost the same speed, except for cases where the system is busy and doesn't respond to your input.

EDIT: There seems to be a bug with iptables parsing, not with missing netfilter extensions, after some refinement, the fancy filter should work for everyone.
Last edited by ionface on Mar 19, 2016, 4:24:41 PM
Everything is running fine for me, both methods. Further feedback / testing welcome.
Here is how to do it now 20.04 ubuntu, just get the awakened trade macro appimage. None of what's posted above works, spent a few hrs, so don't try all that. Most of us in steam/proton now.

chmod a+x "appimage" in terminal the macro appimage you download for awakened trade, then right click and run it. you'll know when you see it's icon by steam that it's running. open poe. shift+space to open macro's options in game. Set /exit to a key you choose in settings. All I can find that works right now.
Last edited by 1337cshacker on Feb 9, 2023, 2:05:10 AM
Initial post is still valid with some updates and this is what I use:

Put in file .xbindkeysrc the following:

"xdotool key --clearmodifiers Return; xdotool type --clearmodifiers /remaining; xdotool key --clearmodifiers Return"
F5 + Release


Now with F5 key you get remaining mobs in map.

Also the logoff procedure with iptables, as already described, works flawlessly.
I'm using the iptables logout but it doesn't exit to character screen. Instead it just causes the screen to freeze and you can see that the connection is lost and the ms bar and number in top right is increasing.
I have to exit the game, but seems the macro is working instantly as intended.

Anyway is there anything I can do to make it exit to character selection screen?

I'm using the second method and executing it with sudo xbindkeys
Ok so I don't think this macro always works, not good enough for HC.
I used it to logout at full hp just to be safe vs a tanky souleater, but to my surprise my char was in standard after that. No way it would happen with normal /exit.

The problem is it doesn't switch you to login screen instantly, you are stuck on a disconnected in game screen. God knows how long your char sits there and still takes damage.

Report Forum Post

Report Account:

Report Type

Additional Info