How to launch an X program (clipit) when I login?

Hello,

I would like my clipboard manager - clipit to start as soon as I log in, where would be the best place to start it? Would that be .xinitrc?

Right now I have to manually start via the app launcher - rofi

:pray: i read wrong … think openbox

You can create a .desktop file containing the below information.

[Desktop Entry]
Version=1.0
Type=Application
Name=<Application Name>
GenericName=X compositor
Comment=A X compositor
Categories=Utility;
Keywords=<Set of key words>;
TryExec=<Command or progaram to run>
Exec=<Command or program to run> <-- This would fail if the above tryExec fails.

And place the file under ~/.config/autostart.

Or you can create a service file. You can use the below template.

[Unit]
Description=Hello world
After=sysinit.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=no
RemainAfterExit=yes
User=root
ExecStart=/bin/echo hello world
ExecStop=/bin/echo goodby world

[Install]
WantedBy=multi-user.target

[Unit]
Description = ~Name of the service~

[Service]
WorkingDirectory= ~directory of working file~
ExecStart= ~directory~/filename.sh

[Install]
WantedBy=multi-user.target

Save the file Save it as /etc/systemd/system/<file name>.service

After saving the file run the below command.

$ sudo systemctl enable --now <service name>

Then check the status of the service with the below command.

$ sudo systemctl status <service name>
2 Likes

Thank you! I will go with the .desktop file. It looks simpler to me :slight_smile:

Here is my picom file that I use to launch my compositor.

[Desktop Entry]
Version=1.0
Type=Application
Name=picom
GenericName=X compositor
Comment=A X compositor
Categories=Utility;
Keywords=compositor;composite manager;window effects;transparency;opacity;
#Command to match
#Use bash -c "<command you want to execute>" to run bash commands
TryExec=picom
#Command to execute above and this has to mathc.
#Use bash -c "<command you want to execute>" to run bash commands
Exec=picom
1 Like

Nice! Thanks for the example! I thought it would be more difficult to achieve this but creating a simple .desktop file is very straightforward :stuck_out_tongue:

Qtile does not respect autostarts.

from libqtile import hook
import subprocess
import os

@hook.subscribe.startup_once
def autostart():
    home = os.path.expanduser('~/.config/qtile/autostart.sh')
    subprocess.call([home])

@hook.subscribe.client_new
def client_new(client):
    if client.name == 'pcmanfm':
        client.togroup('4')
    if client.name == 'dolphin':
        client.togroup('4')    
    if client.name == 'emacs':
        client.togroup('5')
    if client.name == 'Rhythmbox':
        client.togroup('9')

Look in ~/.config/modules/hooks.py note the section about autostart.sh above.

1 Like

If Qutile comes with dex then he can use .desktop file.

Then he needs to do the above and just put dex in the script, but it will load a lot of unnecessary stuff if he has another DE installed.

He can use --environment qutile I think it’s new to dex.

Explain please?

dex has an option as I mentioned that works with the assigned environment only. We use it with our i3 online edition which seems to be working.

How do you launch dex?

dex --autostart --environment i3
dex --autostart --environment qtile
2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.