Last Updated: February 25, 2016
·
1.56K
· w0ng

~/.xinitrc: start apps only if not already running

Local (per user) startup apps are added to ~/.xinitrc.

There may be times when you want to restart X but not restart apps that are already running.

To do so, check if there's any active processes of the app and only start the app if there isn't any.

# start apps in background if not already running
[[ -z "$(pidof mpd)" ]] && mpd
[[ -z "$(pidof tmux)" ]] && tmux &
[[ -z "$(pidof urxvtd)" ]] && urxvtd -q -o -f

Source: https://bbs.archlinux.org/viewtopic.php?pid=1057419#p1057419

2 Responses
Add your response

@jasonwryan Lol sorry. Forgot where I originally saw this. Link added.

over 1 year ago ·