View Single Post
Old 10-27-2021, 04:59 AM   #2
frostschutz
Linux User
frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.
 
frostschutz's Avatar
 
Posts: 2,227
Karma: 5607928
Join Date: Sep 2010
Location: Heidelberg, Germany
Device: Libra 2 (2021), Aura H2O (2014), Story HD (2011)
you can run it with an udev rule, but udev might trigger it multiple times (so you need some locking mechanism) and there's also a case where long running scripts are terminated, so the scripts might need to daemonize itself too.

so almost all my mods do it this way... trigger by udev, setsid, lock.

also your script may already run before kobo finished booting so the user partition maynot be mounted yet, so you have to wait for that too.

example

/etc/udev/rules.d/miniclock.rules
Code:
KERNEL=="loop0", ACTION=="add", RUN+="/usr/local/MiniClock/miniclock.sh"
/usr/local/MiniClock/miniclock.sh
Code:
#!/bin/sh

# udev kills slow scripts
udev_workarounds() {
    if [ "$SETSID" != "1" ]
    then
        SETSID=1 setsid "$0" "$@" &
        exit
    fi

    # udev might call twice
    mkdir /tmp/MiniClock || exit
}

# nickel stuff
wait_for_nickel() {
    while ! pidof nickel || ! grep /mnt/onboard /proc/mounts
    do
      	sleep 5
    done
}

udev_workarounds
wait_for_nickel

# do your stuff past this point
there may be better or different methods, I don't know, this approach has worked well for me so far

using udev rules is nice since you can just add those files. there's no need to modify existing files. you can tamper the Kobo's rc scripts too but if there are two different mods that want to do that, they might be in conflict with one another, and the risk of breaking the boot process is higher

Last edited by frostschutz; 10-27-2021 at 05:02 AM.
frostschutz is online now   Reply With Quote