From fef89ef3fce00dff28f356bb247b0668bf816dd1 Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Mon, 15 Jul 2024 14:00:04 -0500 Subject: [PATCH] alacritty setup --- src/commands/common-script.sh | 59 ++++++++++++++ src/commands/dotfiles/alacritty-setup.sh | 85 ++++++++++++++++++++ src/commands/{ => dotfiles}/kitty-setup.sh | 3 +- src/commands/{ => dotfiles}/rofi-setup.sh | 3 +- src/commands/system-setup/1-compile-setup.sh | 3 +- src/commands/system-setup/2-gaming-setup.sh | 2 +- src/commands/system-update.sh | 3 +- src/list.rs | 8 +- 8 files changed, 159 insertions(+), 7 deletions(-) create mode 100644 src/commands/common-script.sh create mode 100755 src/commands/dotfiles/alacritty-setup.sh rename src/commands/{ => dotfiles}/kitty-setup.sh (98%) rename src/commands/{ => dotfiles}/rofi-setup.sh (99%) diff --git a/src/commands/common-script.sh b/src/commands/common-script.sh new file mode 100644 index 00000000..3ecc4a69 --- /dev/null +++ b/src/commands/common-script.sh @@ -0,0 +1,59 @@ +#!/bin/sh -e + +RC='\033[0m' +RED='\033[31m' +YELLOW='\033[33m' +GREEN='\033[32m' + +command_exists() { + which $1 >/dev/null 2>&1 +} + +checkEnv() { + ## Check for requirements. + REQUIREMENTS='curl groups sudo' + for req in ${REQUIREMENTS}; do + if ! command_exists ${req}; then + echo "${RED}To run me, you need: ${REQUIREMENTS}${RC}" + exit 1 + fi + done + + ## Check Package Handler + PACKAGEMANAGER='apt-get dnf pacman zypper' + for pgm in ${PACKAGEMANAGER}; do + if command_exists ${pgm}; then + PACKAGER=${pgm} + echo "Using ${pgm}" + break + fi + done + + if [ -z "${PACKAGER}" ]; then + echo "${RED}Can't find a supported package manager${RC}" + exit 1 + fi + + ## Check SuperUser Group + SUPERUSERGROUP='wheel sudo root' + for sug in ${SUPERUSERGROUP}; do + if groups | grep -q ${sug}; then + SUGROUP=${sug} + echo "Super user group ${SUGROUP}" + break + fi + done + + ## Check if member of the sudo group. + if ! groups | grep -q ${SUGROUP}; then + echo "${RED}You need to be a member of the sudo group to run me!${RC}" + exit 1 + fi + + DTYPE="unknown" # Default to unknown + # Use /etc/os-release for modern distro identification + if [ -f /etc/os-release ]; then + . /etc/os-release + DTYPE=$ID + fi +} \ No newline at end of file diff --git a/src/commands/dotfiles/alacritty-setup.sh b/src/commands/dotfiles/alacritty-setup.sh new file mode 100755 index 00000000..f35269c8 --- /dev/null +++ b/src/commands/dotfiles/alacritty-setup.sh @@ -0,0 +1,85 @@ +#!/bin/sh -e + +RC='\033[0m' +RED='\033[31m' +YELLOW='\033[33m' +GREEN='\033[32m' + +command_exists() { + which $1 >/dev/null 2>&1 +} + +checkEnv() { + ## Check for requirements. + REQUIREMENTS='curl groups sudo' + for req in ${REQUIREMENTS}; do + if ! command_exists ${req}; then + echo "${RED}To run me, you need: ${REQUIREMENTS}${RC}" + exit 1 + fi + done + + ## Check Package Handler + PACKAGEMANAGER='apt-get dnf pacman zypper' + for pgm in ${PACKAGEMANAGER}; do + if command_exists ${pgm}; then + PACKAGER=${pgm} + echo "Using ${pgm}" + break + fi + done + + if [ -z "${PACKAGER}" ]; then + echo "${RED}Can't find a supported package manager${RC}" + exit 1 + fi + + ## Check SuperUser Group + SUPERUSERGROUP='wheel sudo root' + for sug in ${SUPERUSERGROUP}; do + if groups | grep -q ${sug}; then + SUGROUP=${sug} + echo "Super user group ${SUGROUP}" + break + fi + done + + ## Check if member of the sudo group. + if ! groups | grep -q ${SUGROUP}; then + echo "${RED}You need to be a member of the sudo group to run me!${RC}" + exit 1 + fi + + DTYPE="unknown" # Default to unknown + # Use /etc/os-release for modern distro identification + if [ -f /etc/os-release ]; then + . /etc/os-release + DTYPE=$ID + fi +} + +setupAlacritty() { + echo "Install Alacritty if not already installed..." + if ! command_exists alacritty; then + case ${PACKAGER} in + pacman) + sudo ${PACKAGER} -S --noconfirm alacritty + ;; + *) + sudo ${PACKAGER} install -y alacritty + ;; + esac + else + echo "alacritty is already installed." + fi + echo "Copy alacritty config files" + if [ -d "${HOME}/.config/alacritty" ]; then + cp -r "${HOME}/.config/alacritty" "${HOME}/.config/alacritty-bak" + fi + mkdir -p "${HOME}/.config/alacritty/" + wget -O "${HOME}/.config/alacritty/alacritty.toml" "https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/alacritty/alacritty.toml" + wget -O "${HOME}/.config/alacritty/nordic.toml" "https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/alacritty/nordic.toml" +} + +checkEnv +setupAlacritty \ No newline at end of file diff --git a/src/commands/kitty-setup.sh b/src/commands/dotfiles/kitty-setup.sh similarity index 98% rename from src/commands/kitty-setup.sh rename to src/commands/dotfiles/kitty-setup.sh index 4694420b..000f995a 100755 --- a/src/commands/kitty-setup.sh +++ b/src/commands/dotfiles/kitty-setup.sh @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh -e + RC='\033[0m' RED='\033[31m' YELLOW='\033[33m' diff --git a/src/commands/rofi-setup.sh b/src/commands/dotfiles/rofi-setup.sh similarity index 99% rename from src/commands/rofi-setup.sh rename to src/commands/dotfiles/rofi-setup.sh index 31f25dd6..a99deb98 100755 --- a/src/commands/rofi-setup.sh +++ b/src/commands/dotfiles/rofi-setup.sh @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh -e + RC='\033[0m' RED='\033[31m' YELLOW='\033[33m' diff --git a/src/commands/system-setup/1-compile-setup.sh b/src/commands/system-setup/1-compile-setup.sh index dc987d68..7bd90374 100755 --- a/src/commands/system-setup/1-compile-setup.sh +++ b/src/commands/system-setup/1-compile-setup.sh @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh -e + RC='\033[0m' RED='\033[31m' YELLOW='\033[33m' diff --git a/src/commands/system-setup/2-gaming-setup.sh b/src/commands/system-setup/2-gaming-setup.sh index e1f6a210..85548907 100755 --- a/src/commands/system-setup/2-gaming-setup.sh +++ b/src/commands/system-setup/2-gaming-setup.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -e RC='\e[0m' RED='\e[31m' diff --git a/src/commands/system-update.sh b/src/commands/system-update.sh index f2465a7c..36b7630d 100755 --- a/src/commands/system-update.sh +++ b/src/commands/system-update.sh @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/sh -e + RC='\033[0m' RED='\033[31m' YELLOW='\033[33m' diff --git a/src/list.rs b/src/list.rs index f1a4ab0a..365cfcdc 100644 --- a/src/list.rs +++ b/src/list.rs @@ -72,13 +72,17 @@ impl CustomList { name: "Titus Dotfiles", command: "" } => { + ListNode { + name: "Alacritty Setup", + command: include_str!("commands/dotfiles/alacritty-setup.sh"), + }, ListNode { name: "Kitty Setup", - command: include_str!("commands/kitty-setup.sh"), + command: include_str!("commands/dotfiles/kitty-setup.sh"), }, ListNode { name: "Rofi Setup", - command: include_str!("commands/rofi-setup.sh"), + command: include_str!("commands/dotfiles/rofi-setup.sh"), }, } });