• Autostarting a .sh script.


    Hello everyone, I am a new linux user, and I came to Antergos because I really didn’t like Ubuntu, for some reason it was very buggy , slow and touchpad support was awful. Now that I am on Antergos I’m loving it, everything is so smooth and fast, love the Numix theme as well, my CPU fans on my laptop don’t even turn on !
    Anyways, the only thing that bothers me here is that for some reason a file called kbd_backlight in /sys/devices/platform/sony-laptop/ sets itself to -1 every time I boot my laptop and that disables my keyboard backlight. I managed to create a .sh script which fixes that for me but I find it bothersome to run it every time I turn my laptop on. Can anyone help me and teach me how to make that script run with my system automatically?
    (I already tried numerous methods, but I found them hard to understand so It’s not a surprise that I messed up somewhere in the process of doing it)
    Thanks in advance :)

  • The first link in the previous anwer refers to an appropriate method, but it makes use of cron. Yet, cron is not installed by default on Antergos.

    I am a new Antergos user myself, but I recently saw in the Arch wiki how they go about starting numlockx on startup: https://wiki.archlinux.org/index.php/Activating_Numlock_on_Bootup#Using_a_separate_service They appear to use a “native” way of autostarting applications at the system level, i.e., using systemd and system services, a system Antergos uses by default (just like Ubuntu).

    It actually does not appear to be so difficult. First (as root) save your script in an appropriate place (e.g. /user/bin) and make it executable. Then, creating the system service boils down to creating an appropriately formatted text file in /etc/systemd/system/. You could call it “turnonbacklight.sevice”.

    Then the example for numlock is like:

    [Unit]
    Description=numlock
    
    [Service]
    ExecStart=/usr/bin/numlock
    StandardInput=tty
    RemainAfterExit=yes
    
    [Install]
    WantedBy=multi-user.target
    

    Change the ExecStart entry to the full pathname of your script. Probably, you also need to change RemainAfterExit to “no”. With this, you should have created your first own service.

    Then enable the service with:

    sudo sysstemctl enable turnonbacklight
    

    Let us know if this works.

  • @antimony Wow, thanks ! It worked, I have no idea what I did wrong before but now it works. I’ll make a screenshot of this post for future reference :D
    Thanks guys, appreciate it.

  • @fpozar Hate to be that guy, but can you mark this as solved?

autostarting1 script2 Posts 5Views 185
Log in to reply