diff options
| author | pml68 <contact@pml68.dev> | 2024-12-13 01:54:13 +0100 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2024-12-13 02:01:28 +0100 |
| commit | 4e4a92bd81cf0db319dad55dd927a9414f080b87 (patch) | |
| tree | 4e36e6634eda7bbae3e1ca83cd4d4cf76d504e76 /install.sh | |
| parent | feat: better install script (diff) | |
| download | suckless-setup-4e4a92bd81cf0db319dad55dd927a9414f080b87.tar.gz | |
feat: add root/sudo detection to install script
Diffstat (limited to 'install.sh')
| -rwxr-xr-x | install.sh | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -1,25 +1,29 @@ #!/bin/sh -dirs="dwm dmenu slstatus st" +programs="dwm dmenu slstatus st" command_exists() { command -v "$1" >/dev/null 2>&1 } -for dir in $dirs; do - (cd "$dir" && echo "starting $dir installation" && make clean install && echo "$dir installation complete") +has_root_perms() { + [ "$(id -u)" -eq 0 ] || [ -n "$SUDO_UID" ] +} + +for program in $programs; do + has_root_perms && (cd "$program" && echo "starting $program installation" && make clean install && echo "$program installation complete") || echo "Can't install $program: you must run the script as root or with sudo." done if command_exists feh; then feh --bg-fill wallpaper.jpg - echo "~/.fehbg &" >> ~/.xinitrc + echo "~/.fehbg &" >>~/.xinitrc fi if command_exists picom; then - cp picom.conf /etc/xdg/picom.conf - echo "picom &" >> ~/.xinitrc + has_root_perms && cp picom.conf /etc/xdg/picom.conf || echo "Can't install picom configuration: you must run the script as root or with sudo." + echo "picom &" >>~/.xinitrc fi -command_exists flameshot && echo "flameshot &" >> ~/.xinitrc +command_exists flameshot && echo "flameshot &" >>~/.xinitrc command_exists neofetch && cp neofetch -r ~/.config/ @@ -30,5 +34,5 @@ if command_exists tmux; then cp tmux -r ~/.config/ fi -echo "slstatus &" >> ~/.xinitrc -echo "exec dwm" >> ~/.xinitrc +echo "slstatus &" >>~/.xinitrc +echo "exec dwm" >>~/.xinitrc |
