Make Command Persistent

I have a Topton L4 umpc running current Manjaro. For some reason, its left mouse button needs the script:

#!/bin/sh
xkbset m

to activate itself. Fine, but even if the script is auto-started at boot, it still needs refreshing throughout the session. I have the script successfully keystroked, but wonder if there’s a way to make this command persistent.

Many thanks for any advice.

I don’t use xkbset, but I see some discussion elsewhere about using the exp option to stop a change expiring - have you looked at the exp option?

See here for instance, [SOLVED] How to keep mousekeys active for a long time? / Newbie Corner / Arch Linux Forums

where there is a suggestion of something like

xkbset exp mousekeys

and using

xkbset q exp to see what is the effect of this.

1 Like

Very much appreciate your help, thank you.

I’ve run your two commands and the effect is:

Upon Expiry Mouse-Keys will be: on

Which seems successful, but I still need to run

xkbset m

or the mouse buttons are seemingly disabled.

Right now, I’m running

xkbset m
xkbset exp mousekeys

and I’ll see if things remain more persistent.

Thanks again and will post back results.

1 Like

Ach. The combined commands did not result in persistence. An hour into the session, with successful left mouse button presence even after suspend and log-ins, the left button suddenly needed a rerun of the script.

Well, should all computer problems be so small since it’s easy to keystroke things in xfce.

With the disclaimer that I’m not running Xfce, I suspect that your problem would be caused by a misguided power savings setting, which puts the USB ports to sleep.

For a more permanent solution, it would be worth investigating that. I suspect that you might have the tlp package installed — I don’t know whether it still comes installed by default with the latest ISOs, but it definitely used to be back when I installed Manjaro — and if so, you may need to either tweak its settings or disable (and eventually uninstall) it altogether.

1 Like

Thank you for weighing in. I found this post https://askubuntu.com/questions/1376282/xkbset-setting-does-not-persist and am running

xkbset exp "=mousekeys"

as part of the script.

While TLP is installed, it didn’t appear to be running, but I took your advice and in /etc/tlp.conf, I uncommented the usb setting and set it to:

USB_AUTOSUSPEND=0

Testing now.

After tinkering with tlp setting, left mouse button capability disappeared almost immediately. Have now made tlp a manual start only and continue to test.

Progress. After repeated suspend and log-ins, the left mouse key remains persistent.

xkbset exp "=mousekeys"

This appears to be key, followed by exploring

xkbset q exp

to make certain that this is the mouse keys state:

Upon Expiry Mouse-Keys will be: Unchanged

Rather than “on” or “off”

A small oddity, the script of

xkbset exp "=mousekeys"
xkbset m

has to be run after attaining desktop or from terminal. Putting the script in autostart, no matter the amount of sleep delay, still produces

Upon Expiry Mouse-Keys will be: off

Any idea why such a simple script can be successfully run in terminal or from keystroke, but won’t work via auto-start?

You can try to make is a systemd service i guess.

1 Like

I never knew you could make your own services. I’ll look into it, thanks.

You can take this as example

https://forum.manjaro.org/t/utility-script-my-take-on-a-verified-boot/

Note that this installs and runs the service as root. You might want to install and run as your user.

systemctl edit --force --full my.service

Should do it. (No sudo)

1 Like

Thank you, @Teo. I struggled with building a service but would’ve wrestled it further had I not found a typo in the script that stopped a command. For the record, this appears to make the left mouse button persistent throughout a session (and it will auto-start):

#!/bin/sh
xkbset exp "=mousekeys"
xkbset m

Also for the record, big thanks to those who posted in the thread. Since this issue was minor, tlp experimenting and a switch in emphasis to service-making were most welcome, allowing me to ponder approaches I hadn’t considered.

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.