Background/Problem Statement:

I’ve recently returned to playing Foxhole, an MMO war game that involves lots of repetitive clicking, e.g., Shift+clicking ten times to gather supplies at mines, or clicking-and-holding for minutes at a time to construct buildings and vehicles. I’m looking for the easiest way to do on Linux what AutoHotkey does for Windows users.

Potential Solutions:

I’m using Bazzite Linux, Gnome, Wayland. I know how to set custom shortcuts in Gnome settings (Settings > Keyboard > Keyboard Shortcuts). The thing is I don’t want these custom shortcuts to be always active, so I’m considering writing a pair of executable scripts that would enable me to quickly & easily start listening for the macro shortcuts at the beginning of my gaming session and stop listening when I’m done gaming.

So my workflow would be as follows:

  1. At the beginning of my gaming session, I’ll double click the first script to initiate something like ydotoold. This script will also contain two or three lines of gsettings set commands to create custom keyboard shortcuts, which trigger ydotool commands to emulate mouse clicks. For Windows users, the AHK version of this would be simply double clicking to start the AHK script.
  2. At the end of my gaming session, since I don’t want to leave these custom shortcuts out there when I’m not playing, I will double click the second script, which stops ydotoold and removes the two or three custom keyboard shortcuts for the mouse clicking macros. This is where Windows users simply close AHK.

While I’m comfortable with the command line, this approach of managing Gnome settings through the command line would be new territory for me, and it will require a decent amount of trial and error. Before I proceed, I’d like to know if there’s a more straightforward way to achieve this.

Has anyone else accomplished something similar, and if so, would you be kind enough to share how you did it? Thanks!

EDIT: Adding links to some documentation I’ve found in my research so far. I haven’t set anything up yet, but I figure this might help others trying to do something similar.

  • Omega@discuss.online
    link
    fedilink
    English
    arrow-up
    3
    ·
    25 days ago

    Create a virtual mouse and use keyboard events tracked with python and add it as a service in systemd if you want to always keep it around

    I also use my own solution for this in order to add middle mouse scrolling on everything turned on and off with a keybind

    • yo_scottie_oh@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      25 days ago

      Thanks for the pointer to that Baeldung blog post. I’ve seen references to evdev and libevdev on previous adventures in configuring game pads and HOTAS setups for games that don’t support them natively. Also, fair point about python vs bash—I’ve edited the post to be language agnostic.

      • Chris@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        25 days ago

        If you have a keyboard running qmk or something you may be able to just write a macro for that. I’m not super familiar with it though

  • Overdraft@lemmy.ml
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    25 days ago

    I went on a journey to do something very similar, I remap keypad buttons to various other inputs using a python script running as a service. My original post is here, and my eventual solution is in the comments. My post has some links to other solutions that I tried, but ultimately I’m happy using a custom python script. That may not fit your need, but maybe it will help a little!

    • yo_scottie_oh@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      25 days ago

      I was going to ask if you’ve heard of AntiMicroX, then I saw in your other post that you’d already tried that. Thanks for the idea to use a Python script, I’ll have to look into that.

      • Overdraft@lemmy.ml
        link
        fedilink
        English
        arrow-up
        2
        ·
        25 days ago

        Happy to help! For me, python was the way to get everything I wanted, instead of almost what I needed. In my opinion, the python-evdev documentation is really helpful, and should be able to get you most of the way to what you need. For what it’s worth, based on my experience with AutoHotKey on Windows, you should be able to recreate anything you had before and more with python.

  • Lyra_Lycan@lemmy.blahaj.zone
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    1
    ·
    25 days ago

    What brand of preipherals do you have? Razer software (Synapse) can map Razer peripheral keys to anything you like, including macros. I’m willing to bet several other manufacturers have the same feature.