From f09a1ae032efe689bb99c84e79a49050a88bcbd8 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Mon, 26 Feb 2024 00:21:53 -0500 Subject: [PATCH] Add some early bails for non-standard devices --- copy.sh | 24 +++++++++++++----------- fake_home/.zshrc | 38 +++++++++++++++++++++++++------------- 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/copy.sh b/copy.sh index 1e77c1b..0e8da18 100755 --- a/copy.sh +++ b/copy.sh @@ -11,7 +11,9 @@ if ! command -v wget &> /dev/null; then exit 1 fi -if ! command -v sofi &> /dev/null && ! test -f /usr/bin/sofi; then +mkdir -p "$HOME/.tmp" || exit 1 + +if command -v sudo &> /dev/null && ! command -v sofi &> /dev/null && ! test -f /usr/bin/sofi; then echo -e '#!/bin/bash\n$HOME/.sofi.sh --launch' | sudo tee /usr/bin/sofi sudo chmod +x /usr/bin/sofi fi @@ -85,12 +87,12 @@ if ! test -d "$HOME/.nvm"; then nvm use node fi -if ! command -v dotnet &> /dev/null; then +if command -v sudo &> /dev/null && ! command -v dotnet &> /dev/null; then echo "dotnet is not installed. Installing..." - wget https://dot.net/v1/dotnet-install.sh -O /tmp/dotnet-install.sh - chmod +x /tmp/dotnet-install.sh - /tmp/dotnet-install.sh --version latest - rm /tmp/dotnet-install.sh + wget https://dot.net/v1/dotnet-install.sh -O $HOME/.tmp/dotnet-install.sh + chmod +x $HOME/.tmp/dotnet-install.sh + $HOME/.tmp/dotnet-install.sh --version latest + rm $HOME/.tmp/dotnet-install.sh fi if ! command -v starship &> /dev/null; then @@ -101,8 +103,8 @@ fi if ! test -d $HOME/.config/JetBrains/; then echo "JetBrains toolbox is not installed. Installing..." ARCHIVE_URL="$(curl -s 'https://data.services.jetbrains.com/products/releases?code=TBA&latest=true&type=release' | grep -Po '"linux":.*?[^\\]",' | awk -F ':' '{print $3,":"$4}'| sed 's/[", ]//g')" - wget -q --show-progress -cO "/tmp/jetbrains-toolbox-latest.tar.gz" "$ARCHIVE_URL" - cd /tmp/ + wget -q --show-progress -cO "$HOME/.tmp/jetbrains-toolbox-latest.tar.gz" "$ARCHIVE_URL" + cd $HOME/.tmp/ tar -xvf jetbrains-toolbox-latest.tar.gz --strip-components=1 chmod +x jetbrains-toolbox ./jetbrains-toolbox @@ -111,9 +113,9 @@ fi mkdir -p "$HOME/.local/share/fonts" if ! test -f "$HOME/.local/share/fonts/FiraCodeNerdFontMono-Medium.ttf"; then echo "FiraCode is not installed. Installing..." - wget -O /tmp/firacode.zip "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.1/FiraCode.zip" - unzip -d "$HOME/.local/share/fonts" /tmp/firacode.zip - rm /tmp/firacode.zip + wget -O $HOME/.tmp/firacode.zip "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.1/FiraCode.zip" + unzip -d "$HOME/.local/share/fonts" $HOME/.tmp/firacode.zip + rm $HOME/.tmp/firacode.zip fc-cache -f -v fi diff --git a/fake_home/.zshrc b/fake_home/.zshrc index cab9dc2..6bbf9e4 100644 --- a/fake_home/.zshrc +++ b/fake_home/.zshrc @@ -105,6 +105,10 @@ function dconf-dump { } function push-dconf { + if ! command -v dconf &> /dev/null; then + echo "The current system does not include dconf" + return + fi if ! command -v scpace &> /dev/null; then echo "An alias for scpace has not been defined on this device!" return 1 @@ -180,6 +184,26 @@ function pushdot { return $res } +function sync-dconf { + if ! command -v dconf &> /dev/null; then + echo "System does not use dconf" + return + fi + rm /tmp/dconf-dump &> /dev/null + scp -P 11275 'sage@sagev.space:~/dconf-dump' /tmp/dconf-dump + dconf-dump > /tmp/current-dconf-dump + if ! git --no-pager diff --no-index /tmp/current-dconf-dump /tmp/dconf-dump &> /dev/null; then + echo + echo "Incoming conf changes:" + echo + git --no-pager diff --no-index /tmp/current-dconf-dump /tmp/dconf-dump + echo + bash -c 'read -p "Press enter to continue, or Ctrl-C to cancel."' || return 1 + echo "Applying changes..." + fi + dconf load / < /tmp/dconf-dump || return 1 +} + function getdot { if ! command -v scpace &> /dev/null; then echo "An alias for scpace has not been defined on this device!" @@ -194,20 +218,8 @@ function getdot { load-extensions sync-history + sync-dconf - rm /tmp/dconf-dump &> /dev/null - scp -P 11275 'sage@sagev.space:~/dconf-dump' /tmp/dconf-dump - dconf-dump > /tmp/current-dconf-dump - if ! git --no-pager diff --no-index /tmp/current-dconf-dump /tmp/dconf-dump &> /dev/null; then - echo - echo "Incoming conf changes:" - echo - git --no-pager diff --no-index /tmp/current-dconf-dump /tmp/dconf-dump - echo - bash -c 'read -p "Press enter to continue, or Ctrl-C to cancel."' || return 1 - echo "Applying changes..." - fi - dconf load / < /tmp/dconf-dump || return 1 cd - > /dev/null }