Modulejail questions - Realtime notification

I’ve got some (maybe dumb) questions about this realtime notification script posted by @Teo

You can add the following to your startup scripts (do not forget to make executable):

I’m not that familiar with the term ‘startup scripts’. Do you mean something like a systemd service like I’ve read in the forum?

…
# optional - initial sleep so that a bunch of blocked modules at boot are not showed
sleep 37
…

Why the 37 seconds? Is it some random value or is this tailored to your specific system and I have to figure out the correct timing for mine?

journalctl -f -t modulejail --since "1 sec ago" -o cat | while read -r LINE; do

I guess this script is running all the time but will it generate a lot of load? I get that it’s checking the journal in realtime for the ‘modulejail’ topic but how often? Every second like the --since "1 sec ago" implies or when a new line is added to the journal? Will it stop my system from reaching standby because of the while-do loop?

The last one’s may be the dumb questions because I don’t know how this works in the OS. Compared to all the other processes taking place at all time, is this one just like throwing a pebble into the sea or will it mess with the systems power management/cause higher power usage because the system doesn’t reach deeper c-states?

RedHat documentation - Setting up startup applications in GNOME

Yes

Probably not, but this can be checked in a task manager

No

1 Like

The questions are not dumb.

About startup: yes, you can create a user systemd service with a timer. It is actually the more professional way. But i was too lazy to make a systemd units, and i use xfce and there we have “session and startup settings” and one can add his own script to be executed on startup so i just used this. Pretty sure kde and gnome have similar settings, making service is of course the best.

About the sleep - it is kind of optional. I needed a delay, because at startup some driver trys to load a fujitsu module on my lenovo which is pretty common. And when it fails it tries again. 10-15 times. So i either have to allow this module in the whitelist (and i don’t want to) or every boot i will be greeted with a wall of popups.
The solution is to ignore notifications the first 30 seconds or minute after boot. That is also why the journal starts 1 second before (after) those pretty random 37 seconds.
Obviously, it is your decision if you want this. But if you have something that tries to automatically load on startup and you do not whitelist it, you will be spammed with popup about it.
If you decide to go the systemd timer way, you do not need delay (but you can insert one), you need a target. I still have to test how it goes. Systemd actually silently adds random delays to timers, so there are no collisions. But i went the primitive way without timer and had to make something myself. And since i have several such scripts at startup i chose a kind of random value of about a (half a) minute delay.

The beauty of the script is, in this form it uses pretty much zero cpu. Because the control is in systemd. It only actually does something if the log if filled with a new line. In my many tests i could not move it from 0.01 cpu usage.

Honestly i have not tested the standby, but since i have many similar things running, i can’t imagine a bash loop will prevent sleep. All my other scripts don’t.
p.s. standby tested, no issues with blanking on inactivity.

2 Likes

Thanks guys for all your work on this. I see the progress in the Wiki post. I’ve installed ModuleJail now. Turns out my system is also running the ‘FJES’ module even though I don’t have any Fujitsu network devices that I know of. I’ve whitelisted the module for now.

I’ve also decided to hold back on the notification script since checking journalctl manually should suffice for my workload for now.

Since the author of Modulejail is already working on the systemd integration with BETA 1.5.0, he’s may be also coming up with a systemd unit solution for the notification as well. :crossed_fingers:

EDIT:

Nevertheless thank you @Teo for the details on your bash script. Helped me understand what is going on exactly to make my decision.

I’ve checked the link and didn’t quite get how to run Teo’s Modulejail notification script with this one. It only lets you setup startup applications already installed on the system to be chosen from a dropdown. I didn’t see any input field where I could provide a bash script in the GNOME Tweaks app. I would be able to autostart a ‘Terminal’ session with this one but still can’t figure out how to then let it run a bash script.

Here is a sample systemd service:
make the service as ~/.local/share/systemd/user/modulejailpopup.service

[Unit]
Description=modulejailpopup
Wants=network-online.target graphical-session.target
After=network-online.target graphical-session.target

[Service]
Type=simple
ExecStart=/bin/bash -c "/home/$USER/.local/bin/modulejailpopup.sh"

modulejailpopup.sh is where you saved the notification script and made it executable.

After that:

systemctl --user start modulejailpopup.service
systemctl --user enable modulejailpopup.service

Wouldn’t it be useful if the popup would offer an “Add to whitelist?” option?

1 Like

That is in the todo list since the beginning and i already suggested it to the modulejail author. But for both of us it is a matter of a future version.
On my side it needs some more research. For example the action doesn’t always work on xfce. There might also be differences between kde/gnome/xfce, and finally there is the matter of polkit integration because this needs root.
It will require some days work and i do not have the time at the moment.

1 Like

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