#!/usr/bin/env bash # ╭───────────────╮ # │ env functions │ # ╰───────────────╯ # ───────────────────────────────────< ANSI color codes >─────────────────────────────────── # ─< Check if the given command exists silently >───────────────────────────────────────── command_exists() { command -v "$@" >/dev/null 2>&1 } # WHY: # This import will give you the following variables: # _sudo="sudo -E" <- only if non root user # distro = # arch = bool # fedora = bool # opensuse = bool.... # You can then use it for, `if $arch; then` # Also this gives you the _install command, which installs a package pased on the packagemanager/distro used. # CAUTION: # This only wokrs for generic package names, like neovim, or vim, or tmux etc.. # not every package packagemanager has the same packagenames for their packages.. getImports() { i="https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh" import="$(mktemp)" if command_exists curl; then curl -fsSL $i -o $import else echo "curl is required, but missing.." exit 1 fi source "$import" sleep 0.3 rm "$import" } checkEnv() { if $debian; then echo_info "Using debian.. checking for compatibility.." if ! $trixie; then echo_error "You are not using trixie, this script can currently only run on trixie (13)!" echo_error "trixie: $trixie" echo_error "bookworm: $bookworm" echo_error "bullseye: $bullseye" echo_error "buster: $buster" return 69 else echo_info "Using trixie.. good choice" return 0 fi elif $arch; then echo_info "Using arch linux.. You really shouldn't get any errors :)" return 0 else echo_error "Cannot install $PACKAGE for $distro" return 69 fi } askThings() { # if ! command_exists waybar && ! command_exists hyprpanel && ! command_exists gBar; then choose bar "Choose a bar.." waybar hyprpanel gBar ─────────────────────────────────────────────────────────────────── unset PACKAGE # ─< argument list variables >──────────────────────────────────────────────────────────── silent=false sleep 0.1 PACKAGE=hyprland if command_exists "$PACKAGE"; then echo_warning "$PACKAGE is already installed!" echo_warning "Exiting now!" exit 69 fi # ─< parse arguments and get variable contents >────────────────────────────────────────── for arg in "$@"; do case "$arg" in --silent | -s) export silent=true ;; esac done main fi