2019-04-27 00:01:25 -05:00
|
|
|
#! /bin/bash
|
|
|
|
#
|
2019-06-21 16:39:11 -05:00
|
|
|
# firestarter
|
2019-04-27 00:01:25 -05:00
|
|
|
# A desktop environment startup script
|
|
|
|
# Copyright (C) 2019 Vintage Salt <rehashedsalt@cock.li>
|
|
|
|
#
|
|
|
|
# Distributed under terms of the MIT license.
|
|
|
|
#
|
|
|
|
|
|
|
|
# "Globals"
|
2019-06-21 17:18:32 -05:00
|
|
|
_name="firestarter"
|
|
|
|
_configdir="${XDG_CONFIG_HOME:-$HOME/.config}/$_name"
|
|
|
|
_logdir="${XDG_DATA_HOME:-$HOME/.local/share}/$_name/logs"
|
2019-06-21 18:49:03 -05:00
|
|
|
_firestarterrc="$HOME/.firestarterrc"
|
2019-06-21 19:09:46 -05:00
|
|
|
_sessionid="$(< /proc/self/sessionid)"
|
2019-06-21 22:19:38 -05:00
|
|
|
# Dummy fd for read sleeping
|
|
|
|
exec 1023<> <(:)
|
2019-04-27 00:01:25 -05:00
|
|
|
|
|
|
|
# Basic functions
|
|
|
|
print() {
|
|
|
|
# Write a message to STDOUT without a name attached
|
2019-06-22 00:33:44 -05:00
|
|
|
# 1: That message
|
2019-04-27 00:01:25 -05:00
|
|
|
[ -z "$1" ] && return 1
|
|
|
|
printf "%s\\n" \
|
|
|
|
"$1"
|
|
|
|
}
|
|
|
|
log() {
|
|
|
|
# Write a message to STDOUT
|
2019-06-22 00:33:44 -05:00
|
|
|
# 1: That message
|
2019-04-27 00:01:25 -05:00
|
|
|
[ -z "$1" ] && return 1
|
|
|
|
printf "%s log: %s\\n" \
|
2019-06-21 17:18:32 -05:00
|
|
|
"$_name" \
|
2019-04-27 00:01:25 -05:00
|
|
|
"$1" >&1
|
|
|
|
}
|
|
|
|
err() {
|
|
|
|
# Write a message to STDERR, also exit if arg 2 is specified
|
2019-06-22 00:33:44 -05:00
|
|
|
# 1: That message
|
|
|
|
# 2: An optional exit code (will only exit if provided)
|
2019-04-27 00:01:25 -05:00
|
|
|
[ -z "$1" ] && return 1
|
|
|
|
printf "%s err: %s\\n" \
|
2019-06-21 17:18:32 -05:00
|
|
|
"$_name" \
|
2019-04-27 00:01:25 -05:00
|
|
|
"$1" >&2
|
|
|
|
[ -z "$2" ] && return 0
|
|
|
|
if ! [ "$2" -ge "0" ] > /dev/null 2>&1; then
|
|
|
|
err "Attempted to exit with malformed exit code \"$2\"" 10
|
|
|
|
else
|
|
|
|
exit "$2"
|
|
|
|
fi
|
|
|
|
}
|
2019-06-21 22:19:38 -05:00
|
|
|
has() {
|
2019-06-22 00:33:44 -05:00
|
|
|
# See if a program exists in $PATH
|
|
|
|
# 1: A program
|
2019-06-21 22:19:38 -05:00
|
|
|
[ -z "$1" ] && return 1
|
|
|
|
command -v "$1" > /dev/null 2>&1
|
|
|
|
}
|
2019-06-21 21:40:43 -05:00
|
|
|
gettarget() {
|
|
|
|
# Parse a defaults file to get the target program
|
2019-06-22 00:33:44 -05:00
|
|
|
# 1: A defaults file
|
2019-04-27 00:01:25 -05:00
|
|
|
[ -z "$1" ] && return 1
|
2019-06-21 21:40:43 -05:00
|
|
|
[ -r "$1" ] || return 1
|
|
|
|
# Every odd line is the check line
|
|
|
|
# Every even one is the exec line
|
2019-06-22 01:53:32 -05:00
|
|
|
local firstline
|
2019-06-21 21:40:43 -05:00
|
|
|
while read -r checkline; do
|
2019-06-22 01:53:32 -05:00
|
|
|
if [ -z "$firstline" ]; then
|
|
|
|
if [ "$checkline" = "#.fsdefaults" ]; then
|
|
|
|
firstline=1
|
|
|
|
continue
|
|
|
|
else
|
|
|
|
return 50
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ "${checkline#"#"}" != "$checkline" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
2019-06-21 21:40:43 -05:00
|
|
|
read -r execline
|
|
|
|
if bash -c "$checkline" > /dev/null 2>&1; then
|
|
|
|
_return="$execline"
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
done < "$1"
|
|
|
|
return 2
|
2019-04-27 00:01:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# Steps in execution
|
|
|
|
step_generate() {
|
2019-06-21 17:18:32 -05:00
|
|
|
log "Creating default config setup in \"$_configdir\""
|
2019-04-27 00:01:25 -05:00
|
|
|
log "See firestarter -h for more information"
|
|
|
|
# Audio daemon
|
2019-06-21 17:18:32 -05:00
|
|
|
cat << EOF > "$_configdir/audio-daemon"
|
2019-06-22 01:53:32 -05:00
|
|
|
#.fsdefaults
|
2019-04-27 00:01:25 -05:00
|
|
|
command -v pulseaudio
|
|
|
|
pulseaudio
|
|
|
|
EOF
|
|
|
|
# Information bars
|
2019-06-21 17:18:32 -05:00
|
|
|
cat << EOF > "$_configdir/bar"
|
2019-06-22 01:53:32 -05:00
|
|
|
#.fsdefaults
|
2019-04-27 00:01:25 -05:00
|
|
|
command -v tint2
|
|
|
|
tint2
|
2019-06-21 17:39:49 -05:00
|
|
|
command -v polybar && [ -r "$HOME/.config/polybar/launch.sh" ]
|
2019-06-21 17:18:32 -05:00
|
|
|
"$HOME/.config/polybar/launch.sh"
|
2019-04-27 00:01:25 -05:00
|
|
|
command -v lxpanel
|
|
|
|
lxpanel
|
|
|
|
command -v lxqt-panel
|
|
|
|
lxqt-panel
|
|
|
|
command -v mate-panel
|
|
|
|
mate-panel
|
|
|
|
command -v xfce4-panel
|
|
|
|
xfce4-panel
|
2019-06-21 16:58:01 -05:00
|
|
|
EOF
|
|
|
|
# Blue light filter
|
2019-06-21 17:18:32 -05:00
|
|
|
cat << EOF > "$_configdir/blue-light-filter"
|
2019-06-22 01:53:32 -05:00
|
|
|
#.fsdefaults
|
2019-06-21 16:58:01 -05:00
|
|
|
command -v redshift-gtk
|
|
|
|
redshift-gtk
|
|
|
|
command -v redshift
|
|
|
|
redshift
|
|
|
|
EOF
|
|
|
|
# Compositor
|
2019-06-21 17:18:32 -05:00
|
|
|
cat << EOF > "$_configdir/compositor"
|
2019-06-22 01:53:32 -05:00
|
|
|
#.fsdefaults
|
2019-06-21 16:58:01 -05:00
|
|
|
[ -z "\$DISPLAY" ]
|
|
|
|
:
|
|
|
|
command -v unagi
|
|
|
|
unagi
|
|
|
|
command -v compton
|
|
|
|
compton
|
|
|
|
command -v xcompmgr
|
|
|
|
xcompmgr
|
2019-04-27 00:01:25 -05:00
|
|
|
EOF
|
|
|
|
# Polkit authentication agents
|
2019-06-21 17:18:32 -05:00
|
|
|
cat << EOF > "$_configdir/polkit-agent"
|
2019-06-22 01:53:32 -05:00
|
|
|
#.fsdefaults
|
2019-04-27 00:01:25 -05:00
|
|
|
command -v lxqt-policykit-agent
|
|
|
|
lxqt-policykit-agent
|
|
|
|
command -v lxpolkit
|
|
|
|
lxpolkit
|
|
|
|
command -v mate-polkit
|
|
|
|
mate-polkit
|
|
|
|
command -v polkit-efl-authentication-agent-1
|
|
|
|
polkit-efl-authentication-agent-1
|
2019-06-21 20:17:07 -05:00
|
|
|
[ -x "/usr/lib/ts-polkitagent" ]
|
|
|
|
/usr/lib/ts-polkitagent
|
2019-06-21 20:16:42 -05:00
|
|
|
[ -x "/usr/lib/$(uname -m)-linux-gnu/polkit-mate/polkit-mate-authentication-agent-1" ]
|
|
|
|
"/usr/lib/$(uname -m)-linux-gnu/polkit-mate/polkit-mate-authentication-agent-1"
|
|
|
|
[ -x "/usr/lib/mate-polkit/polkit-mate-authentication-agent-1" ]
|
|
|
|
/usr/lib/mate-polkit/polkit-mate-authentication-agent-1
|
|
|
|
[ -x "/usr/lib/$(uname -m)-linux-gnu/libexec/polkit-kde-authentication-agent-1" ]
|
|
|
|
"/usr/lib/$(uname -m)-linux-gnu/libexec/polkit-kde-authentication-agent-1"
|
|
|
|
[ -x "/usr/lib/polkit-kde-authentication-agent-1" ]
|
|
|
|
/usr/lib/polkit-kde-authentication-agent-1
|
|
|
|
[ -x "/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1" ]
|
|
|
|
/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1
|
|
|
|
[ -x "/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1" ]
|
|
|
|
/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1
|
2019-06-21 16:58:01 -05:00
|
|
|
EOF
|
|
|
|
# Hotkey daemon
|
2019-06-21 17:18:32 -05:00
|
|
|
cat << EOF > "$_configdir/hotkey-daemon"
|
2019-06-22 01:53:32 -05:00
|
|
|
#.fsdefaults
|
2019-06-21 16:58:01 -05:00
|
|
|
[ -z "\$DISPLAY" ]
|
|
|
|
:
|
|
|
|
command -v sxhkd
|
|
|
|
sxhkd
|
2019-06-21 18:06:42 -05:00
|
|
|
EOF
|
|
|
|
# Network daemon
|
|
|
|
cat << EOF > "$_configdir/network-daemon"
|
2019-06-22 01:53:32 -05:00
|
|
|
#.fsdefaults
|
2019-06-21 18:06:42 -05:00
|
|
|
command -v nm-applet
|
|
|
|
nm-applet
|
2019-06-21 16:58:01 -05:00
|
|
|
EOF
|
|
|
|
# Notification daemon
|
2019-06-21 17:18:32 -05:00
|
|
|
cat << EOF > "$_configdir/notification-daemon"
|
2019-06-22 01:53:32 -05:00
|
|
|
#.fsdefaults
|
2019-06-21 16:58:01 -05:00
|
|
|
[ -z "\$DISPLAY" ]
|
|
|
|
:
|
|
|
|
command -v dunst
|
|
|
|
dunst
|
|
|
|
command -v lxqt-notificationd
|
|
|
|
notificationd
|
2019-04-27 00:01:25 -05:00
|
|
|
EOF
|
|
|
|
# Power daemons
|
2019-06-21 17:18:32 -05:00
|
|
|
cat << EOF > "$_configdir/power-daemon"
|
2019-06-22 01:53:32 -05:00
|
|
|
#.fsdefaults
|
2019-04-27 00:01:25 -05:00
|
|
|
command -v batterymon
|
|
|
|
batterymon
|
|
|
|
command -v cbatticon
|
|
|
|
cbatticon
|
|
|
|
command -v lxqt-powermangement
|
|
|
|
lxqt-powermanagement
|
|
|
|
command -v xfce4-power-manager
|
|
|
|
xfce4-power-manager
|
|
|
|
command -v mate-power-manager
|
|
|
|
mate-power-manager
|
|
|
|
command -v gnome-power-manager
|
|
|
|
gnome-power-manager
|
2019-06-21 16:58:01 -05:00
|
|
|
EOF
|
|
|
|
# Runners
|
|
|
|
# Note that rofi is not a daemon and is not included here
|
2019-06-21 17:18:32 -05:00
|
|
|
cat << EOF > "$_configdir/runner"
|
2019-06-22 01:53:32 -05:00
|
|
|
#.fsdefaults
|
2019-06-21 16:58:01 -05:00
|
|
|
command -v krunner
|
|
|
|
krunner
|
2019-04-27 00:01:25 -05:00
|
|
|
EOF
|
|
|
|
# Settings daemons
|
2019-06-21 17:18:32 -05:00
|
|
|
cat << EOF > "$_configdir/settings-daemon"
|
2019-06-22 01:53:32 -05:00
|
|
|
#.fsdefaults
|
2019-04-27 00:01:25 -05:00
|
|
|
command -v xsettingsd
|
|
|
|
xsettingsd
|
|
|
|
command -v xsettings-kde
|
|
|
|
xsettingskde
|
|
|
|
command -v xfsettingsd
|
|
|
|
xfsettingsd
|
|
|
|
command -v mate-settings-daemon
|
|
|
|
mate-settings-daemon
|
|
|
|
command -v gnome-settings-daemon
|
|
|
|
gnome-settings-daemon
|
2019-06-21 08:12:16 -05:00
|
|
|
EOF
|
2019-06-21 17:32:28 -05:00
|
|
|
# System statistics glances
|
2019-06-21 17:18:32 -05:00
|
|
|
cat << EOF > "$_configdir/stat-glances"
|
2019-06-22 01:53:32 -05:00
|
|
|
#.fsdefaults
|
2019-06-21 08:12:16 -05:00
|
|
|
[ -z "\$DISPLAY" ]
|
|
|
|
:
|
2019-06-22 02:33:17 -05:00
|
|
|
# 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
|
2019-06-21 17:39:49 -05:00
|
|
|
command -v conky && [ -r "\${XDG_CONFIG_HOME:-$HOME/.config}/conky/conky.conf" ]
|
2019-06-21 18:35:25 -05:00
|
|
|
sleep 5 && conky
|
2019-06-21 17:39:49 -05:00
|
|
|
EOF
|
|
|
|
# Wallpaper setters
|
|
|
|
cat << EOF > "$_configdir/wallpaper"
|
2019-06-22 01:53:32 -05:00
|
|
|
#.fsdefaults
|
2019-06-21 17:39:49 -05:00
|
|
|
[ -z "\$DISPLAY" ]
|
|
|
|
:
|
|
|
|
command -v feh && [ -r "$HOME/.fehbg" ]
|
|
|
|
~/.fehbg
|
|
|
|
command -v nitrogen
|
|
|
|
nitrogen --restore
|
2019-04-27 00:01:25 -05:00
|
|
|
EOF
|
2019-06-21 16:58:01 -05:00
|
|
|
# Window managers
|
2019-06-21 17:18:32 -05:00
|
|
|
cat << EOF > "$_configdir/wm"
|
2019-06-22 01:53:32 -05:00
|
|
|
#.fsdefaults
|
2019-04-27 00:01:25 -05:00
|
|
|
[ -z "\$DISPLAY" ]
|
|
|
|
:
|
|
|
|
command -v 2bwm
|
|
|
|
2bwm
|
|
|
|
command -v aewm
|
|
|
|
aewm
|
|
|
|
command -v awesome
|
|
|
|
awesome
|
|
|
|
command -v bspwm
|
|
|
|
bspwm
|
|
|
|
command -v catwm
|
|
|
|
catwm
|
|
|
|
command -v cwm
|
|
|
|
cwm
|
|
|
|
command -v dwm
|
|
|
|
dwm
|
|
|
|
command -v evilwm
|
|
|
|
evilwm
|
|
|
|
command -v exwm
|
|
|
|
exwm
|
|
|
|
command -v fluxbox
|
|
|
|
fluxbox
|
|
|
|
command -v flwm
|
|
|
|
flwm
|
|
|
|
command -v fvwm
|
|
|
|
fvwm
|
|
|
|
command -v herbstluftwm
|
|
|
|
herbstluftwm
|
|
|
|
command -v i3
|
|
|
|
i3
|
|
|
|
command -v icewm
|
|
|
|
icewm
|
|
|
|
command -v jbwm
|
|
|
|
jbwm
|
|
|
|
command -v jwm
|
|
|
|
jwm
|
|
|
|
command -v lwm
|
|
|
|
lwm
|
|
|
|
command -v openbox
|
|
|
|
openbox
|
|
|
|
command -v pawm
|
|
|
|
pawm
|
|
|
|
command -v ratpoison
|
|
|
|
ratpoison
|
|
|
|
command -v twm
|
|
|
|
twm
|
|
|
|
command -v windowmaker
|
|
|
|
windowmaker
|
|
|
|
command -v wmii
|
|
|
|
wmii
|
|
|
|
command -v xmonad
|
|
|
|
xmonad
|
|
|
|
command -v xfwm4
|
|
|
|
xfwm4
|
|
|
|
command -v metacity
|
|
|
|
metacity
|
|
|
|
command -v mutter
|
|
|
|
mutter
|
|
|
|
command -v kwin
|
|
|
|
kwin
|
|
|
|
command -v tinywm
|
|
|
|
tinywm
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
step_printhelp() {
|
|
|
|
cat << EOF
|
2019-06-21 07:57:54 -05:00
|
|
|
Usage: $(basename -- "$0") [OPTION...]
|
2019-04-27 00:01:25 -05:00
|
|
|
Start or generate a desktop environment configuration
|
|
|
|
|
|
|
|
-h Show this help text
|
2019-06-21 16:39:11 -05:00
|
|
|
-g Generate a default configuration. This will clobber
|
2019-04-27 00:01:25 -05:00
|
|
|
-d Perform a dry run. This will print the results of all decisions
|
|
|
|
without executing them.
|
|
|
|
|
2019-06-21 22:35:52 -05:00
|
|
|
Additionally, $(basename -- "$0") responds to the following environment variables:
|
2019-06-21 08:16:12 -05:00
|
|
|
|
2019-06-21 22:34:56 -05:00
|
|
|
FS_DIEONWM If nonempty, end the session when the WM dies. This is useful
|
|
|
|
both for preventing session lock-ins and for using built-in WM
|
|
|
|
features to log out of the session.
|
2019-06-21 08:16:12 -05:00
|
|
|
FS_NOLOG If nonempty, create no log files
|
2019-06-21 22:19:38 -05:00
|
|
|
FS_NOWAITWM If nonempty, skip waiting on the WM to initialize
|
2019-06-21 08:16:12 -05:00
|
|
|
|
2019-06-19 07:45:10 -05:00
|
|
|
Copyright (c) 2019 rehashedsalt@cock.li
|
|
|
|
Licensed under the MIT License
|
2019-04-27 00:01:25 -05:00
|
|
|
https://gitlab.com/rehashedsalt/firestarter
|
|
|
|
EOF
|
|
|
|
}
|
2019-06-21 17:32:28 -05:00
|
|
|
step_check() {
|
2019-06-21 18:49:03 -05:00
|
|
|
if [ -z "$_dryrun" ]; then
|
2019-06-21 18:14:55 -05:00
|
|
|
for pid in $(pgrep firestarter); do
|
2019-06-21 19:09:46 -05:00
|
|
|
# Skip invalid PIDs
|
|
|
|
! [ -d "/proc/$pid" ] && continue
|
|
|
|
# If it's not our session then who cares
|
|
|
|
[ "$_sessionid" != "$(< "/proc/$pid/sessionid")" ] && continue
|
2019-06-21 18:14:55 -05:00
|
|
|
if [ "$pid" != "$BASHPID" ]; then
|
2019-06-21 19:12:41 -05:00
|
|
|
err "Firestarter is already running: $pid" 40
|
2019-06-21 18:14:55 -05:00
|
|
|
fi
|
|
|
|
done
|
2019-06-21 17:32:28 -05:00
|
|
|
fi
|
2019-06-21 19:09:46 -05:00
|
|
|
if ! [ -d "$HOME" ] || ! [ -r "$HOME" ]; then
|
|
|
|
err "Inaccessible home directory: \"$HOME\"" 54
|
|
|
|
fi
|
2019-06-21 17:32:28 -05:00
|
|
|
return 0
|
|
|
|
}
|
2019-04-27 00:01:25 -05:00
|
|
|
step_preexecute() {
|
|
|
|
# Special things that can't use simple configuration files
|
2019-06-21 22:19:38 -05:00
|
|
|
[ -n "$_dryrun" ] && return 0
|
2019-04-27 00:01:25 -05:00
|
|
|
|
2019-06-21 21:25:44 -05:00
|
|
|
# Exports
|
|
|
|
export XDG_CURRENT_DESKTOP="${XDG_CURRENT_DESKTOP:-firestarter}"
|
|
|
|
|
2019-04-27 00:01:25 -05:00
|
|
|
# dbus
|
|
|
|
if \
|
|
|
|
[ -z "$DBUS_SESSION_BUS_ADDRESS" ] && \
|
|
|
|
[ -n "$XDG_RUNTIME_DIR" ] && \
|
2019-06-19 07:35:31 -05:00
|
|
|
[ "$XDG_RUNTIME_DIR" = "/run/user/$(id -u)" ] && \
|
2019-04-27 00:01:25 -05:00
|
|
|
[ -S "$XDG_RUNTIME_DIR/bus" ]; then
|
|
|
|
# We already have a bus started, use it
|
|
|
|
export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"
|
|
|
|
hasdbus=1
|
|
|
|
elif \
|
|
|
|
[ -z "$DBUS_SESSION_BUS_ADDRESS" ] && \
|
2019-06-21 22:19:38 -05:00
|
|
|
has dbus-launch; then
|
2019-04-27 00:01:25 -05:00
|
|
|
# We have dbus but haven't started up a bus yet
|
|
|
|
eval "$(dbus-launch --exit-with-session --sh-syntax)"
|
|
|
|
hasdbus=1
|
|
|
|
else
|
|
|
|
log "Did not start dbus; some applications may misbehave"
|
|
|
|
fi
|
|
|
|
if [ -n "$hasdbus" ]; then
|
2019-06-21 22:19:38 -05:00
|
|
|
if has dbus-update-activation-environment; then
|
2019-04-27 00:01:25 -05:00
|
|
|
dbus-update-activation-environment --verbose --systemd --all > /dev/null 2>&1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
unset hasdbus
|
2019-06-19 07:35:31 -05:00
|
|
|
|
|
|
|
# kcminit/Qt settings
|
2019-06-21 22:19:38 -05:00
|
|
|
if has kcminit; then
|
2019-06-19 07:35:31 -05:00
|
|
|
log "Initializing KDE Control Module settings"
|
|
|
|
kcminit > /dev/null 2>&1
|
2019-06-21 19:35:33 -05:00
|
|
|
export XDG_CURRENT_DESKTOP="KDE"
|
2019-06-21 22:19:38 -05:00
|
|
|
elif has qt5ct; then
|
2019-06-19 07:35:31 -05:00
|
|
|
log "Integrating qt5ct"
|
|
|
|
if [ -z "$QT_QPA_PLATFORMTHEME" ]; then
|
|
|
|
export QT_QPA_PLATFORMTHEME="qt5ct"
|
|
|
|
log "Exporting QT_QPA_PLATFORMTHEME as \"$QT_QPA_PLATFORMTHEME\""
|
|
|
|
else
|
|
|
|
log "Using existing theme setting \"$QT_QPA_PLATFORMTHEME\""
|
|
|
|
fi
|
|
|
|
if [ -z "$QT_AUTO_SCREEN_SCALE_FACTOR" ]; then
|
|
|
|
export QT_AUTO_SCREEN_SCALE_FACTOR="0"
|
|
|
|
log "Exporting QT_AUTO_SCREEN_SCALE_FACTOR as $QT_AUTO_SCREEN_SCALE_FACTOR"
|
|
|
|
else
|
|
|
|
log "Using existing scale setting \"$QT_AUTO_SCREEN_SCALE_FACTOR\""
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# xhost
|
2019-06-21 22:19:38 -05:00
|
|
|
if has xhost; then
|
2019-06-19 07:35:31 -05:00
|
|
|
if xhost +si:localuser:"$(id -un)" > /dev/null 2>&1; then
|
|
|
|
log "Session can be accessed in other sessions by this user"
|
|
|
|
else
|
|
|
|
log "Failed to open session up via xhost"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-06-19 07:42:20 -05:00
|
|
|
# xresources
|
2019-06-21 22:19:38 -05:00
|
|
|
if [ -n "$DISPLAY" ] && has xrdb && [ -r "$HOME/.Xresources" ]; then
|
2019-06-19 07:42:20 -05:00
|
|
|
if xrdb "$HOME/.Xresources" > /dev/null 2>&1; then
|
|
|
|
log "Loaded in .Xresources"
|
|
|
|
else
|
|
|
|
log "Failed to load .Xresources"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-06-19 07:35:31 -05:00
|
|
|
# xset
|
2019-06-21 22:19:38 -05:00
|
|
|
if has xset; then
|
2019-06-19 07:35:31 -05:00
|
|
|
log "Disabling bell"
|
|
|
|
xset -b
|
|
|
|
fi
|
2019-04-27 00:01:25 -05:00
|
|
|
}
|
|
|
|
step_execute() {
|
2019-06-21 18:49:03 -05:00
|
|
|
# Ensure we have a config directory
|
2019-06-21 17:18:32 -05:00
|
|
|
if ! [ -d "$_configdir" ]; then
|
|
|
|
if ! mkdir -p "$_configdir" > /dev/null 2>&1; then
|
2019-06-21 19:12:41 -05:00
|
|
|
err "Failed to create configuration directory: \"$_configdir\"" 52
|
2019-04-27 00:01:25 -05:00
|
|
|
fi
|
|
|
|
fi
|
2019-06-21 18:49:03 -05:00
|
|
|
# Ensure we can log if we have to
|
2019-06-21 08:16:12 -05:00
|
|
|
if [ -n "$FS_NOLOG" ]; then
|
|
|
|
log "No logs will be created per FS_NOLOG"
|
2019-06-21 17:18:32 -05:00
|
|
|
elif ! [ -d "$_logdir" ]; then
|
|
|
|
if ! mkdir -p "$_logdir" > /dev/null 2>&1; then
|
2019-06-21 19:12:41 -05:00
|
|
|
err "Failed to create log directory: \"$_logdir\"" 53
|
2019-04-27 00:01:25 -05:00
|
|
|
fi
|
|
|
|
fi
|
2019-06-21 18:49:03 -05:00
|
|
|
# Parse configs
|
2019-06-21 17:18:32 -05:00
|
|
|
for file in "$_configdir"/*; do
|
2019-06-21 21:18:00 -05:00
|
|
|
if ! [ -e "$file" ]; then
|
2019-05-21 18:42:21 -05:00
|
|
|
log "No configuration files found; generating defaults"
|
|
|
|
step_generate
|
|
|
|
step_execute
|
|
|
|
break
|
2019-04-27 00:01:25 -05:00
|
|
|
fi
|
2019-06-21 08:16:12 -05:00
|
|
|
local filename="$(basename -- "$file")"
|
2019-06-21 17:18:32 -05:00
|
|
|
local logfile="$_logdir/$filename"
|
2019-06-21 08:16:12 -05:00
|
|
|
[ -n "$FS_NOLOG" ] && logfile="/dev/null"
|
2019-06-21 21:40:43 -05:00
|
|
|
if gettarget "$file"; then
|
2019-06-22 01:53:32 -05:00
|
|
|
# It's a defaults file with a selected target
|
2019-06-21 21:40:43 -05:00
|
|
|
target="$_return"
|
|
|
|
log "Found target for \"$filename\": \"$target\""
|
2019-06-21 22:19:38 -05:00
|
|
|
if [ -z "$_dryrun" ]; then
|
2019-06-21 21:40:43 -05:00
|
|
|
if [ -f "$logfile" ]; then
|
|
|
|
[ -f "$logfile.old" ] && rm "$logfile.old"
|
|
|
|
mv "$logfile" "$logfile.old"
|
2019-04-27 00:01:25 -05:00
|
|
|
fi
|
2019-06-21 21:40:43 -05:00
|
|
|
bash -c "$target" > "$logfile" 2>&1 &
|
2019-04-27 00:01:25 -05:00
|
|
|
fi
|
2019-06-22 01:53:32 -05:00
|
|
|
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
|
2019-06-22 02:39:46 -05:00
|
|
|
else
|
|
|
|
err "Could not execute file: \"$filename\""
|
2019-06-21 21:40:43 -05:00
|
|
|
fi
|
2019-04-27 00:01:25 -05:00
|
|
|
done
|
2019-06-21 21:40:43 -05:00
|
|
|
}
|
|
|
|
step_postexecute() {
|
2019-06-21 22:19:38 -05:00
|
|
|
# Wait for the WM to initialize, if one was found and we have the tools
|
|
|
|
if [ -z "$FS_NOWAITWM" ] && gettarget "$_configdir/wm" && has xprop && has grep; then
|
|
|
|
log "Waiting for WM to initialize: \"$_return\""
|
|
|
|
for (( i=0; i<10; i++ )); do
|
|
|
|
line="$(xprop -root | grep ^_NET_WM_NAME | grep -o '"\S*"$')"
|
|
|
|
if [ -n "$line" ]; then
|
|
|
|
log "WM has intiailized, _NET_WM_NAME atom reads: $line"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
read -t 1 -u 1023
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
# Start XDG autostarters, if they exist
|
|
|
|
if [ -z "$_dryrun" ]; then
|
|
|
|
if has dex; then
|
|
|
|
dex -a > /dev/null 2>&1
|
|
|
|
elif has fbautostart; then
|
|
|
|
fbautostart > /dev/null 2>&1
|
|
|
|
elif has xdg-autostart; then
|
|
|
|
xdg-autostart ${XDG_CURRENT_DESKTOP:-firestarter}
|
|
|
|
else
|
2019-06-22 02:39:46 -05:00
|
|
|
err "Could not find an XDG autostarter"
|
2019-06-21 22:19:38 -05:00
|
|
|
fi
|
|
|
|
fi
|
2019-06-21 21:40:43 -05:00
|
|
|
# Source in a user script if it exists
|
2019-06-21 18:49:03 -05:00
|
|
|
if [ -r "$_firestarterrc" ] && [ -z "$_dryrun" ]; then
|
|
|
|
log "Sourcing .firestarterrc"
|
|
|
|
"$_firestarterrc"
|
|
|
|
fi
|
2019-04-27 00:01:25 -05:00
|
|
|
}
|
|
|
|
step_wait() {
|
2019-06-21 22:19:38 -05:00
|
|
|
[ -n "$_dryrun" ] && exit 0
|
2019-06-21 08:18:22 -05:00
|
|
|
trap step_logout EXIT
|
2019-06-21 22:43:59 -05:00
|
|
|
if [ -n "$FS_DIEONWM" ] && gettarget "$_configdir/wm" && has readlink && has "$_return"; then
|
|
|
|
target="$(command -v "$_return")"
|
2019-06-21 22:34:56 -05:00
|
|
|
for job in $(jobs -p); do
|
|
|
|
if [ "$target" = "$(readlink /proc/$job/exe)" ]; then
|
2019-06-21 22:43:59 -05:00
|
|
|
log "Waiting for WM to exit: \"$_return\""
|
2019-06-21 22:34:56 -05:00
|
|
|
wait "$job"
|
2019-06-21 22:43:59 -05:00
|
|
|
exit 0
|
2019-06-21 22:34:56 -05:00
|
|
|
fi
|
|
|
|
done
|
2019-06-22 02:39:46 -05:00
|
|
|
err "Could not find WM: \"$target\""
|
2019-06-21 22:34:56 -05:00
|
|
|
fi
|
2019-06-21 22:43:59 -05:00
|
|
|
log "Waiting for programs to exit"
|
|
|
|
wait
|
2019-04-27 00:01:25 -05:00
|
|
|
exit 0
|
|
|
|
}
|
2019-06-21 08:18:22 -05:00
|
|
|
step_logout() {
|
|
|
|
log "Logging out"
|
2019-06-21 22:19:38 -05:00
|
|
|
if has loginctl; then
|
2019-06-21 08:18:22 -05:00
|
|
|
# Use loginctl if possible
|
2019-06-21 19:09:46 -05:00
|
|
|
if [ -n "$_sessionid" ]; then
|
|
|
|
loginctl terminate-session "$_sessionid"
|
2019-06-21 08:18:22 -05:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
# Otherwise just brute it
|
|
|
|
kill $(jobs -p)
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
2019-04-27 00:01:25 -05:00
|
|
|
|
|
|
|
# Main
|
|
|
|
main() {
|
|
|
|
while getopts ":dgh" opt; do
|
|
|
|
case $opt in
|
|
|
|
d)
|
2019-06-22 02:16:47 -05:00
|
|
|
_dryrun=1
|
2019-04-27 00:01:25 -05:00
|
|
|
;;
|
|
|
|
g)
|
|
|
|
step_generate
|
|
|
|
exit $?
|
|
|
|
;;
|
|
|
|
h)
|
|
|
|
step_printhelp
|
|
|
|
exit $?
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
err "Unrecognized argument: \"$OPTARG\"" 50
|
|
|
|
;;
|
|
|
|
:)
|
|
|
|
err "Invalid option: \"$OPTARG\"" 51
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2019-06-22 02:16:47 -05:00
|
|
|
[ -n "$_dryrun" ] && log "Performing a dry run"
|
2019-06-21 17:32:28 -05:00
|
|
|
step_check
|
2019-06-21 17:01:21 -05:00
|
|
|
step_preexecute
|
2019-04-27 00:01:25 -05:00
|
|
|
step_execute
|
2019-06-21 21:40:43 -05:00
|
|
|
step_postexecute
|
2019-04-27 00:01:25 -05:00
|
|
|
step_wait
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|
|
|
|
|