You are not logged in.

#1 2016-03-10 01:47:45

jesc516
Member
From: LI,NY
Registered: 2015-01-26
Posts: 72

Systemd user service loading without errors but script does not run

Hello everyone

I am trying to get xbindkeys to start when I login to my system but no luck. I created the directory ~/.config/systemd/user and created a service file as follows:

[Unit]
Description=Start xbindkeys service.

[Service]
ExecStart=/home/jesc/Documents/Bash/start_xbindkeys.sh

[Install]
WantedBy=default.target

my start_xbindkeys.sh file is as follows:

#!/usr/bin/env bash
xbindkeys

Im not getting any errors (to the best of my knowledge) from journalctl

Mar 09 20:35:43 jonny-arch systemd[556]: Started Start xbindkeys service..
Mar 09 20:36:24 jonny-arch systemd[556]: Stopped Start xbindkeys service..

No errors that I can see when showing the status of my service:

[jesc@arch system]$ systemctl --user status start_xbindkeys.service 
● start_xbindkeys.service - Start xbindkeys service.
   Loaded: loaded (/home/jesc/.config/systemd/user/start_xbindkeys.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Wed 2016-03-09 20:35:43 EST; 7min ago
  Process: 2885 ExecStart=/home/jesc/Documents/Bash/start_xbindkeys.sh (code=exited, status=0/SUCCESS)
 Main PID: 2885 (code=exited, status=0/SUCCESS)

Mar 09 20:35:43 jonny-arch systemd[556]: Started Start xbindkeys service..
Mar 09 20:36:24 jonny-arch systemd[556]: Stopped Start xbindkeys service..

I stopped the service to see if changing "ExecStart=/home/jesc/Documents/Bash/start_xbindkeys.sh" to "ExecStart=/home/jesc/Documents/Bash/./start_xbindkeys.sh" would do anything but it didnt. If i run the script manually it works.

Can someone please help me out?

Thanks

Offline

#2 2016-03-10 02:18:51

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,475

Re: Systemd user service loading without errors but script does not run

Simply add xbindkeys to your .xinitrc or startup file of your desktop environment. This will start xbindkeys as soon as you start your x-server  or DE. This way you can define different keys on different DEs

Offline

#3 2016-03-10 02:39:05

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: Systemd user service loading without errors but script does not run

xbindkeys has to be run from within an x session - that service file does not run it from within an x session.

Your script runs to completion which is probably why systemctl doesn report any errors.  But if you were to log the output of the xbindkeys command, you would see that it is failing.

Also there's not much point in running env to call bash to call xbindkeys when you could just run xbindkeys in the first place (although still not from this service file: either put xbindkeys in xinitrc or follow these instructions for the service file).


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Online

#4 2016-03-10 02:43:20

jesc516
Member
From: LI,NY
Registered: 2015-01-26
Posts: 72

Re: Systemd user service loading without errors but script does not run

Docbroke wrote:

Simply add xbindkeys to your .xinitrc or startup file of your desktop environment. This will start xbindkeys as soon as you start your x-server  or DE. This way you can define different keys on different DEs

added xbindkeys to .xinitrc but no cigar

# start some nice programs

if [ -d /etc/X11/xinit/xinitrc.d ]; then
    for f in /etc/X11/xinit/xinitrc.d/?*.sh; do
        [ -x "$f" ] && . "$f"
    done
    unset f
fi

twm &
xclock -geometry 50x50-1+1 &
xterm -geometry 80x50+494+51 &
xterm -geometry 80x20+494-0 &
xbindkeys
exec xterm -geometry 80x66+0+0 -name login

i also tried

exec xbindkeys

but nothing.

This is the .xinitrc file in my home directory btw (~/.xinitrc)

Offline

#5 2016-03-10 02:45:48

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: Systemd user service loading without errors but script does not run

You're obviously not using startx, so .xinitrc isn't going to do anything. Use your WM/DE setup.

Offline

#6 2016-03-10 03:10:31

jesc516
Member
From: LI,NY
Registered: 2015-01-26
Posts: 72

Re: Systemd user service loading without errors but script does not run

Scimmia wrote:

You're obviously not using startx, so .xinitrc isn't going to do anything. Use your WM/DE setup.

What am I doing wrong big_smile

i tried adding "xbindkeys" to the following files with reboots after each change.

~/.xinitrc
~/.config/xfce4/xinitrc
/etc/lxdm/lxdm.conf
/etc/lxdm/Xsession

I am using xfce4 with lxdm as my display manager.

I just want to start xbindkeys when I log in sad

Offline

#7 2016-03-10 03:15:18

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Systemd user service loading without errors but script does not run


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#8 2016-03-10 03:31:42

jesc516
Member
From: LI,NY
Registered: 2015-01-26
Posts: 72

Re: Systemd user service loading without errors but script does not run

Unfortunately that worked. I really wanted to get this done through systemd as Im trying to get myself familiar with it. I mean its just a simple command I want to initiate once I log in.

BTW; Startup applications created a file in ~/.config/autostart/xbindkeys.desktop

[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=xbindkeys
Comment=Start xbindkeys service.
Exec=xbindkeys
OnlyShowIn=XFCE;
StartupNotify=false
Terminal=false
Hidden=false

I really want to get this done with systemd. Ill play with it tomorrow again.

Offline

#9 2016-03-10 03:46:27

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,475

Re: Systemd user service loading without errors but script does not run

Please read the reply posted by Trilby again, in post 3, that is what you are looking for. Xbindkeys cannot start when x-server is not running, while systemd services start before x (unless you specify positively for service to start after x)

Offline

#10 2016-03-10 03:47:50

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: Systemd user service loading without errors but script does not run

jesc516 wrote:

Unfortunately that worked.

Yeah, don't you just hate when that happens.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Online

Board footer

Powered by FluxBB