[invalid] Run systemd service after specific device is initialized

Hi.
Is there any way to run systemd service only after specific device is initialized/kernel module is loaded?
The task I'm trying to solve is applying trackpoint speed and sensitivity settings on boot in my X220.
Service code (trackpoint.service) is quite simple
[Unit]
Description=Trackpoint configuration
[Service]
Type=oneshot
EnvironmentFile=/etc/conf.d/trackpoint.conf
ExecStart=/bin/sh -c 'echo ${sensitivity} > /sys/devices/platform/i8042/serio1/serio2/sensitivity'
ExecStart=/bin/sh -c 'echo ${speed} > /sys/devices/platform/i8042/serio1/serio2/speed'
[Install]
WantedBy=graphical.target
The issue is that trackpoint.service gets executed before trackpoint device gets initialized and thus fails.
Jun 14 23:12:10 xi sh[414]: /bin/sh: /sys/devices/platform/i8042/serio1/serio2/sensitivity: No such file or directory
Jun 14 23:12:10 xi systemd[1]: Unit trackpoint.service entered failed state.
Jun 14 23:12:18 xi kernel: psmouse serio2: trackpoint: IBM TrackPoint firmware: 0x0e, buttons: 3/3
Jun 14 23:12:18 xi kernel: input: TPPS/2 IBM TrackPoint as /devices/platform/i8042/serio1/serio2/input/input13
What have I tried already
1. Specified systemd-modules-load in After= and Requires= directives and added psmouse module to /etc/modules-load.d
2. Tried path activation (perhaps, I did it wrong) by creating i8042.path
[Path]
PathExists=/sys/devices/platform/i8042
Unit=trackpoint.service
However, this changed nothing.
I don't know what else should I try.
Please suggest solution for this.
Thanks in advance.
Last edited by eDio (2013-06-15 13:28:36)

Thank you very much.
I've finally managed this to work
$ cat /etc/udev/rules.d/10-trackpoint.rules
SUBSYSTEM=="input", KERNEL=="event13", ACTION=="add", RUN+="/usr/bin/trackpoint_apply"
$ cat /etc/conf.d/trackpoint.conf
speed=255
sensitivity=255
$ cat /usr/bin/trackpoint_apply
#!/usr/bin/env sh
. /etc/conf.d/trackpoint.conf
/usr/bin/echo $speed > /sys/devices/platform/i8042/serio1/serio2/sensitivity
/usr/bin/echo $sensitivity > /sys/devices/platform/i8042/serio1/serio2/speed

Similar Messages

  • Restart Systemd service after laptop resume

    Hi!
    After resume my laptop (from suspend, I've no tried hibernation) I need to restart NetworkManager service. How can I do this automaticaly?, I've searched in google and Systemd documentation but I have not a clear idea about how to do it.
    thanks

    Gazpacho wrote:
    lucke wrote:As boast said, you can make pm-utils run "systemctl restart networkmanager.service" after resume for you. https://wiki.archlinux.org/index.php/Pm … _own_hooks
    Sorry (to boast too), you are right. I've read the wiki and created a hook, now NM restarts after resume. Thanks!
    And now I've discovered that my computer only suspends the first time. Second time nothing happens when I close the tap, execute pm-suspend or the KDE menu option suspend to ram
    If you have any idea it is welcome. If not I will mark the thread as solved in a couple of days and search in forums and wiki.
    this usually happens when your hook doesn't exit. pm-suspend never finishes because it's waiting for the hook to exit and the second pm-suspend will block until the other pm-suspend is finished. Please post your hook.

  • [SOLVED] Running Systemd service on login (encrypted home partition)

    Hi,
    I have a dm-crypt/LUKS encrypted home partition that's mounted via PAM on login. I'm trying to use a systemd service (profile-sync-daemon), but the service tries to start and access the home partition before the partition is mounted. The service does seem to start successfully, but it doesn't gain access to necessary files on the home partition and malfunctions later on. Is there a sane hack to somehow delay the start of the service until the relevant partition gets mounted (basically after login)? Manually starting the service after login works just as intended in this case - I'm just looking for a way to automate this process.
    I have an idea of starting the service via Openbox autostart, but I've currently failed in my attempts.
    Last edited by ggg377 (2015-05-28 18:31:10)

    Things got quite complicated and hacky as I researched this so I went out of the box a bit (or took the easy way out, whichever you prefer) and reinstalled Arch with a full disk encryption. All is fine now and I also expect to see less problems overall in the future. If anyone wants to continue researching this it would probably be a good idea to start a new thread.

  • Server failing to run multiple services after Windows Update ran last night.

    SBS 2011 Server was restarted to complete installation of 8 critical security updates last night. A number of services all dependent on RPC Service will not run today. I uninstalled all the updates and restarted Server but still have the same problem.
    This is a real estate law office and they have no printers or E-mail today.  RPC Service reports as started but all services that depend on it fail to start.  I've attempted to troubleshoot the problem but I am not getting
    anywhere.  Any suggestions on best way to resolve the problem? 

    Hi,
    What is the status of RPCSs Service , is it started , Automatic and running on NT AUTHORITY\NetworkService ?
    Find Default SBS 2011 Services status here:
    http://blogs.technet.com/b/sbs/archive/2011/07/13/default-services-and-their-status-in-sbs-2011.aspx
    Open Registry HKLM\System\CCS\Services\RPCss , could you please share the DependOnService values ?
    Make sure there is only NIC card enabled on the server with DNS pointing to itself.
    Disconnect the Network Cable and reboot the server once.
    Do an MSCONFIG , clean boot the server , including Exchange Services.
    Try to boot the server in Safe Mode also try Last known Good configuration, just for troubleshooting.
    We might have to try changing the Logon As in service for RPCss to Local System as a test. (BUT THAT WOULD BE LATER)
    Binu Kumar - MCP, MCITP, MCTS , MBA - IT , Director Aarbin Technology Pvt Ltd - Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Firefox.exe *32 continues to run in services after closing firefox

    i am running win 7 professional, and firefox 6.0.2

    See "Hang at exit":
    *http://kb.mozillazine.org/Firefox_hangs
    *https://support.mozilla.com/kb/Firefox+hangs

  • Systemd: starting service after graphical target without

    Hi there,
    I have a service that I want to start after X has been started.
    This is my service file:
    [Unit]
    Description=Run powersaving script depending on AC state
    After=graphical.target
    [Service]
    Type=oneshot
    KillMode=none
    ExecStart=/usr/bin/powersaving
    [Install]
    WantedBy=multi-user.target
    However, during boot I get the following error message:
    ~ systemctl status powersaving
    ● powersaving.service - Run powersaving script depending on AC state
    Loaded: loaded (/usr/lib/systemd/system/powersaving.service; enabled)
    Active: inactive (dead)
    Apr 07 07:16:14 thinkpad systemd[1]: Found ordering cycle on powersaving.service/start
    Apr 07 07:16:14 thinkpad systemd[1]: Found dependency on graphical.target/start
    Apr 07 07:16:14 thinkpad systemd[1]: Found dependency on multi-user.target/start
    Apr 07 07:16:14 thinkpad systemd[1]: Found dependency on powersaving.service/start
    Apr 07 07:16:17 thinkpad systemd[1]: Found ordering cycle on powersaving.service/start
    Apr 07 07:16:17 thinkpad systemd[1]: Found dependency on graphical.target/start
    Apr 07 07:16:17 thinkpad systemd[1]: Found dependency on multi-user.target/start
    Apr 07 07:16:17 thinkpad systemd[1]: Found dependency on powersaving.service/start
    ~ dmesg | grep powersaving
    [ 7.492597] systemd[1]: Found dependency on powersaving.service/start
    [ 7.492604] systemd[1]: Breaking ordering cycle by deleting job powersaving.service/start
    [ 7.492608] systemd[1]: Job powersaving.service/start deleted to break ordering cycle starting with graphical.target/start
    I found this thread which suggests to use display-manager.service instead of the graphical target.
    However, I start X manually using startx and no display-manager.
    So how can I run my service after starting of X without a display-manager?
    Thanks!

    I don't think your new version will work. Your new version will make your service part of multi-user.target and started after multi-user.target; so you are asking systemd to start your service after itself. In any case such attempts will start the service before startx. startx is a command that you run as an ordinary user, X has the special privilege to get root access (it has the suid bit set) and systemd is not involved in the process. I do not think that you can tell systemd to start a service after a command that you launch by hand; and I don' think it's the purpose of systemd. You are really asking to launch a daemon that needs root access as part of a command that you run as an ordinary user. One of the solution is to use sudo and put sudo /usr/bin/powersaving into ~/.xinitrc after having properly configured sudo.
    Last edited by olive (2014-04-07 08:34:32)

  • Systemd service to run command before stopping connman.service?

    [This is my first time creating a thread, I apoligize if there is a more suitable category]
    Hello,
    I would like to run a command at shutdown before stopping a specific service (connman). I need the command to finish before stopping connman as well.
    Is there a good way to do this? I tried searching, but it seems systemd is a bit finnicky when it comes to shutdowns.
    I'd like to achieve this without modifying connman.service (Though this would probably work for me)
    What is the best way to do this?
    Thanks,
    Jacob
    Last edited by frash23 (2014-12-21 13:59:03)

    Hi
    I'm not sure if it would work, but from logic, creating a service file for your command with an "After=" dependency to connman might do it. Assuming that systemd passes the dependencies in reverse order when shutting down...
    Plus use "ExecStop=" to make your command execute at stopping.
    You gotta try this out.
    Regards
    Edit: To test/debug you can probably simply stop connman and see if it pulls the dep (instead of shutting down completely).
    Edit2: Maybe better better use "ExecStop=" inside the connman service files. As you mentioned you copy the original service file from /usr/lib/systemd/system to /etc/systemd/system and make your modifications there. This is the correct way to modify service files.
    Or then do it with a "config" directory, analog to how it's done here: https://wiki.archlinux.org/index.php/au … al_console
    Reference 'man systemd.service':
    ExecStop=
    Commands to execute to stop the service started via ExecStart=. This argument takes
    multiple command lines, following the same scheme as described for ExecStart= above. Use of
    this setting is optional. After the commands configured in this option are run, all
    processes remaining for a service are terminated according to the KillMode= setting (see
    systemd.kill(5)). If this option is not specified, the process is terminated immediately
    when service stop is requested. Specifier and environment variable substitution is
    supported (including $MAINPID, see above).
    Evtl. make sure your links in the .wants directory reference to the correct service file. (Disable and reenable once.)
    Last edited by rebootl (2014-12-21 16:51:18)

  • Run custom systemd service before NetworkManager

    Hi, I am trying to write a systemd service that runs and completes before NetworkManager.service starts.
    I tried this:
    [Unit]
    Description=Custom service test
    Before=NetworkManager.service
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/echo Custom service test 1
    ExecStart=/usr/bin/sleep 5
    ExecStart=/usr/bin/echo Custom service test 2
    [Install]
    WantedBy=network.target
    While the custom service does start, I got this rather strange output:
    Jan 22 00:12:46 localhost echo[1166]: Custom service test 1
    Jan 22 00:12:48 localhost kernel: NVRM: GPU at 0000:02:00: GPU-(snip)
    ... some unrelated messages (acpid, kdm, etc) ...
    Jan 22 00:12:49 localhost systemd-logind[1170]: Linked /tmp/.X11-unix/X0 to /run/user/1000/X11-display.
    Jan 22 00:13:13 localhost echo[1254]: Custom service test 2
    Jan 22 00:12:50 localhost systemd[1]: Started Custom service test.
    Jan 22 00:12:50 localhost systemd[1]: Starting Network Manager...
    As you can see, while everything appears in the expected order in the log, the timestamps look very wrong. The "Custom service test 2" says "00:13:13", yet it is in the middle of "00:12:49" and "00:12:50". What gives?
    Also, notice that the first echo was at 00:12:46, but NetworkManager started at 00:12:50, which is only 4 seconds later. The "sleep" in the custom services should have made it start at 00:12:51 at the earliest. I don't understand why things are not being respected.
    The output I'd expect to see is something like this:
    Jan 22 00:12:46 localhost echo[1166]: Custom service test 1
    Jan 22 00:12:51 localhost echo[1254]: Custom service test 2
    Jan 22 00:12:51 localhost systemd[1]: Started Custom service test.
    Jan 22 00:12:51 localhost systemd[1]: Starting Network Manager...
    I have also made sure that it shows up in NetworkManager.service's After list:
    $ systemctl show -p After NetworkManager.service
    After=mycustomservice.service syslog.target systemd-journald.socket dbus.socket basic.target

    falconindy wrote:Sooooo this begs the question: what are you really trying to do?
    I'm trying to write a script that changes the interface's MAC address before NetworkManager gets a chance to take over the network interface. I'm aware that there's a page about exactly that on the wiki. I started with the systemd service from the bottom of the page, which says "Before=dhcpcd@%i.service". I changed that line to use "NetworkManager.service", and I changed the ExecStart line to "/usr/bin/macchanger -A myinterface" in order to get a random MAC address, instead of setting a fixed one like the example shows. Then I saw that macchanger's output was being mixed with NetworkManager's output in the journal, so I decided to try and write a custom service just for testing, making it start before NetworkManager, in order to see if it really was systemd's fault or if it was something macchanger-specific. Then I noticed the strange behavior described in the OP, didn't really know what to do about it, so I posted this topic. That's the story so far...
    Last edited by WindPower (2013-01-23 00:13:22)

  • Running Multiple LIRC/[Other App] Instances in systemd Service

    I'm trying to run multiple LIRC instances (one for each device) as a systemd service. This is what my service file looks like:
    [Unit]
    Description=LIRC Daemon
    After=network.target
    [Service]
    Type=oneshot
    EnvironmentFile=/etc/sysconfig/lirc
    ExecStartPre=/bin/mkdir -p /run/lirc
    ExecStartPre=/bin/rm -f /dev/lircd /dev/lircd1
    ExecStartPre=/bin/rm -f /run/lirc/lircd /run/lirc/lircd1
    ExecStartPre=/bin/ln -s /run/lirc/lircd /dev/lircd
    ExecStartPre=/bin/ln -s /run/lirc/lircd1 /dev/lircd1
    ExecStart=/usr/sbin/lircd --device=/dev/input/event12 --output=/run/lirc/lircd1 --pidfile=/run/lirc/lircd1.pid --driver=devinput --listen=8765 /etc/lirc/lircd.conf
    ExecStart=/usr/sbin/lircd --device=/dev/input/event10 --output=/run/lirc/lircd --pidfile=/run/lirc/lircd.pid --driver=devinput --connect=localhost:8765 /etc/lirc/lircd.conf
    ExecStopPost=/bin/rm -f /dev/lircd /dev/lircd1
    ExecStopPost=/bin/rm -fR /run/lirc
    [Install]
    WantedBy=multi-user.target
    I'm having some trouble with it as the service runs the first time but not properly. Restarting the service results in an Permissions error. I'm presuming because the socket is till running despite having manually deleted all LIRC sockets.
    At the moment I'm thinking this is because service file excludes a PID assignment like:
    PIDFile=/run/lirc/lircd.pid
    Yet the two instances have their own PID assignments. What should I be putting or what's a better way to run two instances of LIRC as a service?
    Last edited by archbawks (2013-04-13 16:58:59)

    Anyone?

  • Im trying to install iTunes on my friend's Dell XPS, running windows vista ultimate (32-bit), but whenever I reach the end of the install, it pops up with an error telling me:   "Service 'Apple Mobile Device' (Apple Mobile Device) could not be instal

    Trying to install iTunes on my Laptop, running windows 7 (64-bit), but whenever I reach the end of the install, it pops up with an error telling me:
    "Service 'Apple Mobile Device' (Apple Mobile Device) could not be installed. Verify that you have sufficient privileges to install system services"

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies.
    The further information area has direct links to the current and recent builds in case you have problems downloading, need to revert to an older version or want to try the iTunes for Windows (64-bit - for older video cards) release as a workaround for performance issues or compatibility with third party software.
    Your library should be unaffected by these steps but there is backup and recovery advice elsewhere in the user tip.
    tt2

  • [SOLVED] A custom systemd service doesn't execute a specific command

    I have made a custom service which should set screen brightness.
    file: /etc/systemd/system/backlight100.service
    [Unit]
    Description=Set screen brightness
    [Service]
    Type=oneshot
    ExecStart=/bin/echo 100 > /sys/class/backlight/intel_backlight/brightness
    ExecStart=/usr/bin/beep
    [Install]
    WantedBy=multi-user.target
    (beep is there so I can know for sure that the script runs)
    The problem is, when I run "# systemctl start backlight100.service" I can hear the beep but it doesn't change the brightness. When I run "/bin/echo 100 > /sys/class/backlight/intel_backlight/brightness" in terminal it does change the brightness... but not when I start or restart the service.
    Here's the output of systemctl status backlight100.service after starting it
    backlight100.service - Set screen brightness
    Loaded: loaded (/etc/systemd/system/backlight100.service; enabled)
    Active: inactive (dead) since Fri 2013-04-05 20:17:32 AMT; 3min 19s ago
    Process: 27698 ExecStart=/usr/bin/beep (code=exited, status=0/SUCCESS)
    Process: 27696 ExecStart=/bin/echo 100 > /sys/class/backlight/intel_backlight/brightness (code=exited, status=0/SUCCESS)
    Apr 05 20:17:32 work systemd[1]: Starting Set screen brightness...
    Apr 05 20:17:32 work echo[27696]: 100 > /sys/class/backlight/intel_back...ss
    Apr 05 20:17:32 work systemd[1]: Started Set screen brightness.
    What am I doing wrong here? Any help appreciated.
    Last edited by axper (2013-04-05 18:35:24)

    msthev wrote:$ man systemd.service
    ExecStart=
    Note that this setting does not directly support shell command
    lines. If shell command lines are to be used they need to be passed
    explicitly to a shell implementation of some kind. Example:
    ExecStart=/bin/sh -c 'dmesg | tac'
    Thanks, changing ExecStart line to
    ExecStart=/bin/bash -c '/bin/echo 100 > /sys/class/backlight/intel_backlight/brightness'
    solved the issue. Though I can recall seeing ExecStart lines with direct shell commands.
    Raynman wrote:
    You should look at tmpfiles.d.
    https://wiki.archlinux.org/index.php/Sy … rary_files
    I'll do that, thanks!

  • HT1926 reinstalled itunes after unistalling it due to error message during update. after it was completly unistalled still has the same error message: service "apple mobile device" (apple mobile device) failed to start, verify you have sufficient priviled

    I was prompted to update itunes this evening. I did and in the process, it came up with the following error message: Service "apple mobile device" (apple mobile device) failed to start. Verify you have sufficient priviledges to start system services. I unistalled itunes completly and reinstalled but am still getting the same error message. If I click "ignore" the program will finish downloading but will not launch due to "not being installed correctly". Please help, I use this program alot with my first grade classroom and they're expecting their listening center in the morning.

    Hey I finally got an older vesion of itunes to work!!! 10.7  x64 for windows 7
    After uninstalling all apple products even  quicktime
    I had to delete everything from (program files, and program  files x64, program data,)
    And all downloads from apple, and I went in to search deleted  other stuff from apple, and itunes
    But definently not my itunes library and Playlist
    Down loaded 10.7 x64 for windows 7, but checked (do not start  when done)
    Then I emptied my recycling bin and restarted my  PC
    I ran geek tech tool box same as reg cure pro, also PC Tools  registry cleaner, and CC Cleaner
    Then I emptied my recycling bin and restarted my  PC
    And wallah... It finally works, and I Love the older version  anyways.
    Easier to download and transfer  music!!!!!

  • While installing the latest iTunes version I get the following msg:"Service Apple Mobile Device failed to start.Verify that you have sufficient privileges to start system services. I already tried it from the installer Running it as Administrator

    While installing the latest iTunes version I get the following msg:"Service Apple Mobile Device failed to start.Verify that you have sufficient privileges to start system services. I already tried it from the installer Running it as Administrator and still get the same message.  I click "ignore" and finish the installation but when I try to open it I get this "Runtime Error! R6034 An application has made an attempt to load the C runtime library incorrectly."  I already uninstalled iTunes and all other applications involved and re-installed itunes from the itunes site and the problem persists. Please help!

    Solving MSVCR80 issue and Windows iTunes install issues.

  • I just bought my IPhone and am also getting the the Service Apple Mobile Device failed to start. Verify that you have sufficient privileges to start system services.  This is after following the uninstall/reinstall instruction.  This needs to be fixed!!!

    I just bought my IPhone and am also getting the the Service Apple Mobile Device failed to start. Verify that you have sufficient privileges to start system services.  This is after following the uninstall/reinstall instruction.  I am due to travel in 2 days and am very upset about this. This needs to be fixed!!!

    http://support.apple.com/kb/TS1567
    Log in to the Windows with "administrative rights".

  • I tray to reinstall i tunes in my pc after having error 7, but wyle in the instalation this mesage appear said service apple mobile device failed to star. verefy that you have suficient privileges to star system services.

    i tray to reinstall i tunes in my pc after having error 7, but wyle in the instalation this mesage appear said service apple mobile device failed to star. verefy that you have suficient privileges to star system services.

    Let's try a standalone Apple Mobile Device Support install. It still might not install, but fingers crossed any error messages will give us a better idea of the underlying cause of why it's not installing under normal conditions.
    Download and save a copy of the iTunesSetup.exe (or iTunes64setup.exe) installer file to your hard drive:
    http://www.apple.com/itunes/download/
    Download and install the free trial version of WinRAR:
    http://www.rarlab.com/
    Right-click the iTunesSetup.exe (or iTunes64Setup.exe), and select "Extract to iTunesSetup" (or "Extract to iTunes64Setup"). WinRAR will expand the contents of the file into a folder called "iTunesSetup" (or "iTunes64Setup").
    Go into the folder and doubleclick the AppleMobileDeviceSupport.msi to do a standalone AMDS install.
    (If it offers you the choice to remove or repair, choose "Remove", and if the uninstall goes through successfully, see if you can reinstall by doubleclicking the AppleMobileDeviceSupport.msi again.)
    Does it install (or uninstall and then reinstall) properly for you? If so, does an iTunes install go through properly now?
    If instead you get an error message during the install (or uninstall), let us know what it says. (Precise text, please.)

Maybe you are looking for

  • Making link open new tab/window?

    I am fairly new to dreamweaver (just started website construction this year, only go to it every other day) and in that time I believe I have already learned quite a bit. I already know how to use spry efficiently which I believe nobody else in the c

  • Hover state to work in IE8

    I cannot get the hover state to work on <p> I have assigned a hover state to the paragraph tag. It works fine in FireFox but I can not get the hover state to work in Internet Explorer 8. The reason that I gave it a hover state is because it is linked

  • Automatic statrup & shutdown

    below are the stapes to startup and shutdown oracle 9i database ... but what if i have multiple oracle home and i want to do startup and shutdown automatic for both oracle 9i and 10g databases...? =====================================================

  • Compressor doesn't open

    Hallo! I can't open the Compressor. Last week I installed Mavericks - could this be the reason? I tried to install it again, but my Mac doesn't open the zip-file too because I should buy a programm for that... I always thought it should work without.

  • Is photoshop cs4 the reason my vaio laptop constantly crashes?

    Hi, i have read through lots of forums about the Open GL 2.0 and Shader model 3.0 being necessary in order to run CS4 photoshop.  I have the Adobe Web premium Cs4 package but i have never run anything but photoshop on my Sony vaio laptop,  I see that