1

I thought this would be simple, but I have this issue where SXHKD bindings won't work after boot until a bash xfce4-terminal has been opened once. So I tried opening a terminal on boot via rc.local, which is no good because it doesn't open with the ~/.config settings. So I created a launcher put in /etc/xdg/autostart with Exec= /Usr/bin/xfce4-terminal -e 'bash -c "sleep 1"' Or bash -c '/usr/bin/xfce4-terminal' And dozens of other things, with the intent of momentarily opening bash, but nothing seems to work. For example I can't run the launcher from rc.local, either.

0

1 Answer 1

1

Rather than autostart the terminal why not autostart SXHKD.

Create this file ~/.config/autostart/sxhkd.desktop

It should contain:

[Desktop Entry]
Name=sxhkd
Comment=Simple X hotkey daemon
Exec=/usr/bin/sxhkd
Terminal=false
Type=Application

Here's a worked example, where I tried the following on an Xfce installation I have in a VM.

  1. I used Settings > Session and Startup > Application Autostart.

  2. I added a new task with the command xfce4-terminal -e 'bash -c "sleep 5"'

  3. This added a file to ~/.config/autostart/ (not /etc/xdg/autostart)

  4. The contents were:

    [Desktop Entry]  
    Encoding=UTF-8  
    Version=0.9.4  
    Type=Application
    Name=Terminal
    Comment=Terminal test
    Exec=xfce4-terminal -e 'bash -c "sleep 5"'
    OnlyShowIn=XFCE;
    RunHook=0
    StartupNotify=false
    Terminal=false
    Hidden=false

This worked perfectly, terminal appeared, hung around for 5 seconds, then closed.

When you launch the terminal with a command to execute, it does just that, executes the command. While it’s executing the command it’s not available for subsequent commands to be entered, hence no user@user prompt. Most commands are so quick you don’t notice this. In your case the sleep command makes it far more noticeable.

If you open a terminal normally and type something like firefox then Firefox should open. Leaving firefox open if you go back to the terminal you will see no user@user prompt waiting for you but you will still see the previous prompt and firefox command on the screen. You may also see a few error or warning messages. The Firefox command is running in the terminal so the terminal is busy with no user prompt waiting for input. If you then close the Firefox window the user@user prompt will be available in the terminal again.

You can get a terminal to open when you login with a user@user prompt ready by using just xfce4-terminal as your command in the auto launcher.

3
  • I thank you for your solution PonJar, it is elegant. It only differed in that the Exec=/usr/local/bin/sxhkd Because I spent so much time on trying to get BASH to launch a command on startup, if anyone knows a solution, I'd still like to know that too. Thanks again! Nov 25 at 12:05
  • Thanks again. You're right, but I think a lack of understanding on my part has not aided in my explanation. Using the autorun in ~/.config yields the same result as in xdg: There is no user prompt (and for whatever reason sxhkd won't launch, which is no longer an issue). Why is there no user@user: when we launch the terminal this way? Thanks very much Nov 26 at 1:32
  • Ah, that makes sense. much appreciated. Nov 26 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.