2020-05-15 03:15:18 -05:00
|
|
|
#! /bin/bash
|
|
|
|
#
|
|
|
|
# firestarter
|
|
|
|
# A desktop environment startup script
|
|
|
|
# Copyright (C) 2019 Vintage Salt <rehashedsalt@cock.li>
|
|
|
|
#
|
|
|
|
# Distributed under terms of the MIT license.
|
|
|
|
#
|
|
|
|
|
2020-05-15 03:21:28 -05:00
|
|
|
# "Globals"
|
|
|
|
_name="firestarter"
|
|
|
|
_configdir="${XDG_CONFIG_HOME:-$HOME/.config}/$_name"
|
|
|
|
_logdir="${XDG_DATA_HOME:-$HOME/.local/share}/$_name/logs"
|
|
|
|
_firestarterrc="$HOME/.firestarterrc"
|
|
|
|
_sessionid="$(< /proc/self/sessionid)"
|
|
|
|
# Dummy fd for read sleeping
|
|
|
|
exec 1023<> <(:)
|
2020-05-15 03:15:18 -05:00
|
|
|
|
2020-05-15 03:21:28 -05:00
|
|
|
# Basic functions
|
|
|
|
print() {
|
|
|
|
# Write a message to STDOUT without a name attached
|
|
|
|
# 1: That message
|
2020-05-15 03:15:18 -05:00
|
|
|
[ -z "$1" ] && return 1
|
2020-05-15 03:21:28 -05:00
|
|
|
printf "%s\\n" \
|
|
|
|
"$1"
|
2020-05-15 03:15:18 -05:00
|
|
|
}
|
2020-05-15 03:21:28 -05:00
|
|
|
log() {
|
|
|
|
# Write a message to STDOUT
|
|
|
|
# 1: That message
|
2020-05-15 03:15:18 -05:00
|
|
|
[ -z "$1" ] && return 1
|
2020-05-15 03:21:28 -05:00
|
|
|
printf "%s log: %s\\n" \
|
|
|
|
"$_name" \
|
|
|
|
"$1" >&1
|
2020-05-15 03:15:18 -05:00
|
|
|
}
|
2020-05-15 03:21:28 -05:00
|
|
|
err() {
|
|
|
|
# Write a message to STDERR, also exit if arg 2 is specified
|
|
|
|
# 1: That message
|
|
|
|
# 2: An optional exit code (will only exit if provided)
|
2020-05-15 03:15:18 -05:00
|
|
|
[ -z "$1" ] && return 1
|
2020-05-15 03:21:28 -05:00
|
|
|
printf "%s err: %s\\n" \
|
|
|
|
"$_name" \
|
|
|
|
"$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
|
2020-05-15 03:15:18 -05:00
|
|
|
else
|
2020-05-15 03:21:28 -05:00
|
|
|
exit "$2"
|
2020-05-15 03:15:18 -05:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
has() {
|
2020-05-15 03:21:28 -05:00
|
|
|
# See if a program exists in $PATH
|
|
|
|
# 1: A program
|
|
|
|
[ -z "$1" ] && return 1
|
|
|
|
command -v "$1" > /dev/null 2>&1
|
2020-05-15 03:15:18 -05:00
|
|
|
}
|
|
|
|
gettarget() {
|
2020-05-15 03:21:28 -05:00
|
|
|
# Parse a defaults file to get the target program
|
|
|
|
# 1: A defaults file
|
2020-05-15 03:15:18 -05:00
|
|
|
[ -z "$1" ] && return 1
|
|
|
|
[ -r "$1" ] || return 1
|
2020-05-15 03:21:28 -05:00
|
|
|
# Every odd line is the check line
|
|
|
|
# Every even one is the exec line
|
2020-05-15 03:15:18 -05:00
|
|
|
local firstline
|
|
|
|
while read -r checkline; do
|
|
|
|
if [ -z "$firstline" ]; then
|
2020-05-15 03:18:36 -05:00
|
|
|
if [ "$checkline" = "#.fsdefaults" ]; then
|
2020-05-15 03:15:18 -05:00
|
|
|
firstline=1
|
|
|
|
continue
|
|
|
|
else
|
|
|
|
return 50
|
|
|
|
fi
|
|
|
|
fi
|
2020-05-15 03:21:28 -05:00
|
|
|
if [ "${checkline#"#"}" != "$checkline" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
2020-05-15 03:15:18 -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
|
|
|
|
}
|
2020-05-15 03:21:28 -05:00
|
|
|
|
|
|
|
# Steps in execution
|
|
|
|
step_generate() {
|
|
|
|
log "Creating default config setup in \"$_configdir\""
|
2020-05-15 03:15:18 -05:00
|
|
|
log "See firestarter -h for more information"
|
|
|
|
# Audio daemon
|
2020-05-15 03:21:28 -05:00
|
|
|
cat << EOF > "$_configdir/audio-daemon"
|
2020-05-15 03:15:18 -05:00
|
|
|
#.fsdefaults
|
|
|
|
command -v pulseaudio
|
|
|
|
pulseaudio
|
|
|
|
EOF
|
|
|
|
# Information bars
|
2020-05-15 03:21:28 -05:00
|
|
|
cat << EOF > "$_configdir/bar"
|
2020-05-15 03:15:18 -05:00
|
|
|
#.fsdefaults
|
|
|
|
command -v polybar && [ -r "$HOME/.config/polybar/launch.sh" ]
|
|
|
|
"$HOME/.config/polybar/launch.sh"
|
|
|
|
command -v tint2
|
|
|
|
tint2
|
|
|
|
command -v lxpanel
|
|
|
|
lxpanel
|
|
|
|
command -v lxqt-panel
|
|
|
|
lxqt-panel
|
|
|
|
command -v mate-panel
|
|
|
|
mate-panel
|
|
|
|
command -v xfce4-panel
|
|
|
|
xfce4-panel
|
|
|
|
EOF
|
|
|
|
# Blue light filter
|
2020-05-15 03:21:28 -05:00
|
|
|
cat << EOF > "$_configdir/blue-light-filter"
|
2020-05-15 03:15:18 -05:00
|
|
|
#.fsdefaults
|
|
|
|
command -v redshift-gtk
|
|
|
|
redshift-gtk
|
|
|
|
command -v redshift
|
|
|
|
redshift
|
|
|
|
EOF
|
|
|
|
# Compositor
|
2020-05-15 03:21:28 -05:00
|
|
|
cat << EOF > "$_configdir/compositor"
|
2020-05-15 03:15:18 -05:00
|
|
|
#.fsdefaults
|
|
|
|
[ -z "\$DISPLAY" ]
|
|
|
|
:
|
|
|
|
command -v unagi
|
|
|
|
unagi
|
|
|
|
command -v compton
|
|
|
|
compton
|
|
|
|
command -v xcompmgr
|
|
|
|
xcompmgr
|
|
|
|
EOF
|
|
|
|
# Polkit authentication agents
|
2020-05-15 03:21:28 -05:00
|
|
|
cat << EOF > "$_configdir/polkit-agent"
|
2020-05-15 03:15:18 -05:00
|
|
|
#.fsdefaults
|
|
|
|
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
|
|
|
|
[ -x "/usr/lib/ts-polkitagent" ]
|
|
|
|
/usr/lib/ts-polkitagent
|
|
|
|
[ -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
|
|
|
|
# Debian locations
|
|
|
|
# On generation time, your architecture is filled in here
|
|
|
|
[ -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/$(uname -m)-linux-gnu/libexec/polkit-kde-authentication-agent-1" ]
|
|
|
|
"/usr/lib/$(uname -m)-linux-gnu/libexec/polkit-kde-authentication-agent-1"
|
|
|
|
# OpenSuSE locations
|
|
|
|
[ -x "/usr/lib/polkit-mate/polkit-mate-authentication-agent-1" ]
|
|
|
|
"/usr/lib/polkit-mate/polkit-mate-authentication-agent-1"
|
|
|
|
[ -x "/usr/lib/polkit-kde-authentication-agent-1" ]
|
|
|
|
"/usr/lib/polkit-kde-authentication-agent-1"
|
|
|
|
# Arch locations
|
|
|
|
[ -x "/usr/lib/mate-polkit/polkit-mate-authentication-agent-1" ]
|
|
|
|
/usr/lib/mate-polkit/polkit-mate-authentication-agent-1
|
|
|
|
[ -x "/usr/lib/polkit-kde-authentication-agent-1" ]
|
|
|
|
/usr/lib/polkit-kde-authentication-agent-1
|
|
|
|
# Fedora locations
|
|
|
|
[ -x "/usr/libexec/xfce-polkit" ]
|
|
|
|
/usr/libexec/xfce-polkit
|
|
|
|
[ -x "/usr/libexec/lxqt-policykit-agent" ]
|
|
|
|
/usr/libexec/lxqt-policykit-agent
|
|
|
|
[ -x "/usr/libexec/polkit-mate-authentication-agent-1" ]
|
|
|
|
/usr/libexec/polkit-mate-authentication-agent-1
|
|
|
|
[ -x "/usr/libexec/kf5/polkit-kde-authentication-agent-1" ]
|
|
|
|
/usr/libexec/kf5/polkit-kde-authentication-agent-1
|
|
|
|
[ -x "/usr/libexec/polkit-gnome-authentication-agent-1" ]
|
|
|
|
/usr/libexec/polkit-gnome-authentication-agent-1
|
|
|
|
EOF
|
|
|
|
# Hotkey daemon
|
2020-05-15 03:21:28 -05:00
|
|
|
cat << EOF > "$_configdir/hotkey-daemon"
|
2020-05-15 03:15:18 -05:00
|
|
|
#.fsdefaults
|
|
|
|
[ -z "\$DISPLAY" ]
|
|
|
|
:
|
|
|
|
command -v sxhkd
|
|
|
|
sxhkd
|
|
|
|
command -v lxqt-globalkeysd
|
|
|
|
lxqt-globalkeysd
|
|
|
|
EOF
|
|
|
|
# Network daemon
|
2020-05-15 03:21:28 -05:00
|
|
|
cat << EOF > "$_configdir/network-daemon"
|
2020-05-15 03:15:18 -05:00
|
|
|
#.fsdefaults
|
|
|
|
command -v nm-applet
|
|
|
|
nm-applet
|
|
|
|
EOF
|
|
|
|
# Notification daemon
|
2020-05-15 03:21:28 -05:00
|
|
|
cat << EOF > "$_configdir/notification-daemon"
|
2020-05-15 03:15:18 -05:00
|
|
|
#.fsdefaults
|
|
|
|
[ -z "\$DISPLAY" ]
|
|
|
|
:
|
|
|
|
command -v dunst
|
|
|
|
dunst
|
|
|
|
command -v lxqt-notificationd
|
|
|
|
notificationd
|
|
|
|
EOF
|
|
|
|
# Power daemons
|
2020-05-15 03:21:28 -05:00
|
|
|
cat << EOF > "$_configdir/power-daemon"
|
2020-05-15 03:15:18 -05:00
|
|
|
#.fsdefaults
|
|
|
|
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
|
|
|
|
EOF
|
|
|
|
# Runners
|
|
|
|
# Note that rofi is not a daemon and is not included here
|
2020-05-15 03:21:28 -05:00
|
|
|
cat << EOF > "$_configdir/runner"
|
2020-05-15 03:15:18 -05:00
|
|
|
#.fsdefaults
|
|
|
|
command -v krunner
|
|
|
|
krunner
|
|
|
|
EOF
|
|
|
|
# Settings daemons
|
2020-05-15 03:21:28 -05:00
|
|
|
cat << EOF > "$_configdir/settings-daemon"
|
2020-05-15 03:15:18 -05:00
|
|
|
#.fsdefaults
|
|
|
|
command -v xsettingsd
|
|
|
|
xsettingsd
|
|
|
|
command -v xsettings-kde
|
|
|
|
xsettingskde
|
|
|
|
command -v lxsettings-daemon
|
|
|
|
lxsettings-daemon
|
|
|
|
command -v xfsettingsd
|
|
|
|
xfsettingsd
|
|
|
|
command -v mate-settings-daemon
|
|
|
|
mate-settings-daemon
|
|
|
|
command -v gnome-settings-daemon
|
|
|
|
gnome-settings-daemon
|
|
|
|
EOF
|
|
|
|
# System statistics glances
|
2020-05-15 03:21:28 -05:00
|
|
|
cat << EOF > "$_configdir/stat-glances"
|
2020-05-15 03:15:18 -05:00
|
|
|
#.fsdefaults
|
|
|
|
[ -z "\$DISPLAY" ]
|
|
|
|
:
|
|
|
|
# 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
|
|
|
|
command -v conky && [ -r "\${XDG_CONFIG_HOME:-$HOME/.config}/conky/conky.conf" ]
|
|
|
|
sleep 5 && conky
|
|
|
|
EOF
|
|
|
|
# Wallpaper setters
|
2020-05-15 03:21:28 -05:00
|
|
|
cat << EOF > "$_configdir/wallpaper"
|
2020-05-15 03:15:18 -05:00
|
|
|
#.fsdefaults
|
|
|
|
[ -z "\$DISPLAY" ]
|
|
|
|
:
|
|
|
|
command -v feh && [ -r "$HOME/.fehbg" ]
|
|
|
|
~/.fehbg
|
|
|
|
command -v nitrogen
|
|
|
|
nitrogen --restore
|
|
|
|
EOF
|
|
|
|
# Window managers
|
2020-05-15 03:21:28 -05:00
|
|
|
cat << EOF > "$_configdir/wm"
|
2020-05-15 03:15:18 -05:00
|
|
|
#.fsdefaults
|
|
|
|
[ -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
|
|
|
|
}
|
2020-05-15 03:21:28 -05:00
|
|
|
step_printhelp() {
|
|
|
|
cat << EOF
|
|
|
|
Usage: $(basename -- "$0") [OPTION...]
|
|
|
|
Start or generate a desktop environment configuration
|
|
|
|
|
|
|
|
-h Show this help text
|
|
|
|
-g Generate a default configuration. This will clobber
|
|
|
|
-d Perform a dry run. This will print the results of all decisions
|
|
|
|
without executing them.
|
|
|
|
|
|
|
|
Additionally, $(basename -- "$0") responds to the following environment variables:
|
|
|
|
|
|
|
|
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.
|
|
|
|
FS_NOLOG If nonempty, create no log files
|
|
|
|
FS_NOWAITWM If nonempty, skip waiting on the WM to initialize
|
|
|
|
|
|
|
|
Copyright (c) 2019 rehashedsalt@cock.li
|
|
|
|
Licensed under the MIT License
|
|
|
|
https://gitlab.com/rehashedsalt/firestarter
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
step_check() {
|
|
|
|
if [ -z "$_dryrun" ] && [ -z "$_generate" ]; then
|
|
|
|
for pid in $(pgrep firestarter); do
|
|
|
|
# Skip invalid PIDs
|
|
|
|
! [ -d "/proc/$pid" ] && continue
|
|
|
|
# If it's not our session then who cares
|
|
|
|
[ "$_sessionid" != "$(< "/proc/$pid/sessionid")" ] && continue
|
|
|
|
if [ "$pid" != "$BASHPID" ]; then
|
|
|
|
err "Firestarter is already running: $pid" 40
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
if ! [ -d "$HOME" ] || ! [ -r "$HOME" ]; then
|
|
|
|
err "Inaccessible home directory: \"$HOME\"" 54
|
|
|
|
fi
|
|
|
|
if ! [ -d "$_configdir" ]; then
|
|
|
|
if ! mkdir -p "$_configdir" > /dev/null 2>&1; then
|
|
|
|
err "Failed to create configuration directory: \"$_configdir\"" 52
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
2020-05-15 03:15:18 -05:00
|
|
|
step_preexecute() {
|
|
|
|
# Special things that can't use simple configuration files
|
2020-05-15 03:21:28 -05:00
|
|
|
[ -n "$_dryrun" ] && return 0
|
|
|
|
|
|
|
|
# Xsessionrc
|
|
|
|
[ -r "$HOME/.xsessionrc" ] && source "$HOME/.xsessionrc"
|
|
|
|
|
|
|
|
# Exports
|
2020-05-15 03:15:18 -05:00
|
|
|
export XDG_CURRENT_DESKTOP="${XDG_CURRENT_DESKTOP:-firestarter}"
|
2020-05-15 03:21:28 -05:00
|
|
|
|
2020-05-15 03:15:18 -05:00
|
|
|
# dbus
|
|
|
|
if \
|
|
|
|
[ -z "$DBUS_SESSION_BUS_ADDRESS" ] && \
|
|
|
|
[ -n "$XDG_RUNTIME_DIR" ] && \
|
|
|
|
[ "$XDG_RUNTIME_DIR" = "/run/user/$(id -u)" ] && \
|
|
|
|
[ -S "$XDG_RUNTIME_DIR/bus" ]; then
|
2020-05-15 03:21:28 -05:00
|
|
|
# We already have a bus started, use it
|
2020-05-15 03:15:18 -05:00
|
|
|
export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"
|
|
|
|
hasdbus=1
|
|
|
|
elif \
|
|
|
|
[ -z "$DBUS_SESSION_BUS_ADDRESS" ] && \
|
|
|
|
has dbus-launch; then
|
2020-05-15 03:21:28 -05:00
|
|
|
# We have dbus but haven't started up a bus yet
|
|
|
|
eval "$(dbus-launch --exit-with-session --sh-syntax)"
|
2020-05-15 03:15:18 -05:00
|
|
|
hasdbus=1
|
|
|
|
else
|
2020-05-15 03:21:28 -05:00
|
|
|
log "Did not start dbus; some applications may misbehave"
|
2020-05-15 03:15:18 -05:00
|
|
|
fi
|
|
|
|
if [ -n "$hasdbus" ]; then
|
2020-05-15 03:21:28 -05:00
|
|
|
if has dbus-update-activation-environment; then
|
|
|
|
dbus-update-activation-environment --verbose --systemd --all > /dev/null 2>&1
|
|
|
|
fi
|
2020-05-15 03:15:18 -05:00
|
|
|
fi
|
|
|
|
unset hasdbus
|
2020-05-15 03:21:28 -05:00
|
|
|
|
2020-05-15 03:15:18 -05:00
|
|
|
# kcminit/Qt settings
|
|
|
|
if has kcminit; then
|
|
|
|
log "Initializing KDE Control Module settings"
|
2020-05-15 03:21:28 -05:00
|
|
|
kcminit > /dev/null 2>&1
|
2020-05-15 03:15:18 -05:00
|
|
|
export XDG_CURRENT_DESKTOP="KDE"
|
|
|
|
elif has qt5ct; then
|
2020-05-15 03:21:28 -05:00
|
|
|
log "Integrating qt5ct"
|
2020-05-15 03:15:18 -05:00
|
|
|
if [ -z "$QT_QPA_PLATFORMTHEME" ]; then
|
|
|
|
export QT_QPA_PLATFORMTHEME="qt5ct"
|
2020-05-15 03:21:28 -05:00
|
|
|
log "Exporting QT_QPA_PLATFORMTHEME as \"$QT_QPA_PLATFORMTHEME\""
|
2020-05-15 03:15:18 -05:00
|
|
|
else
|
2020-05-15 03:21:28 -05:00
|
|
|
log "Using existing theme setting \"$QT_QPA_PLATFORMTHEME\""
|
2020-05-15 03:15:18 -05:00
|
|
|
fi
|
|
|
|
if [ -z "$QT_AUTO_SCREEN_SCALE_FACTOR" ]; then
|
|
|
|
export QT_AUTO_SCREEN_SCALE_FACTOR="0"
|
2020-05-15 03:21:28 -05:00
|
|
|
log "Exporting QT_AUTO_SCREEN_SCALE_FACTOR as $QT_AUTO_SCREEN_SCALE_FACTOR"
|
2020-05-15 03:15:18 -05:00
|
|
|
else
|
2020-05-15 03:21:28 -05:00
|
|
|
log "Using existing scale setting \"$QT_AUTO_SCREEN_SCALE_FACTOR\""
|
2020-05-15 03:15:18 -05:00
|
|
|
fi
|
|
|
|
fi
|
2020-05-15 03:21:28 -05:00
|
|
|
|
2020-05-15 03:15:18 -05:00
|
|
|
# xhost
|
|
|
|
if has xhost; then
|
2020-05-15 03:21:28 -05:00
|
|
|
if xhost +si:localuser:"$(id -un)" > /dev/null 2>&1; then
|
|
|
|
log "Session can be accessed in other sessions by this user"
|
2020-05-15 03:15:18 -05:00
|
|
|
else
|
2020-05-15 03:21:28 -05:00
|
|
|
log "Failed to open session up via xhost"
|
2020-05-15 03:15:18 -05:00
|
|
|
fi
|
|
|
|
fi
|
2020-05-15 03:21:28 -05:00
|
|
|
|
2020-05-15 03:15:18 -05:00
|
|
|
# xresources
|
|
|
|
if [ -n "$DISPLAY" ] && has xrdb && [ -r "$HOME/.Xresources" ]; then
|
2020-05-15 03:21:28 -05:00
|
|
|
if xrdb "$HOME/.Xresources" > /dev/null 2>&1; then
|
2020-05-15 03:15:18 -05:00
|
|
|
log "Loaded in .Xresources"
|
|
|
|
else
|
2020-05-15 03:21:28 -05:00
|
|
|
log "Failed to load .Xresources"
|
2020-05-15 03:15:18 -05:00
|
|
|
fi
|
|
|
|
fi
|
2020-05-15 03:21:28 -05:00
|
|
|
|
2020-05-15 03:15:18 -05:00
|
|
|
# xset
|
|
|
|
if has xset; then
|
|
|
|
log "Disabling bell"
|
|
|
|
xset -b
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
step_execute() {
|
2020-05-15 03:21:28 -05:00
|
|
|
# Ensure we can log if we have to
|
|
|
|
if [ -n "$FS_NOLOG" ]; then
|
|
|
|
log "No logs will be created per FS_NOLOG"
|
|
|
|
elif ! [ -d "$_logdir" ]; then
|
|
|
|
if ! mkdir -p "$_logdir" > /dev/null 2>&1; then
|
|
|
|
err "Failed to create log directory: \"$_logdir\"" 53
|
2020-05-15 03:15:18 -05:00
|
|
|
fi
|
|
|
|
fi
|
2020-05-15 03:21:28 -05:00
|
|
|
# Parse configs
|
|
|
|
for file in "$_configdir"/*; do
|
2020-05-15 03:15:18 -05:00
|
|
|
if ! [ -e "$file" ]; then
|
|
|
|
log "No configuration files found; generating defaults"
|
2020-05-15 03:21:28 -05:00
|
|
|
step_generate
|
2020-05-15 03:15:18 -05:00
|
|
|
step_execute
|
2020-05-15 03:21:28 -05:00
|
|
|
break
|
2020-05-15 03:15:18 -05:00
|
|
|
fi
|
|
|
|
local filename="$(basename -- "$file")"
|
2020-05-15 03:21:28 -05:00
|
|
|
local logfile="$_logdir/$filename"
|
|
|
|
[ -n "$FS_NOLOG" ] && logfile="/dev/null"
|
2020-05-15 03:15:18 -05:00
|
|
|
if gettarget "$file"; then
|
|
|
|
# It's a defaults file with a selected target
|
|
|
|
target="$_return"
|
2020-05-15 03:21:28 -05:00
|
|
|
log "Found target for \"$filename\": \"$target\""
|
|
|
|
if [ -z "$_dryrun" ]; then
|
|
|
|
if [ -f "$logfile" ]; then
|
|
|
|
[ -f "$logfile.old" ] && rm "$logfile.old"
|
|
|
|
mv "$logfile" "$logfile.old"
|
|
|
|
fi
|
|
|
|
bash -c "$target" > "$logfile" 2>&1 &
|
2020-05-15 03:15:18 -05:00
|
|
|
fi
|
|
|
|
elif [ $? = 50 ] && [ -x "$file" ]; then
|
2020-05-15 03:21:28 -05:00
|
|
|
# It's a shell script or something
|
|
|
|
log "Executing file straight out: \"$filename\""
|
|
|
|
if [ -z "$_dryrun" ]; then
|
|
|
|
"$file" > "$logfile" 2>&1 &
|
|
|
|
fi
|
2020-05-15 03:15:18 -05:00
|
|
|
else
|
2020-05-15 03:21:28 -05:00
|
|
|
err "Could not execute file: \"$filename\""
|
2020-05-15 03:15:18 -05:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
step_postexecute() {
|
|
|
|
# Wait for the WM to initialize, if one was found and we have the tools
|
2020-05-15 03:21:28 -05:00
|
|
|
if [ -z "$FS_NOWAITWM" ] && gettarget "$_configdir/wm" && has xprop && has grep; then
|
2020-05-15 03:15:18 -05:00
|
|
|
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
|
2020-05-15 03:21:28 -05:00
|
|
|
log "WM has intiailized, _NET_WM_NAME atom reads: $line"
|
2020-05-15 03:15:18 -05:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
read -t 1 -u 1023
|
|
|
|
done
|
|
|
|
fi
|
2020-05-15 03:21:28 -05:00
|
|
|
# Dumb Polybar workaround
|
2020-05-15 03:15:18 -05:00
|
|
|
killall polybar -SIGUSR1
|
2020-05-15 03:21:28 -05:00
|
|
|
# Execute a user script if it exists
|
|
|
|
if [ -r "$_firestarterrc" ] && [ -z "$_dryrun" ]; then
|
|
|
|
log "Executing .firestarterrc"
|
|
|
|
"$_firestarterrc"
|
2020-05-15 03:15:18 -05:00
|
|
|
fi
|
|
|
|
# Start XDG autostarters, if they exist
|
2020-05-15 03:21:28 -05:00
|
|
|
if [ -z "$_dryrun" ]; then
|
2020-05-15 03:15:18 -05:00
|
|
|
if has dex; then
|
2020-05-15 03:21:28 -05:00
|
|
|
dex -a > /dev/null 2>&1
|
2020-05-15 03:15:18 -05:00
|
|
|
elif has fbautostart; then
|
|
|
|
fbautostart > /dev/null 2>&1
|
|
|
|
elif has xdg-autostart; then
|
|
|
|
xdg-autostart ${XDG_CURRENT_DESKTOP:-firestarter}
|
|
|
|
else
|
2020-05-15 03:21:28 -05:00
|
|
|
err "Could not find an XDG autostarter"
|
2020-05-15 03:15:18 -05:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
step_wait() {
|
2020-05-15 03:21:28 -05:00
|
|
|
[ -n "$_dryrun" ] && exit 0
|
2020-05-15 03:15:18 -05:00
|
|
|
trap step_logout EXIT
|
2020-05-15 03:21:28 -05:00
|
|
|
if [ -n "$FS_DIEONWM" ] && gettarget "$_configdir/wm" && has readlink && has "$_return"; then
|
2020-05-15 03:15:18 -05:00
|
|
|
target="$(command -v "$_return")"
|
|
|
|
for job in $(jobs -p); do
|
|
|
|
if [ "$target" = "$(readlink /proc/$job/exe)" ]; then
|
|
|
|
log "Waiting for WM to exit: \"$_return\""
|
|
|
|
wait "$job"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
done
|
2020-05-15 03:21:28 -05:00
|
|
|
err "Could not find WM: \"$target\""
|
2020-05-15 03:15:18 -05:00
|
|
|
fi
|
|
|
|
log "Waiting for programs to exit"
|
|
|
|
wait
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
step_logout() {
|
|
|
|
log "Logging out"
|
|
|
|
if has loginctl; then
|
|
|
|
# Use loginctl if possible
|
|
|
|
if [ -n "$_sessionid" ]; then
|
|
|
|
loginctl terminate-session "$_sessionid"
|
|
|
|
fi
|
|
|
|
else
|
2020-05-15 03:21:28 -05:00
|
|
|
# Otherwise just brute it
|
2020-05-15 03:15:18 -05:00
|
|
|
kill $(jobs -p)
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# Main
|
|
|
|
main() {
|
2020-05-15 03:21:28 -05:00
|
|
|
while getopts ":dgh" opt; do
|
|
|
|
case $opt in
|
|
|
|
d)
|
|
|
|
_dryrun=1
|
|
|
|
;;
|
|
|
|
g)
|
|
|
|
_generate=1
|
|
|
|
;;
|
|
|
|
h)
|
|
|
|
step_printhelp
|
|
|
|
exit $?
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
err "Unrecognized argument: \"$OPTARG\"" 50
|
|
|
|
;;
|
|
|
|
:)
|
|
|
|
err "Invalid option: \"$OPTARG\"" 51
|
|
|
|
;;
|
|
|
|
esac
|
2020-05-15 03:15:18 -05:00
|
|
|
done
|
2020-05-15 03:21:28 -05:00
|
|
|
step_check
|
|
|
|
if [ -n "$_generate" ]; then
|
|
|
|
step_generate
|
|
|
|
else
|
|
|
|
[ -n "$_dryrun" ] && log "Performing a dry run"
|
|
|
|
step_preexecute
|
|
|
|
step_execute
|
|
|
|
step_postexecute
|
|
|
|
step_wait
|
2020-05-15 03:15:18 -05:00
|
|
|
fi
|
2020-05-15 03:21:28 -05:00
|
|
|
return 0
|
2020-05-15 03:15:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|
|
|
|
|