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