Review shell scripts

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-01-22 14:07:22 +00:00
parent 8f94687b2b
commit bcbda92c46
27 changed files with 273 additions and 259 deletions

View File

@@ -1,5 +1,5 @@
STEAM="${HOME}/.local/share/Steam/steamapps/common"
GAMES="${HOME}/Games"
STEAM="$HOME/.local/share/Steam/steamapps/common"
GAMES="$HOME/Games"
EXCLUDE=(
"Proton - Experimental"
@@ -11,47 +11,47 @@ EXCLUDE=(
is_excluded() {
local dir=$1
for exclude in "${EXCLUDE[@]}"; do
if [[ "${dir}" == "${exclude}" ]]; then
if [[ "$dir" == "$exclude" ]]; then
return 0
fi
done
return 1
}
for game in "${STEAM}"/*/; do
name=$(basename "${game}")
for game in "$STEAM"/*/; do
name=$(basename "$game")
if is_excluded "${name}"; then
echo "Excluding ${name} from symlink creation."
if is_excluded "$name"; then
echo "Excluding $name from symlink creation."
continue
fi
if [[ -L "${GAMES}/${name}" ]]; then
if [[ -L "$GAMES/$name" ]]; then
continue
fi
if [[ -d "${GAMES}/${name}" || -f "${GAMES}/${name}" ]]; then
>&2 echo "Error: ${name} is already a regular directory or file."
if [[ -d "$GAMES/$name" || -f "$GAMES/$name" ]]; then
>&2 echo "Error: $name is already a regular directory or file."
continue
fi
echo "Creating symlink for ${name}..."
ln -s "${game}" "${GAMES}/${name}"
echo "Creating symlink for $name..."
ln -s "$game" "$GAMES/$name"
done
for link in "${GAMES}"/*; do
target=$(readlink "${link}")
for link in "$GAMES"/*; do
target=$(readlink "$link")
if [[ ! "${target}" == "${STEAM}/"* ]]; then
if [[ ! "$target" == "$STEAM/"* ]]; then
continue
fi
name=$(basename "${target}")
name=$(basename "$target")
if [[ -e "${target}" ]] && ! is_excluded "${name}"; then
if [[ -e "$target" ]] && ! is_excluded "$name"; then
continue
fi
echo "Removing symlink ${link}..."
rm "${link}"
echo "Removing symlink $link..."
rm "$link"
done

View File

@@ -66,23 +66,23 @@ in
dconf
];
text = ''
MODE=$(cat "${hmConfig.theme.configDir}/mode")
mode=$(cat "${hmConfig.theme.configDir}/mode")
if [ "$MODE" = "light" ]; then
GTK_THEME="adw-gtk3"
if [ "$mode" = "light" ]; then
gtk_theme="adw-gtk3"
else
GTK_THEME="adw-gtk3-dark"
gtk_theme="adw-gtk3-dark"
fi
if [[ -v DBUS_SESSION_BUS_ADDRESS ]]; then
DCONF_DBUS_RUN_SESSION=""
dconf_dbus_run_session=""
else
DCONF_DBUS_RUN_SESSION="dbus-run-session --dbus-daemon=dbus-daemon"
dconf_dbus_run_session="dbus-run-session --dbus-daemon=dbus-daemon"
fi
$DCONF_DBUS_RUN_SESSION bash -c "
dconf write /org/gnome/desktop/interface/gtk-theme \"'$GTK_THEME'\"
dconf write /org/gnome/desktop/interface/color-scheme \"'prefer-$MODE'\"
$dconf_dbus_run_session bash -c "
dconf write /org/gnome/desktop/interface/gtk-theme \"'$gtk_theme'\"
dconf write /org/gnome/desktop/interface/color-scheme \"'prefer-$mode'\"
"
'';
}

View File

@@ -11,7 +11,7 @@ set_wallpaper() {
}
toggle_mode() {
if [[ "$(cat "${CONFIG}"/mode)" = "light" ]]; then
if [[ "$(cat "$CONFIG"/mode)" = "light" ]]; then
mode="dark"
else
mode="light"
@@ -19,16 +19,16 @@ toggle_mode() {
}
usage() {
echo "Usage: theme [-m {light|dark|toggle}] [-w <file>]"
echo "Usage: $0 [-m {light|dark|toggle}] [-w <file>]"
exit 1
}
finish() {
[[ -n "${wallpaper}" ]] && ln -sf "${wallpaper}" "${CONFIG}"/wallpaper
[[ -n "${mode}" ]] && echo "${mode}" > "${CONFIG}"/mode
[[ -n "$wallpaper" ]] && ln -sf "$wallpaper" "$CONFIG"/wallpaper
[[ -n "$mode" ]] && echo "$mode" > "$CONFIG"/mode
"${INIT}" > /dev/null
"${RELOAD}" > /dev/null
"$INIT" > /dev/null
"$RELOAD" > /dev/null
}
# Parse arguments