Solved CWM how to autostart applications?

.xinitrc, .xwmrc or what?
I like cwm -- my cwm desktop makes for a nice clean screenshot (nothing at all on a dark background). The normal way, I suppose, of autostarting applications in cwm is to start them in .xinitrc. The next question to ask is "How do I get my login manager to execute my .xinitrc?" It can be done nicely using x11/slim, which will pass the exec line from the chosen session file to your ~/.xinitrc. For cwm the session file (/usr/local/share/xsessions/cwm.desktop) defines the command to be executed as "cwm", so your ~/.xinitrc can start all of the applications you want on every login and end by exec'ing cwm.

As an extended example (since your question was so brief that I don't know how much detail you need) I want to run whatever window manager was selected using the F1 key in slim, or if I'm starting some other way and there is no parameter passed in I want to run my default window manager, which is cwm if cwm is installed, or fluxbox otherwise...
Code:
# .xinitrc
# On OpenBSD cwm and xterm (and all of x11) are in the base operating system
# and so are available at all times even before any packages are installed.
# For everything else there's fluxbox :)
if which cwm >/dev/null 2>&1 ; then
  SESSION=${1:-cwm}
else
  SESSION=${1:-startfluxbox}
fi

if which gnome-keyring-daemon >/dev/null 2>&1 ; then
  eval $(gnome-keyring-daemon --start --components=pkcs11,secrets,ssh,gpg)
  export SSH_AUTH_SOCK
  export GPG_AGENT_INFO
fi

if which compton >/dev/null 2>&1; then
  compton &
fi

# ...etc...

echo "`date`:  $SESSION" >>~/sessions
if which ck-launch-session >/dev/null 2>&1 ; then
    exec ck-launch-session dbus-launch --sh-syntax --exit-with-session "$SESSION"
else
  exec "$SESSION"
fi
I hope that that's helpful to you.
 
garry I have been meaning to post something similar to the OP for some time, many thanks for your example as I was able to correct the way I launch security/gnome-keyring and devel/dbus.

While I am not the OP, this seems like a somewhat logical place to ask how one might auto-launch applications that require DBus running before they start?

My example is deskutils/nextcloudclient, if I launch it manually (either via a shell, or via x11-wm/cwm's "exec program" dialog Nextcloud will poke Gnome Keyring for a password and (once entered) will start syncing files.
However, if I try to launch it in my ~/.xsession I see a window flicker up and disappear.
 
...if I try to launch it in my ~/.xsession I see a window flicker up and disappear.
and thank you for reminding me to use the
Code:
[port] and [/port]
markup.

Have you tried launching deskutils/nextcloudclient in your xsession after correctly starting gnome keyring? As for how to start stuff "correctly" I have had on and off consolekit and dbus problems over the years. In FreeBSD I've settled on using x11/slim built locally with the option CONSOLEKIT=off so that slim does not try to start a consolekit session for me; I start it in my xinitrc as shown in my previous post.

I do not actually start stuff (except gnome-keyring) in my xinitrc despite my contrived example. I assign a shortcut key to open my own script that uses x11/dmenu and x11/rofi to run my system of menus for accessing everything.
Code:
# ~/everything/.run
prompt="`date +%H:%M`"
font='Monospace-11:normal'
selection="`LC_COLLATE=C ls | dmenu -p $prompt -b -sb green -sf black -fn $font`"
# ^ or v
# selection="`ls | rofi -case-sensitive -dmenu`"
if [ "$selection" ]; then
        if [ -d "$selection" ]; then
                if [ -x "$selection/.run" ]; then
                        ./"$selection/.run"
                elif [ -x "$selection/AppRun" ]; then 
                        ./"$selection/AppRun" 
                else
                        #xdg-open "$selection"
                        # ^ or v
                        rox  "$selection" 
                fi
        else
                #- xdg-open "$selection"
                # ^ or v
                rox   "$selection"
        fi
fi

fi
So by executing ~/everything/.run I can quickly get at any application, place, notebook, password, system setting, or other category according to the other folders I create under ~/everything and how I write the .run script for that category.
 
Do you know why my .xinitrc does not run tmux script file?


Code:
## Run tmux command
~/.config/tmux.sh &

## Start dmenu
dmenu &

## Start CWM
exec cwm

Code:
> cat .config/tmux.sh
### TMUX xonfiguration
#tmux new-session \; split-window -h \; select-pane -t 0 \; split-window -v -p 66 \; split-window -v \;
tmux new-session \; split-window -h \; select-pane -t 0 \; split-window -v -p 66 \;

Could you post your ~/.cwmrc file here? I need to define keybindings or at least define keybinding to dmenu.
 
So here is the excerpt from my .cwmrc that I use to launch dmenu:

Code:
# Key bindings 
bind-key CM-p         "dmenu_run"

I think that's the same keybinding "ctrl + alt + p" that x11-wm/dwm used and I used to use dwm so it kind of stuck. As I mentioned, no need to run it from .xinitrc
 
Do you know how to change mouse bindings from Alt to Superkey?


mousebind 4-M1 window_move
mousebind 4-M2 window_resize


These does not work..
 
Back
Top