I’m talking about this patch:

https://dwm.suckless.org/patches/autostart/

Now, the notes seem simple: after apply the patch, dwm will look for the autostart script in ~/.dwm/autostart.sh.

But if you read it carefully, the file is:

~/.dwm/autostart.sh &

Wth does a “&” have to do with file name? I tried to just use the normal file: autostart.sh with exec dunst. It doesnt work…

I tried to create in the Thunar this weird file name, “autostop.sh &”. The system does not recognize it as sh script anymore. .

Any help is welcome.

  • gnuhaut@lemmy.ml
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    3 days ago

    The file autostart.sh file needs to be executable. This might be why it’s not working.

  • www-gem@lemmy.ml
    link
    fedilink
    arrow-up
    3
    ·
    4 days ago

    I will not reiterate what others have well explained Re: the use of &, though it’s surprising to see someone able to use dwm before getting control of the basics of the command-line :)

    Coming back to your issue, have you applied the patch and recompiled dwm? Also, you may want to take a look at the note on this patch’s github (which was last updated 13 years ago).

  • vvv@programming.dev
    link
    fedilink
    arrow-up
    4
    ·
    4 days ago

    The & is an indicator to most shells to run this command in “the background”. Try and run ( sleep 10; echo hi ) & - you’ll see you get your shell prompt back, where you can run more commands, but 10 second later you’ll see that ‘hi’ come through. ‘blocking’ is the default behavior, if you don’t add the & you’re still going get the hi in ten seconds, but you don’t get a prompt because your shell’s execution is blocked until your command is done.

    The doc here is indicating that you havea choice between autostart_blocking.sh and autostart.sh, the latter of which would be run with a &. They could have expressed this better.

    As for why your script didn’t work, I’d try executing it in a terminal to see what error message comes up.

    • mazzilius_marsti@lemmy.worldOP
      link
      fedilink
      arrow-up
      1
      ·
      4 days ago

      i see, so the file names are: autostart_blocking.sh and autostart.sh

      I dont need to create a weird file name like: autostart.sh &

      But, whichever command I put in autostart.sh will run as if I run in terminal with the & sign. E.g: dunst & to run in the background.

      • Ferk@lemmy.ml
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        3 days ago

        But, whichever command I put in autostart.sh will run as if I run in terminal with the & sign. E.g: dunst & to run in the background.

        Well, only if it’s one single command, if you have multiple commands inside of the script, they will still run sequentially (the next command will only run after the previous one completely closes) unless you add & to them as well.

        The difference is that dwm itself will not have to wait for the autostart.sh to complete before launching itself (thanks to it being run in the background with &)

        However, autostart_blocking.sh (which isn’t run with a &) will stop dwm from fully launching until the script completes… I guess this is useful if you need certain things to be set up before dwm actually starts… but it would potentially add a delay on dwm startup.

  • TXL@sopuli.xyz
    link
    fedilink
    arrow-up
    3
    ·
    4 days ago

    It’s not a file name. It’s shell syntax. Specifically, https://en.wikipedia.org/wiki/Job_control_(Unix)

    That’s a pretty terrible article on the subject, but I don’t have a better one at hand. You could read some shell scripting tutorial or manual or maybe a beginners guide to Unix. A decent one should explain job control well.

    But basically, in a script or command line, an ampersand ends a command and runs it in the background without waiting for it to finish before running the next command. A semicolon works the same but waits on the foreground.

  • catharso@discuss.tchncs.de
    link
    fedilink
    arrow-up
    1
    ·
    4 days ago

    hmm, usually the & is not part of the filename and just tells the script to run in the background 🤔

    but i’m not sure what it means in this case.

    • mazzilius_marsti@lemmy.worldOP
      link
      fedilink
      arrow-up
      1
      arrow-down
      1
      ·
      4 days ago

      yes, that is what I thought: so “dunst &” means to start dunst in the background. But the way they attach to the end of a file name is weird.