gh0stzk / dotfiles

BSPWM environment with 18 themes. With a theme selector to change on the fly.
GNU General Public License v3.0
2.69k stars 201 forks source link

Autostart apps #213

Closed chrollorifat closed 4 months ago

chrollorifat commented 5 months ago

I've created an autostart.sh script and put it in the .config/bspwm/scripts/ directory. In the script, I have a list of the commands for opening the applications that i want to open. For example, variety & xdman-gtk & keepassxc &

And then I have added a line exec /home/user/.config/bspwm/scripts/autostart.sh & in my bspwmrc at the end to execute the script whenever bspwm is launched/restarted. The only issue I'm having with this approach is, it always opens up the applications that I mentioned to autostart. It is supposed to be in the background with a tray icon/ polybar icon and not launched full screen, right? But I have to manually close them every time I start or restart bspwm.

I want to know if there is a better way to setup autostart of applications.

gh0stzk commented 5 months ago

Your approach is correct, but in setups where you don't reload bspwm very often or at all. Here we have 15 themes and every time you change to another, your applications in autostart.sh are launched again and in the event that the application does not accept another instance of it, it simply opens it, that is why you have to close it every time you change the theme . You have several solutions, I leave you 2.

In your autostart.sh

pidof -q appprocess1 || app1 &
pidof -q appprocess2 || app2 &
pidof -q appprocess3 || app3 &

With this, it first checks if the application is already running, if it is not, it executes it and if it is already running, it does nothing.

Of course change the appprocess for the real process i dont use that apps so I don't know what the name of the process is.

The other method could be add that apps to the line 63 of bspwmrc

processes=("sxhkd" "polybar" "dunst" "eww.*bar")

But that would kill your applications every time you change the theme and relaunch them thanks to your autostart script, and I don't think that's the right approach.