wip
This commit is contained in:
@@ -6,9 +6,6 @@ printfe "%s\n" "cyan" "Exporting GNOME extensions"
|
||||
source $HOME/dotfiles/bin/helpers/gnome_extensions.sh
|
||||
export_gnome_extensions
|
||||
|
||||
printfe "%s\n" "cyan" "Exporting VSCode extensions"
|
||||
code --list-extensions | jq -R -s -c 'split("\n")[:-1]' > ~/dotfiles/vscode/extensions.json
|
||||
|
||||
printfe "%s\n" "cyan" "Exporting gnome-terminal settings"
|
||||
dconf dump /org/gnome/terminal/ > ~/dotfiles/config/gnome-terminal.dconf
|
||||
|
||||
|
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
x-terminal-emulator -e $HOME/dotfiles/bin/actions/startup.sh $@
|
@@ -1,116 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source $HOME/dotfiles/bin/helpers/functions.sh
|
||||
|
||||
countdown() {
|
||||
for i in $(seq $1 -1 1); do
|
||||
printfe "%s" "green" " - Waiting for $i seconds... "
|
||||
echo -en "\r"
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
run_startup_scripts() {
|
||||
if is_wsl; then
|
||||
echo "Running in WSL, skipping startup scripts."
|
||||
return
|
||||
fi
|
||||
|
||||
logo continue
|
||||
echo ""
|
||||
local time_of_day
|
||||
# Time of day (morning, afternoon, evening, night)
|
||||
case $(date +%H) in
|
||||
0[0-9]|1[0-1])
|
||||
time_of_day="morning"
|
||||
emoji="🌅"
|
||||
;;
|
||||
1[2-7])
|
||||
time_of_day="afternoon"
|
||||
emoji="🌞"
|
||||
;;
|
||||
1[8-9]|2[0-3])
|
||||
time_of_day="evening"
|
||||
emoji="🌆"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Run the welcome.py from $HOME/dotfiles/bin/helpers/welcome.py
|
||||
python3 $HOME/dotfiles/bin/helpers/welcome.py
|
||||
echo ""
|
||||
|
||||
# Initialize array to hold commands
|
||||
local startup_commands=()
|
||||
|
||||
# Read each command key and add it to the array
|
||||
while IFS= read -r command; do
|
||||
startup_commands+=("$command")
|
||||
done < <(cat $HOME/dotfiles/config/config.yaml | shyaml keys config.startup.commands)
|
||||
|
||||
# Read delay and delay_between_ms values from YAML
|
||||
local delay=$(cat $HOME/dotfiles/config/config.yaml | shyaml get-value config.startup.delay)
|
||||
local delay_between_ms=$(cat $HOME/dotfiles/config/config.yaml | shyaml get-value config.startup.delay_between_ms)
|
||||
|
||||
printfe "%s\n" "cyan" "Running startup commands... (delay: $delay s, delay_between: $delay_between_ms ms)"
|
||||
|
||||
# Wait for the initial delay
|
||||
countdown $delay
|
||||
|
||||
# Ensure the log folder exists
|
||||
mkdir -p $HOME/dotfiles/logs/startup
|
||||
|
||||
# Execute each command in a new screen window
|
||||
for command_key in "${startup_commands[@]}"; do
|
||||
local command=$(cat $HOME/dotfiles/config/config.yaml | shyaml get-value config.startup.commands.$command_key)
|
||||
|
||||
printfe "%s" "green" " - Running '"
|
||||
printfe "%s" "blue" "$command_key"
|
||||
printfe "%s" "green" "'... ("
|
||||
printfe "%s" "blue" "$command"
|
||||
printfe "%s\n" "green" ")"
|
||||
|
||||
# Check if a screen with the same name already exists, if so log it and don't run the command
|
||||
if screen -list | grep -q $command_key; then
|
||||
printfe "%s" "red" " - Screen session already exists: "
|
||||
printfe "%s" "blue" "$command_key"
|
||||
printfe "%s\n" "red" ""
|
||||
continue
|
||||
fi
|
||||
|
||||
# Ensure the log file exists, if it exists, clear it
|
||||
touch $HOME/dotfiles/logs/startup/$command_key.log
|
||||
|
||||
# Run the command in a new screen session named after the command_key
|
||||
screen -dmS $command_key bash -c "eval $command > $HOME/dotfiles/logs/startup/$command_key.log 2>&1"
|
||||
sleep $(echo "scale=2; $delay_between_ms / 1000" | bc)
|
||||
|
||||
if ! screen -list | grep -q $command_key; then
|
||||
printfe "%s" "red" " - Screen session died immediately: "
|
||||
printfe "%s" "blue" "$command_key"
|
||||
printfe "%s\n" "red" " (Within $delay_between_ms ms, check the logs for more information in $HOME/dotfiles/logs/startup/$command_key.log)"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Check if command is ok, if not log that it failed
|
||||
if [ $? -ne 0 ]; then
|
||||
printfe "%s" "red" " - Command failed: "
|
||||
printfe "%s" "blue" "$command"
|
||||
printfe "%s\n" "red" ""
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Check if we're in a graphical session
|
||||
if [[ -z "$DISPLAY" && "$XDG_SESSION_TYPE" != "x11" && "$XDG_SESSION_TYPE" != "wayland" ]]; then
|
||||
echo "Not in a graphical session. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
run_startup_scripts
|
||||
|
||||
echo ""
|
||||
|
||||
# Show message to press any key to close the terminal window
|
||||
printfe "%s\n" "green" "Press any key to close this window..."
|
||||
read -s -n 1
|
||||
exit 0
|
@@ -1,12 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source $HOME/dotfiles/bin/helpers/functions.sh
|
||||
source $HOME/dotfiles/bin/helpers/keyboard_shortcuts.sh
|
||||
source $HOME/dotfiles/bin/helpers/apt_packages.sh
|
||||
source $HOME/dotfiles/bin/helpers/pipx_packages.sh
|
||||
source $HOME/dotfiles/bin/helpers/cargo_packages.sh
|
||||
source $HOME/dotfiles/bin/helpers/flatpak_packages.sh
|
||||
source $HOME/dotfiles/bin/helpers/vscode-extensions.sh
|
||||
source $HOME/dotfiles/bin/helpers/fonts.sh
|
||||
|
||||
# Check if parameter --verbose was passed
|
||||
@@ -18,10 +15,7 @@ fi
|
||||
|
||||
echo -e "\n"
|
||||
|
||||
print_keyboard_shortcuts_status
|
||||
print_fonts_status
|
||||
print_apt_status
|
||||
print_pipx_status
|
||||
print_cargo_status
|
||||
print_flatpak_status
|
||||
print_vsc_status
|
||||
|
@@ -16,43 +16,33 @@ if [ ! -x "$(command -v shyaml)" ]; then
|
||||
pipx install shyaml
|
||||
fi
|
||||
|
||||
groups() {
|
||||
####################################################################################################
|
||||
# Ensure user groups
|
||||
####################################################################################################
|
||||
|
||||
printfe "%s\n" "cyan" "Ensuring user groups..."
|
||||
source $HOME/dotfiles/bin/helpers/user_groups.sh
|
||||
ensure_user_groups
|
||||
}
|
||||
|
||||
ensure_symlink() {
|
||||
local source
|
||||
local target
|
||||
|
||||
# Fetch target from YAML
|
||||
target=$(shyaml get-value "config.symlinks.$1.target" < "$HOME/dotfiles/config/config.yaml") 2>/dev/null
|
||||
target=$(shyaml get-value "config.symlinks.$1.target" < "$HOME/dotfiles/config/config.yaml" 2>/dev/null)
|
||||
|
||||
# Fetch source from YAML based on OS
|
||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
# Check for WSL2
|
||||
if [[ $(uname -a) == *"microsoft-standard-WSL2"* ]]; then
|
||||
source=$(shyaml get-value "config.symlinks.$1.sources.wsl" < "$HOME/dotfiles/config/config.yaml") 2>/dev/null
|
||||
source=$(shyaml get-value "config.symlinks.$1.sources.wsl" < "$HOME/dotfiles/config/config.yaml" 2>/dev/null)
|
||||
else
|
||||
source=$(shyaml get-value "config.symlinks.$1.sources.linux" < "$HOME/dotfiles/config/config.yaml") 2>/dev/null
|
||||
source=$(shyaml get-value "config.symlinks.$1.sources.linux" < "$HOME/dotfiles/config/config.yaml" 2>/dev/null)
|
||||
fi
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
source=$(shyaml get-value "config.symlinks.$1.sources.macos" < "$HOME/dotfiles/config/config.yaml") 2>/dev/null
|
||||
source=$(shyaml get-value "config.symlinks.$1.sources.macos" < "$HOME/dotfiles/config/config.yaml" 2>/dev/null)
|
||||
fi
|
||||
|
||||
# Fall back to generic source if OS-specific source is empty
|
||||
if [ -z "$source" ]; then
|
||||
source=$(shyaml get-value "config.symlinks.$1.source" < "$HOME/dotfiles/config/config.yaml") 2>/dev/null
|
||||
source=$(shyaml get-value "config.symlinks.$1.source" < "$HOME/dotfiles/config/config.yaml" 2>/dev/null)
|
||||
fi
|
||||
|
||||
# Attempt to use the hostname of the machine if source is still empty
|
||||
if [ -z "$source" ]; then
|
||||
source=$(shyaml get-value "config.symlinks.$1.sources.$(hostname)" < "$HOME/dotfiles/config/config.yaml") 2>/dev/null
|
||||
source=$(shyaml get-value "config.symlinks.$1.sources.$(hostname)" < "$HOME/dotfiles/config/config.yaml" 2>/dev/null)
|
||||
fi
|
||||
|
||||
# Error out if source is still empty
|
||||
@@ -80,7 +70,7 @@ ensure_symlink() {
|
||||
resolved_target="$target"
|
||||
fi
|
||||
|
||||
current_chmod=$(stat -c %a "$resolved_target")
|
||||
current_chmod=$(stat -c %a "$resolved_target" 2>/dev/null)
|
||||
if [ "$current_chmod" != "$desired_chmod" ]; then
|
||||
printfe "%s\n" "yellow" " - Changing chmod of $resolved_target to $desired_chmod"
|
||||
chmod "$desired_chmod" "$resolved_target"
|
||||
@@ -113,6 +103,11 @@ sys_packages() {
|
||||
brew upgrade
|
||||
brew cleanup
|
||||
else
|
||||
if [ -x "$(command -v nixos-version)" ]; then
|
||||
sudo nixos-rebuild switch
|
||||
return
|
||||
fi
|
||||
|
||||
sudo nala upgrade -y
|
||||
sudo nala autoremove -y --purge
|
||||
fi
|
||||
@@ -122,26 +117,18 @@ sys_packages() {
|
||||
# Update packages
|
||||
####################################################################################################
|
||||
|
||||
cargopkgs() {
|
||||
printfe "%s\n" "cyan" "Rust update..."
|
||||
source $HOME/dotfiles/bin/helpers/rust.sh
|
||||
ensure_rust_installed
|
||||
|
||||
cargopkgs() {
|
||||
printfe "%s\n" "cyan" "Ensuring Cargo packages are installed..."
|
||||
source $HOME/dotfiles/bin/helpers/cargo_packages.sh
|
||||
ensure_cargo_packages_installed
|
||||
}
|
||||
|
||||
aptpkgs() {
|
||||
printfe "%s\n" "cyan" "Ensuring APT repositories are added..."
|
||||
source $HOME/dotfiles/bin/helpers/apt_packages.sh
|
||||
ensure_repositories
|
||||
|
||||
printfe "%s\n" "cyan" "Ensuring APT packages are installed..."
|
||||
ensure_apt_packages_installed
|
||||
}
|
||||
|
||||
pipxpkgs() {
|
||||
if [ ! -x "$(command -v pipx)" ]; then
|
||||
printfe "%s\n" "yellow" "pipx is not available, skipping pipx packages."
|
||||
return
|
||||
fi
|
||||
|
||||
printfe "%s\n" "cyan" "Ensuring pyenv is installed..."
|
||||
if [ ! -d "$HOME/.pyenv" ]; then
|
||||
curl https://pyenv.run | bash
|
||||
@@ -155,6 +142,11 @@ pipxpkgs() {
|
||||
}
|
||||
|
||||
flatpakpkgs() {
|
||||
if [ ! -x "$(command -v flatpak)" ]; then
|
||||
printfe "%s\n" "yellow" "Flatpak is not available, skipping Flatpak."
|
||||
return
|
||||
fi
|
||||
|
||||
if is_wsl; then
|
||||
printfe "%s\n" "yellow" "Running in WSL, skipping Flatpak."
|
||||
return
|
||||
@@ -166,6 +158,12 @@ flatpakpkgs() {
|
||||
}
|
||||
|
||||
dockercmd() {
|
||||
# On NixOS this is managed by the docker.nix module
|
||||
if [ -x "$(command -v nixos-version)" ]; then
|
||||
printfe "%s\n" "yellow" "Detected NixOS, skipping Docker."
|
||||
return
|
||||
fi
|
||||
|
||||
printfe "%s\n" "cyan" "Ensuring Docker is installed..."
|
||||
source $HOME/dotfiles/bin/helpers/docker.sh
|
||||
ensure_docker_installed
|
||||
@@ -191,34 +189,12 @@ extensions() {
|
||||
printfe "%s\n" "cyan" "Ensuring GNOME Extensions are installed..."
|
||||
source $HOME/dotfiles/bin/helpers/gnome_extensions.sh
|
||||
ensure_gnome_extensions_installed
|
||||
|
||||
printfe "%s\n" "cyan" "Ensuring VSCode extensions are installed..."
|
||||
source $HOME/dotfiles/bin/helpers/vscode-extensions.sh
|
||||
ensure_vscode_extensions_installed
|
||||
|
||||
if [ ! -f "$HOME/.local/share/nemo/actions/vscode.nemo_action" ]; then
|
||||
printfe "%s\n" "cyan" "Ensuring nemo open with VSCode extension is installed..."
|
||||
wget https://raw.githubusercontent.com/mhsattarian/nemo-open-in-vscode/master/vscode.nemo_action -O $HOME/.local/share/nemo/actions/vscode.nemo_action
|
||||
else
|
||||
printfe "%s\n" "green" " - nemo open with VSCode extension is already installed"
|
||||
fi
|
||||
}
|
||||
|
||||
####################################################################################################
|
||||
# Update system settings
|
||||
####################################################################################################
|
||||
|
||||
keyboard() {
|
||||
if is_wsl; then
|
||||
printfe "%s\n" "yellow" "Running in WSL, skipping keyboard shortcuts."
|
||||
return
|
||||
fi
|
||||
|
||||
printfe "%s\n" "cyan" "Setting up keyboard shortcuts..."
|
||||
source $HOME/dotfiles/bin/helpers/keyboard_shortcuts.sh
|
||||
ensure_keyboard_shortcuts
|
||||
}
|
||||
|
||||
fonts() {
|
||||
if is_wsl; then
|
||||
printfe "%s\n" "yellow" "Running in WSL, skipping fonts."
|
||||
@@ -279,12 +255,16 @@ git_repos() {
|
||||
ensure_git_repos
|
||||
}
|
||||
|
||||
homemanager() {
|
||||
home-manager switch
|
||||
}
|
||||
|
||||
####################################################################################################
|
||||
# Parse arguments
|
||||
####################################################################################################
|
||||
|
||||
# Multiple options can be passed to the script, for example:
|
||||
# ./update.sh --verbose --groups --symlinks --packages --keyboard --fonts --default-terminal --default-shell
|
||||
# ./update.sh --git --symlinks --packages
|
||||
# If no options are passed, the script will run all functions
|
||||
|
||||
# Shift the first argument since this is the script name
|
||||
@@ -293,45 +273,39 @@ shift
|
||||
if [ "$#" -eq 0 ]; then
|
||||
printfe "%s\n" "yellow" "No options passed, running full update..."
|
||||
|
||||
git_repos
|
||||
groups
|
||||
symlinks
|
||||
sys_packages
|
||||
aptpkgs
|
||||
homemanager
|
||||
cargopkgs
|
||||
pipxpkgs
|
||||
dockercmd
|
||||
git_repos
|
||||
flatpakpkgs
|
||||
tailscalecmd
|
||||
extensions
|
||||
keyboard
|
||||
fonts
|
||||
terminal
|
||||
default_shell
|
||||
else
|
||||
for arg in "$@"; do
|
||||
case $arg in
|
||||
--homemanager)
|
||||
homemanager
|
||||
;;
|
||||
--git)
|
||||
git_repos
|
||||
;;
|
||||
--groups)
|
||||
groups
|
||||
;;
|
||||
--symlinks)
|
||||
symlinks
|
||||
;;
|
||||
--packages)
|
||||
sys_packages
|
||||
cargopkgs
|
||||
aptpkgs
|
||||
pipxpkgs
|
||||
flatpakpkgs
|
||||
dockercmd
|
||||
tailscalecmd
|
||||
;;
|
||||
--apt)
|
||||
aptpkgs
|
||||
;;
|
||||
--pipx)
|
||||
pipxpkgs
|
||||
;;
|
||||
@@ -350,9 +324,6 @@ else
|
||||
--extensions)
|
||||
extensions
|
||||
;;
|
||||
--keyboard)
|
||||
keyboard
|
||||
;;
|
||||
--fonts)
|
||||
fonts
|
||||
;;
|
||||
|
Reference in New Issue
Block a user