Review shell scripts
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
install -d -m 700 "${GNUPGHOME}"
|
||||
install -d -m 700 "$GNUPGHOME"
|
||||
|
||||
for dir in "${HOME}"/.config/sops-nix/secrets/gpg/*; do
|
||||
keyfile="${dir}/key"
|
||||
passfile="${dir}/pass"
|
||||
for dir in "$HOME"/.config/sops-nix/secrets/gpg/*; do
|
||||
keyfile="$dir/key"
|
||||
passfile="$dir/pass"
|
||||
|
||||
if [[ ! -f "${keyfile}" ]]; then
|
||||
if [[ ! -f "$keyfile" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ -f "${passfile}" ]]; then
|
||||
gpg2 --batch --yes --pinentry-mode loopback --passphrase-file "${passfile}" --import "${keyfile}"
|
||||
if [[ -f "$passfile" ]]; then
|
||||
gpg2 --batch --yes --pinentry-mode loopback --passphrase-file "$passfile" --import "$keyfile"
|
||||
else
|
||||
gpg2 --batch --yes --import "${keyfile}"
|
||||
gpg2 --batch --yes --import "$keyfile"
|
||||
fi
|
||||
|
||||
gpg2 --with-colons --import-options show-only --import "${keyfile}" | grep '^fpr' | cut -d: -f10 | while read -r KEY_ID; do
|
||||
echo "${KEY_ID}:6:" >> "${GNUPGHOME}"/otrust.txt
|
||||
gpg2 --with-colons --import-options show-only --import "$keyfile" | grep '^fpr' | cut -d: -f10 | while read -r key_id; do
|
||||
echo "$key_id:6:" >> "$GNUPGHOME"/otrust.txt
|
||||
done
|
||||
done
|
||||
|
||||
gpg2 --import-ownertrust "${GNUPGHOME}"/otrust.txt
|
||||
rm "${GNUPGHOME}"/otrust.txt
|
||||
gpg2 --import-ownertrust "$GNUPGHOME"/otrust.txt
|
||||
rm "$GNUPGHOME"/otrust.txt
|
||||
|
@@ -20,16 +20,34 @@
|
||||
in
|
||||
''
|
||||
nix-develop() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: nix-develop <shell>"
|
||||
return 1
|
||||
local devshell=""
|
||||
|
||||
while getopts "s:" opt; do
|
||||
case $opt in
|
||||
s)
|
||||
devshell=$OPTARG
|
||||
;;
|
||||
*)
|
||||
echo "Usage: nix-develop [-s <devshell>]"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$devshell" ]]; then
|
||||
if [ ! -f flake.nix ]; then cp "${./template.nix}" flake.nix; fi
|
||||
nix develop -c "$SHELL"
|
||||
else
|
||||
nix develop self#"$devshell" -c "$SHELL"
|
||||
fi
|
||||
nix develop self#"$1" -c "$SHELL"
|
||||
}
|
||||
|
||||
_nix-develop_completion() {
|
||||
local shells=(${devShells})
|
||||
compadd -- $shells
|
||||
local options=(
|
||||
'-s[Dev shell from root flake]:shell:(${devShells})'
|
||||
)
|
||||
|
||||
_arguments -s $options
|
||||
}
|
||||
|
||||
compdef _nix-develop_completion nix-develop
|
||||
|
@@ -30,36 +30,38 @@
|
||||
in
|
||||
''
|
||||
nix-direnv() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "use flake" > .envrc
|
||||
local devshell=""
|
||||
local hide=false
|
||||
|
||||
if [ ! -f flake.nix ]; then
|
||||
echo "Do you want to create an empty flake.nix? (y/N)"
|
||||
read -r answer
|
||||
if [[ "$answer" =~ ^[Yy]$ ]]; then
|
||||
cp "${./template.nix}" flake.nix
|
||||
fi
|
||||
fi
|
||||
while getopts "s:h" opt; do
|
||||
case $opt in
|
||||
s)
|
||||
devshell=$OPTARG
|
||||
;;
|
||||
h)
|
||||
hide=true
|
||||
;;
|
||||
*)
|
||||
echo "Usage: nix-direnv [-s <devshell>] [-h]"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$devshell" ]]; then
|
||||
echo "use flake" > .envrc
|
||||
if [ ! -f flake.nix ]; then cp "${../nix-develop/template.nix}" flake.nix; fi
|
||||
else
|
||||
echo "use flake self#$1" > .envrc
|
||||
echo "use flake self#$devshell" > .envrc
|
||||
fi
|
||||
|
||||
if git rev-parse --is-inside-work-tree &> /dev/null; then
|
||||
if ! grep -q "^\.envrc$" .gitignore .git/info/exclude; then
|
||||
echo "Do you want to hide the .envrc file from git? (y/N)"
|
||||
read -r answer
|
||||
if [[ "$answer" =~ ^[Yy]$ ]]; then
|
||||
echo ".envrc" >> .git/info/exclude
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f flake.nix ] && ! grep -q "^flake.nix$" .gitignore .git/info/exclude; then
|
||||
echo "Do you want to hide the flake.nix and flake.lock files from git? (y/N)"
|
||||
read -r answer
|
||||
if [[ "$answer" =~ ^[Yy]$ ]]; then
|
||||
echo "flake.nix" >> .git/info/exclude
|
||||
echo "flake.lock" >> .git/info/exclude
|
||||
fi
|
||||
if hide && git rev-parse --is-inside-work-tree &>/dev/null; then
|
||||
local top
|
||||
top=$(git rev-parse --show-toplevel)
|
||||
if ! grep -q "^\.envrc$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "$(realpath --relative-to="$top" .envrc)" >> "$top/.git/info/exclude"; fi
|
||||
if [ -z "$devshell" ]; then
|
||||
if ! grep -q "^flake.nix$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "flake.nix" >> "$top/.git/info/exclude"; fi
|
||||
if ! grep -q "^flake.lock$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "flake.lock" >> "$top/.git/info/exclude"; fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -67,8 +69,12 @@
|
||||
}
|
||||
|
||||
_nix-direnv_completion() {
|
||||
local shells=(${devShells})
|
||||
compadd -- $shells
|
||||
local options=(
|
||||
'-s[Dev shell from root flake]:shell:(${devShells})'
|
||||
'-h[Hide .envrc and flake.nix in git]'
|
||||
)
|
||||
|
||||
_arguments -s $options
|
||||
}
|
||||
|
||||
compdef _nix-direnv_completion nix-direnv
|
||||
|
@@ -19,7 +19,7 @@ in
|
||||
with cfg;
|
||||
{
|
||||
initExtra = ''
|
||||
export P10K_EXTRA_RIGHT_PROMPT_ELEMENTS=(${strings.concatStringsSep " " cfg.p10k.extraRightPromptElements})
|
||||
export P10K_EXTRA_RIGHT_PROMPT_ELEMENTS=(${strings.concatStringsSep " " p10k.extraRightPromptElements})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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'\"
|
||||
"
|
||||
'';
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user