Remove g_ prefix on globals, replace it with _

This commit is contained in:
Salt 2019-06-21 17:18:32 -05:00
parent 311f83bf25
commit 0c599a72f3

View File

@ -8,9 +8,9 @@
# #
# "Globals" # "Globals"
g_name="firestarter" _name="firestarter"
g_configdir="${XDG_CONFIG_HOME:-$HOME/.config}/$g_name" _configdir="${XDG_CONFIG_HOME:-$HOME/.config}/$_name"
g_logdir="${XDG_DATA_HOME:-$HOME/.local/share}/$g_name/logs" _logdir="${XDG_DATA_HOME:-$HOME/.local/share}/$_name/logs"
# Basic functions # Basic functions
print() { print() {
@ -23,14 +23,14 @@ log() {
# Write a message to STDOUT # Write a message to STDOUT
[ -z "$1" ] && return 1 [ -z "$1" ] && return 1
printf "%s log: %s\\n" \ printf "%s log: %s\\n" \
"$g_name" \ "$_name" \
"$1" >&1 "$1" >&1
} }
err() { err() {
# Write a message to STDERR, also exit if arg 2 is specified # Write a message to STDERR, also exit if arg 2 is specified
[ -z "$1" ] && return 1 [ -z "$1" ] && return 1
printf "%s err: %s\\n" \ printf "%s err: %s\\n" \
"$g_name" \ "$_name" \
"$1" >&2 "$1" >&2
[ -z "$2" ] && return 0 [ -z "$2" ] && return 0
if ! [ "$2" -ge "0" ] > /dev/null 2>&1; then if ! [ "$2" -ge "0" ] > /dev/null 2>&1; then
@ -57,17 +57,19 @@ startfile() {
# Steps in execution # Steps in execution
step_generate() { step_generate() {
log "Creating default config setup in \"$g_configdir\"" log "Creating default config setup in \"$_configdir\""
log "See firestarter -h for more information" log "See firestarter -h for more information"
# Audio daemon # Audio daemon
cat << EOF > "$g_configdir/audio-daemon" cat << EOF > "$_configdir/audio-daemon"
command -v pulseaudio command -v pulseaudio
pulseaudio pulseaudio
EOF EOF
# Information bars # Information bars
cat << EOF > "$g_configdir/bar" cat << EOF > "$_configdir/bar"
command -v tint2 command -v tint2
tint2 tint2
command -v polybar && [ -f "$HOME/.config/polybar/launch.sh" ]
"$HOME/.config/polybar/launch.sh"
command -v lxpanel command -v lxpanel
lxpanel lxpanel
command -v lxqt-panel command -v lxqt-panel
@ -78,14 +80,14 @@ command -v xfce4-panel
xfce4-panel xfce4-panel
EOF EOF
# Blue light filter # Blue light filter
cat << EOF > "$g_configdir/blue-light-filter" cat << EOF > "$_configdir/blue-light-filter"
command -v redshift-gtk command -v redshift-gtk
redshift-gtk redshift-gtk
command -v redshift command -v redshift
redshift redshift
EOF EOF
# Compositor # Compositor
cat << EOF > "$g_configdir/compositor" cat << EOF > "$_configdir/compositor"
[ -z "\$DISPLAY" ] [ -z "\$DISPLAY" ]
: :
command -v unagi command -v unagi
@ -96,7 +98,7 @@ command -v xcompmgr
xcompmgr xcompmgr
EOF EOF
# Polkit authentication agents # Polkit authentication agents
cat << EOF > "$g_configdir/polkit-agent" cat << EOF > "$_configdir/polkit-agent"
command -v lxqt-policykit-agent command -v lxqt-policykit-agent
lxqt-policykit-agent lxqt-policykit-agent
command -v lxpolkit command -v lxpolkit
@ -107,14 +109,14 @@ command -v polkit-efl-authentication-agent-1
polkit-efl-authentication-agent-1 polkit-efl-authentication-agent-1
EOF EOF
# Hotkey daemon # Hotkey daemon
cat << EOF > "$g_configdir/hotkey-daemon" cat << EOF > "$_configdir/hotkey-daemon"
[ -z "\$DISPLAY" ] [ -z "\$DISPLAY" ]
: :
command -v sxhkd command -v sxhkd
sxhkd sxhkd
EOF EOF
# Notification daemon # Notification daemon
cat << EOF > "$g_configdir/notification-daemon" cat << EOF > "$_configdir/notification-daemon"
[ -z "\$DISPLAY" ] [ -z "\$DISPLAY" ]
: :
command -v dunst command -v dunst
@ -123,7 +125,7 @@ command -v lxqt-notificationd
notificationd notificationd
EOF EOF
# Power daemons # Power daemons
cat << EOF > "$g_configdir/power-daemon" cat << EOF > "$_configdir/power-daemon"
command -v batterymon command -v batterymon
batterymon batterymon
command -v cbatticon command -v cbatticon
@ -139,12 +141,12 @@ gnome-power-manager
EOF 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 > "$g_configdir/runner" cat << EOF > "$_configdir/runner"
command -v krunner command -v krunner
krunner krunner
EOF EOF
# Settings daemons # Settings daemons
cat << EOF > "$g_configdir/settings-daemon" cat << EOF > "$_configdir/settings-daemon"
command -v xsettingsd command -v xsettingsd
xsettingsd xsettingsd
command -v xsettings-kde command -v xsettings-kde
@ -157,14 +159,14 @@ command -v gnome-settings-daemon
gnome-settings-daemon gnome-settings-daemon
EOF EOF
# X system statistics glances # X system statistics glances
cat << EOF > "$g_configdir/stat-glances" cat << EOF > "$_configdir/stat-glances"
[ -z "\$DISPLAY" ] [ -z "\$DISPLAY" ]
: :
command -v conky && [ -f "\${XDG_CONFIG_HOME:-$HOME/.config}/conky/conky.conf" ] command -v conky && [ -f "\${XDG_CONFIG_HOME:-$HOME/.config}/conky/conky.conf" ]
conky conky
EOF EOF
# Window managers # Window managers
cat << EOF > "$g_configdir/wm" cat << EOF > "$_configdir/wm"
[ -z "\$DISPLAY" ] [ -z "\$DISPLAY" ]
: :
command -v 2bwm command -v 2bwm
@ -229,7 +231,7 @@ command -v tinywm
tinywm tinywm
EOF EOF
# XDG autostarter # XDG autostarter
cat << EOF > "$g_configdir/xdg-autostart" cat << EOF > "$_configdir/xdg-autostart"
command -v dex command -v dex
dex -a dex -a
command -v fbautostart command -v fbautostart
@ -331,19 +333,19 @@ step_preexecute() {
fi fi
} }
step_execute() { step_execute() {
if ! [ -d "$g_configdir" ]; then if ! [ -d "$_configdir" ]; then
if ! mkdir -p "$g_configdir" > /dev/null 2>&1; then if ! mkdir -p "$_configdir" > /dev/null 2>&1; then
err "Failed to create configuration directory \"$g_configdir\"" 52 err "Failed to create configuration directory \"$_configdir\"" 52
fi fi
fi fi
if [ -n "$FS_NOLOG" ]; then if [ -n "$FS_NOLOG" ]; then
log "No logs will be created per FS_NOLOG" log "No logs will be created per FS_NOLOG"
elif ! [ -d "$g_logdir" ]; then elif ! [ -d "$_logdir" ]; then
if ! mkdir -p "$g_logdir" > /dev/null 2>&1; then if ! mkdir -p "$_logdir" > /dev/null 2>&1; then
err "Failed to create log directory \"$g_logdir\"" 53 err "Failed to create log directory \"$_logdir\"" 53
fi fi
fi fi
for file in "$g_configdir"/*; do for file in "$_configdir"/*; do
if ! [ -f "$file" ]; then if ! [ -f "$file" ]; then
log "No configuration files found; generating defaults" log "No configuration files found; generating defaults"
step_generate step_generate
@ -351,7 +353,7 @@ step_execute() {
break break
fi fi
local filename="$(basename -- "$file")" local filename="$(basename -- "$file")"
local logfile="$g_logdir/$filename" local logfile="$_logdir/$filename"
[ -n "$FS_NOLOG" ] && logfile="/dev/null" [ -n "$FS_NOLOG" ] && logfile="/dev/null"
# 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