Add comments and pseudo-shebangs
This commit is contained in:
parent
73f9ec4294
commit
5809078169
18
README.md
18
README.md
@ -13,24 +13,16 @@ Execute `firestarter` in your `.xinitrc`, either by replacing the file or by `ex
|
|||||||
On first run and when invoked with `firestarter -g`, Firestarter will generate a series of configuration files in `~/.config/firestarter`. These files consist of several lines that look somewhat like the following:
|
On first run and when invoked with `firestarter -g`, Firestarter will generate a series of configuration files in `~/.config/firestarter`. These files consist of several lines that look somewhat like the following:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
#.fsdefaults
|
||||||
command -v i3
|
command -v i3
|
||||||
i3
|
i3
|
||||||
|
command -v openbox
|
||||||
|
openbox
|
||||||
```
|
```
|
||||||
|
|
||||||
Every odd line is a command that must succeed in order for the following even line to be executed. Once an even command is executed, parsing stops. When Firestarter is invoked with no arguments, every configuration file is parsed this way.
|
Every first uncommented line is a "check" command that must succeed in order for the following "target" line to be executed. Once a target command is selected, parsing stops and the target is executed. When Firestarter is invoked with no arguments, any file with a first line of `#.fsdefaults` is parsed this way.
|
||||||
|
|
||||||
This approach allows for a single file to contain very many alternatives while still being readable and supporting arbitrary launch requirements (such as in the case of Polybar, which requires a `launch.sh` script by default).
|
Any file that does *not* have the initial "crunchdot" is executed normally. You can keep shell scripts or symlinks in here and they will be executed without issue.
|
||||||
|
|
||||||
By setting a dummy execution line, one can effectively prevent an entire configuration file from being parsed in certain environments. As an example, the following configuration file will only attempt to start an X infobar in an X environment:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
[ -z "$DISPLAY" ]
|
|
||||||
:
|
|
||||||
command -v polybar
|
|
||||||
polybar bar
|
|
||||||
command -v lemonbar
|
|
||||||
~/.bin/lemonbar.sh | lemonbar
|
|
||||||
```
|
|
||||||
|
|
||||||
After all these programs have been started, firestarter starts XDG autostart applications and executes `~/.firestarterrc` if it exists.
|
After all these programs have been started, firestarter starts XDG autostart applications and executes `~/.firestarterrc` if it exists.
|
||||||
|
|
||||||
|
33
firestarter
33
firestarter
@ -60,7 +60,19 @@ gettarget() {
|
|||||||
[ -r "$1" ] || return 1
|
[ -r "$1" ] || return 1
|
||||||
# Every odd line is the check line
|
# Every odd line is the check line
|
||||||
# Every even one is the exec line
|
# Every even one is the exec line
|
||||||
|
local firstline
|
||||||
while read -r checkline; do
|
while read -r checkline; do
|
||||||
|
if [ -z "$firstline" ]; then
|
||||||
|
if [ "$checkline" = "#.fsdefaults" ]; then
|
||||||
|
firstline=1
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
return 50
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ "${checkline#"#"}" != "$checkline" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
read -r execline
|
read -r execline
|
||||||
if bash -c "$checkline" > /dev/null 2>&1; then
|
if bash -c "$checkline" > /dev/null 2>&1; then
|
||||||
_return="$execline"
|
_return="$execline"
|
||||||
@ -78,11 +90,13 @@ step_generate() {
|
|||||||
log "See firestarter -h for more information"
|
log "See firestarter -h for more information"
|
||||||
# Audio daemon
|
# Audio daemon
|
||||||
cat << EOF > "$_configdir/audio-daemon"
|
cat << EOF > "$_configdir/audio-daemon"
|
||||||
|
#.fsdefaults
|
||||||
command -v pulseaudio
|
command -v pulseaudio
|
||||||
pulseaudio
|
pulseaudio
|
||||||
EOF
|
EOF
|
||||||
# Information bars
|
# Information bars
|
||||||
cat << EOF > "$_configdir/bar"
|
cat << EOF > "$_configdir/bar"
|
||||||
|
#.fsdefaults
|
||||||
command -v tint2
|
command -v tint2
|
||||||
tint2
|
tint2
|
||||||
command -v polybar && [ -r "$HOME/.config/polybar/launch.sh" ]
|
command -v polybar && [ -r "$HOME/.config/polybar/launch.sh" ]
|
||||||
@ -98,6 +112,7 @@ xfce4-panel
|
|||||||
EOF
|
EOF
|
||||||
# Blue light filter
|
# Blue light filter
|
||||||
cat << EOF > "$_configdir/blue-light-filter"
|
cat << EOF > "$_configdir/blue-light-filter"
|
||||||
|
#.fsdefaults
|
||||||
command -v redshift-gtk
|
command -v redshift-gtk
|
||||||
redshift-gtk
|
redshift-gtk
|
||||||
command -v redshift
|
command -v redshift
|
||||||
@ -105,6 +120,7 @@ redshift
|
|||||||
EOF
|
EOF
|
||||||
# Compositor
|
# Compositor
|
||||||
cat << EOF > "$_configdir/compositor"
|
cat << EOF > "$_configdir/compositor"
|
||||||
|
#.fsdefaults
|
||||||
[ -z "\$DISPLAY" ]
|
[ -z "\$DISPLAY" ]
|
||||||
:
|
:
|
||||||
command -v unagi
|
command -v unagi
|
||||||
@ -116,6 +132,7 @@ xcompmgr
|
|||||||
EOF
|
EOF
|
||||||
# Polkit authentication agents
|
# Polkit authentication agents
|
||||||
cat << EOF > "$_configdir/polkit-agent"
|
cat << EOF > "$_configdir/polkit-agent"
|
||||||
|
#.fsdefaults
|
||||||
command -v lxqt-policykit-agent
|
command -v lxqt-policykit-agent
|
||||||
lxqt-policykit-agent
|
lxqt-policykit-agent
|
||||||
command -v lxpolkit
|
command -v lxpolkit
|
||||||
@ -141,6 +158,7 @@ polkit-efl-authentication-agent-1
|
|||||||
EOF
|
EOF
|
||||||
# Hotkey daemon
|
# Hotkey daemon
|
||||||
cat << EOF > "$_configdir/hotkey-daemon"
|
cat << EOF > "$_configdir/hotkey-daemon"
|
||||||
|
#.fsdefaults
|
||||||
[ -z "\$DISPLAY" ]
|
[ -z "\$DISPLAY" ]
|
||||||
:
|
:
|
||||||
command -v sxhkd
|
command -v sxhkd
|
||||||
@ -148,11 +166,13 @@ sxhkd
|
|||||||
EOF
|
EOF
|
||||||
# Network daemon
|
# Network daemon
|
||||||
cat << EOF > "$_configdir/network-daemon"
|
cat << EOF > "$_configdir/network-daemon"
|
||||||
|
#.fsdefaults
|
||||||
command -v nm-applet
|
command -v nm-applet
|
||||||
nm-applet
|
nm-applet
|
||||||
EOF
|
EOF
|
||||||
# Notification daemon
|
# Notification daemon
|
||||||
cat << EOF > "$_configdir/notification-daemon"
|
cat << EOF > "$_configdir/notification-daemon"
|
||||||
|
#.fsdefaults
|
||||||
[ -z "\$DISPLAY" ]
|
[ -z "\$DISPLAY" ]
|
||||||
:
|
:
|
||||||
command -v dunst
|
command -v dunst
|
||||||
@ -162,6 +182,7 @@ notificationd
|
|||||||
EOF
|
EOF
|
||||||
# Power daemons
|
# Power daemons
|
||||||
cat << EOF > "$_configdir/power-daemon"
|
cat << EOF > "$_configdir/power-daemon"
|
||||||
|
#.fsdefaults
|
||||||
command -v batterymon
|
command -v batterymon
|
||||||
batterymon
|
batterymon
|
||||||
command -v cbatticon
|
command -v cbatticon
|
||||||
@ -178,11 +199,13 @@ EOF
|
|||||||
# Runners
|
# Runners
|
||||||
# Note that rofi is not a daemon and is not included here
|
# Note that rofi is not a daemon and is not included here
|
||||||
cat << EOF > "$_configdir/runner"
|
cat << EOF > "$_configdir/runner"
|
||||||
|
#.fsdefaults
|
||||||
command -v krunner
|
command -v krunner
|
||||||
krunner
|
krunner
|
||||||
EOF
|
EOF
|
||||||
# Settings daemons
|
# Settings daemons
|
||||||
cat << EOF > "$_configdir/settings-daemon"
|
cat << EOF > "$_configdir/settings-daemon"
|
||||||
|
#.fsdefaults
|
||||||
command -v xsettingsd
|
command -v xsettingsd
|
||||||
xsettingsd
|
xsettingsd
|
||||||
command -v xsettings-kde
|
command -v xsettings-kde
|
||||||
@ -198,6 +221,7 @@ EOF
|
|||||||
# Note: the dumb sleep hack is because Conky crashes with window_type override if the WM hasn't loaded yet
|
# Note: the dumb sleep hack is because Conky crashes with window_type override if the WM hasn't loaded yet
|
||||||
# This gives the Wm ample time to load up
|
# This gives the Wm ample time to load up
|
||||||
cat << EOF > "$_configdir/stat-glances"
|
cat << EOF > "$_configdir/stat-glances"
|
||||||
|
#.fsdefaults
|
||||||
[ -z "\$DISPLAY" ]
|
[ -z "\$DISPLAY" ]
|
||||||
:
|
:
|
||||||
command -v conky && [ -r "\${XDG_CONFIG_HOME:-$HOME/.config}/conky/conky.conf" ]
|
command -v conky && [ -r "\${XDG_CONFIG_HOME:-$HOME/.config}/conky/conky.conf" ]
|
||||||
@ -205,6 +229,7 @@ sleep 5 && conky
|
|||||||
EOF
|
EOF
|
||||||
# Wallpaper setters
|
# Wallpaper setters
|
||||||
cat << EOF > "$_configdir/wallpaper"
|
cat << EOF > "$_configdir/wallpaper"
|
||||||
|
#.fsdefaults
|
||||||
[ -z "\$DISPLAY" ]
|
[ -z "\$DISPLAY" ]
|
||||||
:
|
:
|
||||||
command -v feh && [ -r "$HOME/.fehbg" ]
|
command -v feh && [ -r "$HOME/.fehbg" ]
|
||||||
@ -214,6 +239,7 @@ nitrogen --restore
|
|||||||
EOF
|
EOF
|
||||||
# Window managers
|
# Window managers
|
||||||
cat << EOF > "$_configdir/wm"
|
cat << EOF > "$_configdir/wm"
|
||||||
|
#.fsdefaults
|
||||||
[ -z "\$DISPLAY" ]
|
[ -z "\$DISPLAY" ]
|
||||||
:
|
:
|
||||||
command -v 2bwm
|
command -v 2bwm
|
||||||
@ -422,6 +448,7 @@ step_execute() {
|
|||||||
local logfile="$_logdir/$filename"
|
local logfile="$_logdir/$filename"
|
||||||
[ -n "$FS_NOLOG" ] && logfile="/dev/null"
|
[ -n "$FS_NOLOG" ] && logfile="/dev/null"
|
||||||
if gettarget "$file"; then
|
if gettarget "$file"; then
|
||||||
|
# It's a defaults file with a selected target
|
||||||
target="$_return"
|
target="$_return"
|
||||||
log "Found target for \"$filename\": \"$target\""
|
log "Found target for \"$filename\": \"$target\""
|
||||||
if [ -z "$_dryrun" ]; then
|
if [ -z "$_dryrun" ]; then
|
||||||
@ -431,6 +458,12 @@ step_execute() {
|
|||||||
fi
|
fi
|
||||||
bash -c "$target" > "$logfile" 2>&1 &
|
bash -c "$target" > "$logfile" 2>&1 &
|
||||||
fi
|
fi
|
||||||
|
elif [ $? = 50 ] && [ -x "$file" ]; then
|
||||||
|
# It's a shell script or something
|
||||||
|
log "Executing file straight out: \"$filename\""
|
||||||
|
if [ -z "$_dryrun" ]; then
|
||||||
|
"$file" > "$logfile" 2>&1 &
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user