From 7f0421d094889dc889dae003833e01d957cfbec0 Mon Sep 17 00:00:00 2001 From: Didier Date: Wed, 23 Aug 2023 06:14:56 +0200 Subject: [PATCH 1/8] next gen init --- .gitignore | 3 +- README.md | 17 +- compatibility/fedora.sh | 12 - distros/alpine/pm.sh | 19 ++ distros/any/package.list | 4 + distros/any/root/etc/sudoers | 4 + distros/arch/package.list | 2 + distros/arch/pm.sh | 22 ++ distros/arch/root/etc/pacman.conf | 31 +++ distros/arch/sys-scripts/00-reflector.sh | 12 + distros/arch/user-scripts/00-yay.sh | 13 + files/dwm/config.h | 158 ----------- files/dwm/dwm-lock.sh | 5 - files/dwm/dwm-start.sh | 18 -- files/dwm/dwm-status.sh | 26 -- files/dwm/dwm-sync.sh | 7 - files/dwm/dwm.desktop | 6 - files/home/.config/kanshi/config | 9 - files/home/.config/kitty/kitty.conf | 1 - files/home/.config/rofi/config.rasi | 1 - files/home/.config/sway/config | 248 ------------------ files/home/.config/sway/status.py | 25 -- files/home/.config/sway/status.sh | 16 -- files/home/.zsh_preferences | 2 - files/home/.zsh_scripts | 49 ---- files/home/.zshrc | 35 --- files/root/etc/pacman.conf | 100 ------- files/root/etc/pacman.d/mirrorlist | 11 - gpackage.list | 3 - .../.config/alacritty/alacritty.yml | 0 {files/home => home}/.vimrc | 1 + hop.sh | 15 -- package.list | 4 - scripts/00-install-requirements.sh | 6 - scripts/05-zsh.sh | 32 --- scripts/10-copy-files.sh | 8 - scripts/20-install-pkgs.sh | 23 -- scripts/30-dwm.sh | 49 ---- sync.sh | 126 +++++++-- unlink.sh | 10 + 40 files changed, 239 insertions(+), 894 deletions(-) delete mode 100755 compatibility/fedora.sh create mode 100644 distros/alpine/pm.sh create mode 100644 distros/any/package.list create mode 100644 distros/any/root/etc/sudoers create mode 100644 distros/arch/package.list create mode 100644 distros/arch/pm.sh create mode 100644 distros/arch/root/etc/pacman.conf create mode 100644 distros/arch/sys-scripts/00-reflector.sh create mode 100644 distros/arch/user-scripts/00-yay.sh delete mode 100644 files/dwm/config.h delete mode 100755 files/dwm/dwm-lock.sh delete mode 100755 files/dwm/dwm-start.sh delete mode 100755 files/dwm/dwm-status.sh delete mode 100755 files/dwm/dwm-sync.sh delete mode 100644 files/dwm/dwm.desktop delete mode 100644 files/home/.config/kanshi/config delete mode 120000 files/home/.config/kitty/kitty.conf delete mode 100755 files/home/.config/rofi/config.rasi delete mode 100755 files/home/.config/sway/config delete mode 100755 files/home/.config/sway/status.py delete mode 100755 files/home/.config/sway/status.sh delete mode 100644 files/home/.zsh_preferences delete mode 100644 files/home/.zsh_scripts delete mode 100644 files/home/.zshrc delete mode 100644 files/root/etc/pacman.conf delete mode 100644 files/root/etc/pacman.d/mirrorlist delete mode 100644 gpackage.list rename {files/home => home}/.config/alacritty/alacritty.yml (100%) rename {files/home => home}/.vimrc (96%) mode change 100755 => 100644 delete mode 100755 hop.sh delete mode 100644 package.list delete mode 100644 scripts/00-install-requirements.sh delete mode 100644 scripts/05-zsh.sh delete mode 100644 scripts/10-copy-files.sh delete mode 100644 scripts/20-install-pkgs.sh delete mode 100644 scripts/30-dwm.sh mode change 100755 => 100644 sync.sh create mode 100644 unlink.sh diff --git a/.gitignore b/.gitignore index 62c8935..e0318d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.idea/ \ No newline at end of file +.idea/ +.dotfiles/ \ No newline at end of file diff --git a/README.md b/README.md index 2e5da9f..e6074a3 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ -# Faulty's Dotfiles -Version: 3 +# Dotfiles ---- - -## file sync -files in `./files` are synced across the system. -files in `./files/home` are synced to the home of the user running the script. -files in `./files/root` are synced with sudo to the root of the script. \ No newline at end of file +## `distros/` +This directory is meant to setup the distro to the liking of the user. +### `distros/*/root` +Contains files to overlay over the executing system. +### `distro/*/sys-scripts` +scripts that are ran as `root` +### `distro/*/user-scripts` +scripts that are ran as the user \ No newline at end of file diff --git a/compatibility/fedora.sh b/compatibility/fedora.sh deleted file mode 100755 index bc85691..0000000 --- a/compatibility/fedora.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -export SUDO=sudo - -export PM=dnf -export PM_INSTALL=install -export PM_NOCONFIRM=-y - -$SUDO dnf update -[ "${NO_GRAPHICS:-no}" = "yes" ] || $SUDO $PM $PM_INSTALL $PM_NOCONFIRM libX11-devel libXft-devel libXinerama-devel libXrandr-devel xorg-x11-xinit-session - -[ -f ./sync.sh ] && ./sync.sh $@ || (cd .. && ./sync.sh $@) \ No newline at end of file diff --git a/distros/alpine/pm.sh b/distros/alpine/pm.sh new file mode 100644 index 0000000..90eac36 --- /dev/null +++ b/distros/alpine/pm.sh @@ -0,0 +1,19 @@ +cmd="apk" +while getopts "icru" opt; do + case $opt in + i) + cmd="$cmd add" + ;; + u) + cmd="$cmd add" + r) + cmd="$cmd remove" + ;; + c) + cmd="$cmd info -q" + ;; + esac +done +shift $((OPTIND-1)) + +$cmd $@ \ No newline at end of file diff --git a/distros/any/package.list b/distros/any/package.list new file mode 100644 index 0000000..53b3000 --- /dev/null +++ b/distros/any/package.list @@ -0,0 +1,4 @@ +neofetch +git +vim +sudo \ No newline at end of file diff --git a/distros/any/root/etc/sudoers b/distros/any/root/etc/sudoers new file mode 100644 index 0000000..e77799b --- /dev/null +++ b/distros/any/root/etc/sudoers @@ -0,0 +1,4 @@ +root ALL=(ALL:ALL) ALL +%wheel ALL=(ALL:ALL) ALL +%root ALL=(ALL:ALL) NOPASSWD: ALL +@includedir /etc/sudoers.d diff --git a/distros/arch/package.list b/distros/arch/package.list new file mode 100644 index 0000000..c3e02c8 --- /dev/null +++ b/distros/arch/package.list @@ -0,0 +1,2 @@ +reflector # for scripts/00-reflector.sh +alacritty # favourite terminal emulator \ No newline at end of file diff --git a/distros/arch/pm.sh b/distros/arch/pm.sh new file mode 100644 index 0000000..0fd802c --- /dev/null +++ b/distros/arch/pm.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +cmd="pacman --noconfirm" +while getopts "icru" opt; do + case $opt in + i) + cmd="$cmd -S" + ;; + u) + cmd="$cmd -Syyu" + ;; + r) + cmd="$cmd -R" + ;; + c) + cmd="$cmd -Q" + ;; + esac +done +shift $((OPTIND-1)) + +$cmd $@ \ No newline at end of file diff --git a/distros/arch/root/etc/pacman.conf b/distros/arch/root/etc/pacman.conf new file mode 100644 index 0000000..e63be35 --- /dev/null +++ b/distros/arch/root/etc/pacman.conf @@ -0,0 +1,31 @@ +[options] +HoldPkg = pacman glibc yay +Architecture = auto + +Color +CheckSpace +ParallelDownloads = 5 + +SigLevel = Required DatabaseOptional +LocalFileSigLevel = Optional + +#[testing] +#Include = /etc/pacman.d/mirrorlist + +[core] +Include = /etc/pacman.d/mirrorlist + +[extra] +Include = /etc/pacman.d/mirrorlist + +#[community-testing] +#Include = /etc/pacman.d/mirrorlist + +[community] +Include = /etc/pacman.d/mirrorlist + +#[multilib-testing] +#Include = /etc/pacman.d/mirrorlist + +[multilib] +Include = /etc/pacman.d/mirrorlist diff --git a/distros/arch/sys-scripts/00-reflector.sh b/distros/arch/sys-scripts/00-reflector.sh new file mode 100644 index 0000000..7d2aa9d --- /dev/null +++ b/distros/arch/sys-scripts/00-reflector.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# Sets up fast mirrors on arch + +if ! pacman -Q reflector; then + echo "reflector was not installed" + exit 1 +fi + +cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak +reflector -c NL -f 10 --threads 4 --save /etc/pacman.d/mirrorlist +echo "Server = arch.neo.faulty.nl/$repo/os/$arch" >> /etc/pacman.d/mirrorlist \ No newline at end of file diff --git a/distros/arch/user-scripts/00-yay.sh b/distros/arch/user-scripts/00-yay.sh new file mode 100644 index 0000000..4ce4631 --- /dev/null +++ b/distros/arch/user-scripts/00-yay.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# Installs yay. + +[ "$UID" = "0" ] || exit 0 + +yaytmpdir=$(mktemp -d) + +git clone https://aur.archlinux.org/yay $yaytmpdir +oldpwd=$(pwd) +cd $yaytmpdir +makepkg -si +cd $oldpwd diff --git a/files/dwm/config.h b/files/dwm/config.h deleted file mode 100644 index d957645..0000000 --- a/files/dwm/config.h +++ /dev/null @@ -1,158 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -#include - -/* appearance */ -static const unsigned int borderpx = 2; /* border pixel of windows */ -static const unsigned int snap = 32; /* snap pixel */ -static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */ -static const unsigned int systrayonleft = 0; /* 0: systray in the right corner, >0: systray on left of status text */ -static const unsigned int systrayspacing = 2; /* systray spacing */ -static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/ -static const int showsystray = 1; /* 0 means no systray */ -static const int showbar = 1; /* 0 means no bar */ -static const int topbar = 1; /* 0 means bottom bar */ -static const char *fonts[] = { "monospace:size=10" }; -static const char dmenufont[] = "monospace:size=10"; - -static const char col_bg_inactive[] = "#444444"; -static const char col_fg_inactive[] = "#bbbbbb"; - -static const char col_bg_highlight[] = "#ffaaaa"; -static const char col_fg_highlight[] = "#000000"; - -static const char *colors[][3] = { - /* fg bg border */ - [SchemeNorm] = { col_fg_inactive, col_bg_inactive, col_bg_inactive }, - [SchemeSel] = { col_fg_highlight, col_bg_highlight, col_bg_highlight } -}; - -/* tagging */ -static const char *tags[] = { "main", "term", "www", "chat", "5", "6", "7", "8", "9", }; - -static const Rule rules[] = { - /* class instance title tags mask isfloating monitor */ - { "Gimp", NULL, NULL, 0, True, -1 }, - { "firefox", NULL, NULL, 1 << 2, False, -1 }, - { "discord", NULL, NULL, 1 << 3, False, -1 }, - { "Thunderbird", NULL, NULL, 2, False, -1 }, - { "stalonetray", NULL, NULL, 1, False, -1 }, - { "chrome", NULL, NULL, 4, False, -1 }, -}; - -/* layout(s) */ -static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ -static const Bool resizehints = True; /* True means respect size hints in tiled resizals */ -static const int nmaster = 1; /* number of clients in master area */ -static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ - -static const Layout layouts[] = { - /* symbol arrange function */ - { "[]=", tile }, /* first entry is default */ - { "><>", NULL }, /* no layout function means floating behavior */ - { "[M]", monocle }, -}; - -/* key definitions */ -#define MODKEY Mod4Mask -#define TAGKEYS(KEY,TAG) \ - { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ - { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ - { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ - { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, - -/* helper for spawning shell commands in the pre dwm-5.0 fashion */ -#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } - -/* commands */ - -// dmenu -static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ -static const char *dmenucmd[] = { - "dmenu_run", - "-m", dmenumon, - "-fn", dmenufont, - "-nb", col_bg_inactive, - "-nf", col_fg_inactive, - "-sb", col_bg_highlight, - "-sf", col_fg_highlight, NULL }; - -// terminal -static const char *termcmd[] = { "alacritty", NULL }; - -// general & sys -static const char *locksaver[] = { "/usr/local/bin/dwm-lock", NULL }; -static const char *vol_up[] = { "amixer", "set", "Master", "5%+", NULL }; -static const char *vol_down[] = { "amixer", "set", "Master", "5%-", NULL }; -static const char *vol_mute[] = { "amixer", "set", "Master", "toggle", NULL }; -static const char *light_up[] = {"light", "-A", "5", NULL}; -static const char *light_down[] = {"light", "-U", "5", NULL}; - -// screenshots -static const char *screenshot[] = {"flameshot", "full", "-c", NULL}; -static const char *screenshot_partial[] = {"flameshot", "gui", "-c", NULL}; - -// kill dwm -static const char *dwmdie[] = {"/bin/sh", "-c", "pkill dwm-start && pkill dwm", "null"}; - -static Key keys[] = { - /* modifier key function argument */ - { MODKEY, XK_Return, spawn, {.v = termcmd } }, - { MODKEY|ShiftMask, XK_d, spawn, {.v = dmenucmd } }, - { MODKEY|ShiftMask, XK_e, spawn, {.v = dwmdie } }, - { MODKEY, XK_l, spawn, {.v = locksaver } }, - { MODKEY, XK_b, togglebar, {0} }, - { MODKEY, XK_j, focusstack, {.i = +1 } }, - { MODKEY, XK_k, focusstack, {.i = -1 } }, - { MODKEY|Mod1Mask, XK_h, incnmaster, {.i = +1} }, - { MODKEY|Mod1Mask, XK_u, incnmaster, {.i = -1} }, - { MODKEY|ShiftMask, XK_Return, zoom, {0} }, - { MODKEY, XK_Tab, view, {0} }, - { MODKEY|ShiftMask, XK_c, killclient, {0} }, - { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, - { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, - { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, - { MODKEY, XK_space, setlayout, {0} }, - { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, - { MODKEY, XK_0, view, {.ui = ~0 } }, - { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, - { MODKEY, XK_comma, focusmon, {.i = -1 } }, - { MODKEY, XK_period, focusmon, {.i = +1 } }, - { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, - { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, - { 0, XK_Print, spawn, {.v = screenshot } }, - { Mod1Mask, XK_Print, spawn, {.v = screenshot_partial } }, - { 0, XF86XK_AudioRaiseVolume, spawn, {.v = vol_up } }, - { 0, XF86XK_AudioLowerVolume, spawn, {.v = vol_down } }, - { 0, XF86XK_AudioMute, spawn, {.v = vol_mute } }, - { 0, XF86XK_MonBrightnessUp, spawn, {.v = light_up} }, - { 0, XF86XK_MonBrightnessDown, spawn, {.v = light_down} }, - TAGKEYS( XK_1, 0) - TAGKEYS( XK_2, 1) - TAGKEYS( XK_3, 2) - TAGKEYS( XK_4, 3) - TAGKEYS( XK_5, 4) - TAGKEYS( XK_6, 5) - TAGKEYS( XK_7, 6) - TAGKEYS( XK_8, 7) - TAGKEYS( XK_9, 8) - { MODKEY|ShiftMask|Mod1Mask, XK_q, quit, {0} }, -}; - -/* button definitions */ -/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ -static Button buttons[] = { - /* click event mask button function argument */ - { ClkLtSymbol, 0, Button1, setlayout, {0} }, - { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, - { ClkWinTitle, 0, Button2, zoom, {0} }, - { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, - { ClkClientWin, MODKEY, Button1, movemouse, {0} }, - { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, - { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, - { ClkTagBar, 0, Button1, view, {0} }, - { ClkTagBar, 0, Button3, toggleview, {0} }, - { ClkTagBar, MODKEY, Button1, tag, {0} }, - { ClkTagBar, MODKEY, Button3, toggletag, {0} }, -}; - diff --git a/files/dwm/dwm-lock.sh b/files/dwm/dwm-lock.sh deleted file mode 100755 index 2ce99e0..0000000 --- a/files/dwm/dwm-lock.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -touch /tmp/$USER-screen.lock -i3lock ${@:--nefc "#000000"} -rm -f /tmp/$USER-screen.lock diff --git a/files/dwm/dwm-start.sh b/files/dwm/dwm-start.sh deleted file mode 100755 index 88c7cd4..0000000 --- a/files/dwm/dwm-start.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -LITE=${LITE:-no} - -xsetroot -solid black - -start_apps() { - nm-applet & - flameshot & - discord & - firefox & -} - -[ "$LITE" = "yes" ] || /usr/local/bin/dwm-status & -[ "$LITE" = "yes" ] || (sleep 1 && start_apps) & - -feh -zZ --bg-scale $HOME/Pictures/background.* -[ "${NO_DWM:-no}" = "yes" ] || exec dwm >/dev/null diff --git a/files/dwm/dwm-status.sh b/files/dwm/dwm-status.sh deleted file mode 100755 index bfa8a91..0000000 --- a/files/dwm/dwm-status.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -xsetroot -solid black -name "starting dwm..." - -#while loop to update statusbar with some goodies -while true; do - sleep 1 - [ -f /tmp/$USER-screen.lock ] && continue - #memfreak to get it in MB - memfree=$(grep MemFree /proc/meminfo | awk '{ print $2 }') - memtotal=$(grep MemTotal /proc/meminfo | awk '{ print $2 }') - memfreak=$(((memtotal - memfree) / 1024)) - #time - CLK=$(date +'%a %b %d %R:%S %Z') - #volume - VOL=$(amixer get Master | tail -1 | awk '{ print $5 }' | tr -d '[]') - #loadavg - AVG=$(cat /proc/loadavg | cut -d ' ' -f -3) - #network stats in Bytes - NW=$(dstat -n --nocolor 1 1 | tail -1 | awk '{ print $1, $2}') - battper=$(cat /sys/class/power_supply/BAT0/capacity) - #this one is not so good, increases a delay of 1-2s of the updating. - #put it in the xsetrootname plz (tip of the day, do not put | as first char after " - xsetroot -name "$AVG | $memfreak MB | Bat: $battper% | Vol: $VOL | $CLK |" -done - diff --git a/files/dwm/dwm-sync.sh b/files/dwm/dwm-sync.sh deleted file mode 100755 index eb2f276..0000000 --- a/files/dwm/dwm-sync.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -pushd ~/.local/dotfiles -./sync.sh 30-dwm.sh -popd - -loginctl kill-user $USER \ No newline at end of file diff --git a/files/dwm/dwm.desktop b/files/dwm/dwm.desktop deleted file mode 100644 index 2f8e70f..0000000 --- a/files/dwm/dwm.desktop +++ /dev/null @@ -1,6 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Name=dwm -Comment=This session starts dwm -Exec=/usr/local/bin/dwm-start -Type=Application \ No newline at end of file diff --git a/files/home/.config/kanshi/config b/files/home/.config/kanshi/config deleted file mode 100644 index 5a245d2..0000000 --- a/files/home/.config/kanshi/config +++ /dev/null @@ -1,9 +0,0 @@ -profile school { - output "Iiyama North America PL2483H 1156290962278" mode 1920x1080 position 0,0 - output eDP-1 mode 1920x1080 position 1920,0 -} - -#profile sharing { -# output HDMI-A-1 mode 1920x1080 position 0,1080 -# output eDP-1 mode 1920x1080 position 0,0 -#} diff --git a/files/home/.config/kitty/kitty.conf b/files/home/.config/kitty/kitty.conf deleted file mode 120000 index de7259e..0000000 --- a/files/home/.config/kitty/kitty.conf +++ /dev/null @@ -1 +0,0 @@ -/home/didier/.local/dotfiles/./files/kitty/kitty.conf \ No newline at end of file diff --git a/files/home/.config/rofi/config.rasi b/files/home/.config/rofi/config.rasi deleted file mode 100755 index 1efb65f..0000000 --- a/files/home/.config/rofi/config.rasi +++ /dev/null @@ -1 +0,0 @@ -@theme "Arc-Dark" diff --git a/files/home/.config/sway/config b/files/home/.config/sway/config deleted file mode 100755 index 2b78650..0000000 --- a/files/home/.config/sway/config +++ /dev/null @@ -1,248 +0,0 @@ -# Faulty's sway Config - - -set $mod Mod1 -set $sup Mod4 -set $terminal alacritty #sway-sensible-terminal -set $browser firefox -set $editor gedit - -#font pango:monospace 8 -font pango:DejaVu Sans Mono 8 - -#! Startup Applications -exec --no-startup-id kanshi -exec --no-startup-id xss-lock --transfer-sleep-lock -- swaylock --nofork -exec --no-startup-id gnome-keyring-daemon --start --components=ssh,secrets,pkcs11 -exec --no-startup-id nm-applet -exec thunderbird -exec discord - -set $lock swaylock -c "#000000" - -set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (Shift+r) reboot, (Shift+s) shutdown -mode "$mode_system" { - bindsym l exec --no-startup-id $lock, mode "default" - bindsym e exec --no-startup-id sway exit, mode "default" - bindsym s exec --no-startup-id $lock && systemctl suspend, mode "default" - bindsym h exec --no-startup-id $lock && systemctl hibernate, mode "default" - bindsym Shift+r exec --no-startup-id systemctl reboot, mode "default" - bindsym Shift+s exec --no-startup-id systemctl poweroff -i, mode "default" - - # back to normal: Enter or Escape - bindsym Return mode "default" - bindsym Escape mode "default" - -} -bindsym $sup+Delete mode "$mode_system" -bindsym $sup+l exec --no-startup-id $lock - -#! Media -bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_swaystatus -bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_swaystatus -bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_swaystatus -bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_swaystatus - -#! Light -bindsym XF86MonBrightnessUp exec light -A 10 # increase screen brightness -bindsym XF86MonBrightnessDown exec light -U 10 # decrease screen brightness - -#! Customization -# class border backgr. text indicator child_border -client.focused #000000 #222299 #ffffff #000000 #222222 -client.focused_inactive #333333 #5f676a #ffffff #484e50 #5f676a -client.unfocused #333333 #222222 #888888 #292d2e #222222 -client.urgent #EF2929 #900000 #ffffff #900000 #900000 -client.placeholder #000000 #0c0c0c #ffffff #000000 #0c0c0c -client.background #888A85 -#exec --no-startup-id xsetroot -solid "#333333" -exec --no-startup-id swaybg -i ~/Pictures/background.png -no_focus [class="Fig" instance="fig" window_role="autocomplete"] -for_window [class="Fig" instance="fig" window_role="autocomplete"] border pixel 0 - -#! Navigation -set $up l -set $down k -set $left j -set $right semicolon - -# use Mouse+Mod1 to drag floating windows to their wanted position -floating_modifier $sup - -#! Applications -bindsym $sup+Return exec $terminal -bindsym $sup+q exec $browser -bindsym $sup+d exec rofi -show run -bindsym $sup+Shift+d exec --no-startup-id rofi -show drun -bindsym Ctrl+Print exec --no-startup-id grim ~/Pictures/Screenshots/$(date +"%d-%m-%y_%H:%M:%S").png -bindsym Print exec --no-startup-id grim - | xclip -selection clipboard -t image/png - -# kill focused window -bindsym $sup+Shift+q kill - -# change focus -bindsym $mod+$left focus left -bindsym $mod+$down focus down -bindsym $mod+$up focus up -bindsym $mod+$right focus right - -# alternatively, you can use the cursor keys: -bindsym $mod+Left focus left -bindsym $mod+Down focus down -bindsym $mod+Up focus up -bindsym $mod+Right focus right - -# move focused window -bindsym $mod+Shift+$left move left -bindsym $mod+Shift+$down move down -bindsym $mod+Shift+$up move up -bindsym $mod+Shift+$right move right - -# alternatively, you can use the cursor keys: -bindsym $mod+Shift+Left move left -bindsym $mod+Shift+Down move down -bindsym $mod+Shift+Up move up -bindsym $mod+Shift+Right move right - -# split in horizontal orientation -bindsym $mod+h split h - -# split in vertical orientation -bindsym $mod+v split v - -# enter fullscreen mode for the focused container -bindsym $mod+f fullscreen toggle - -#! Layouts -# change container layout (stacked, tabbed, toggle split) -bindsym $sup+s layout stacking -bindsym $sup+w layout tabbed -bindsym $sup+e layout toggle split - -# toggle tiling / floating -bindsym $mod+Shift+space floating toggle - -# change focus between tiling / floating windows -bindsym $mod+space focus mode_toggle - -# focus the parent container -bindsym $mod+a focus parent - -# focus the child container -#bindsym Mod1+d focus child - -# move the currently focused window to the scratchpad -bindsym $sup+Shift+minus move scratchpad - -# Show the next scratchpad window or hide the focused scratchpad window. -# If there are multiple scratchpad windows, this command cycles through them. -bindsym $sup+minus scratchpad show - -# Define names for default workspaces for which we configure key bindings later on. -# We use variables to avoid repeating the names in multiple places. -#! Workspaces -set $ws1 "1: main" -set $ws2 "2: browse" -set $ws3 "3: term" -set $ws4 "4: other" -set $ws5 "5: other" -set $ws6 "6: other" -set $ws7 "7: other" -set $ws8 "8: business" -set $ws9 "9: talk" -set $ws10 "10: misc" - -#! Assignments -assign [class="Spotify"] $ws10 -assign [class="firefox"] $ws2 -assign [class="thunderbird"] $ws8 -assign [class="discord"] $ws9 -assign [class="jetbrains-idea-ce"] $ws1 - -bindsym $sup+$left workspace prev -bindsym $sup+$right workspace next -# alter.. youknow what is coming -bindsym $sup+Left workspace prev -bindsym $sup+Right workspace next - -# switch to workspace -bindsym $sup+1 workspace number $ws1 -bindsym $sup+2 workspace number $ws2 -bindsym $sup+3 workspace number $ws3 -bindsym $sup+4 workspace number $ws4 -bindsym $sup+5 workspace number $ws5 -bindsym $sup+6 workspace number $ws6 -bindsym $sup+7 workspace number $ws7 -bindsym $sup+8 workspace number $ws8 -bindsym $sup+9 workspace number $ws9 -bindsym $sup+0 workspace number $ws10 - -# move focused container to workspace -bindsym $sup+Shift+1 move container to workspace number $ws1 -bindsym $sup+Shift+2 move container to workspace number $ws2 -bindsym $sup+Shift+3 move container to workspace number $ws3 -bindsym $sup+Shift+4 move container to workspace number $ws4 -bindsym $sup+Shift+5 move container to workspace number $ws5 -bindsym $sup+Shift+6 move container to workspace number $ws6 -bindsym $sup+Shift+7 move container to workspace number $ws7 -bindsym $sup+Shift+8 move container to workspace number $ws8 -bindsym $sup+Shift+9 move container to workspace number $ws9 -bindsym $sup+Shift+0 move container to workspace number $ws10 - -#! sway manage -# reload the configuration file -bindsym $sup+Shift+c reload -# restart sway inplace (preserves your layout/session, can be used to upgrade sway) -bindsym $sup+Shift+r restart -# exit sway (logs you out of your wayland session) -#bindsym $sup+Shift+e exec "swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your X session.' -B 'Yes, exit sway' 'sway exit'" -bindsym $sup+Shift+e exec wlogout -# edit config -bindsym $sup+Shift+Alt+c exec "$editor ~/.config/sway/config" - -#! Resize -# resize window (you can also use the mouse for that) -mode "resize" { - # These bindings trigger as soon as you enter the resize mode - - # Pressing left will shrink the windowโ€™s width. - # Pressing right will grow the windowโ€™s width. - # Pressing up will shrink the windowโ€™s height. - # Pressing down will grow the windowโ€™s height. - bindsym $left resize shrink width 10 px or 10 ppt - bindsym $down resize grow height 10 px or 10 ppt - bindsym $up resize shrink height 10 px or 10 ppt - bindsym $right resize grow width 10 px or 10 ppt - - # same bindings, but for the arrow keys - bindsym Left resize shrink width 10 px or 10 ppt - bindsym Down resize grow height 10 px or 10 ppt - bindsym Up resize shrink height 10 px or 10 ppt - bindsym Right resize grow width 10 px or 10 ppt - - # back to normal: Enter or Escape or Mod1+r - bindsym Return mode "default" - bindsym Escape mode "default" - bindsym $sup+r mode "default" -} - -bindsym $sup+r mode "resize" - -input "1102:4629:ALP0016:00_044E:1215" { - tap enabled - natural_scroll enabled -} - -bar { - position top - - # When the status_command prints a new line to stdout, swaybar updates. - # The default just shows the current date and time. - status_command while ~/.config/sway/status.sh; do printf ''; done - - colors { - statusline #ffffff - background #323232 - inactive_workspace #32323200 #32323200 #5c5c5c - } -} diff --git a/files/home/.config/sway/status.py b/files/home/.config/sway/status.py deleted file mode 100755 index 5a89322..0000000 --- a/files/home/.config/sway/status.py +++ /dev/null @@ -1,25 +0,0 @@ -import socket -from datetime import datetime -from psutil import disk_usage, sensors_battery -from psutil._common import bytes2human -import socket -from subprocess import check_output -from sys import stdout -from time import sleep - -def write(data): - stdout.write('%s\n' % data) - stdout.flush() - -def refresh(): - disk = f"{bytes2human(disk_usage('/').used)} / {bytes2human(disk_usage('/').total)} ({bytes2human(disk_usage('/').free)})" - hostname = socket.gethostname() - ip = socket.gethostbyname(hostname+".") - battery = int(sensors_battery().percent) - status = "Charging" if sensors_battery().power_plugged else "Discharging" - date = datetime.now().strftime('%h %d %A %H:%M:%S') - write(f"d: {disk} | n: {hostname} @ {ip} | b: {battery}% ({status.lower()[:3]}) | {date}") - -while True: - refresh() - sleep(1) diff --git a/files/home/.config/sway/status.sh b/files/home/.config/sway/status.sh deleted file mode 100755 index c8bcfc3..0000000 --- a/files/home/.config/sway/status.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -uptimef=$(uptime | cut -d ',' -f1 | cut -d ' ' -f4,5) -datef=$(date "+%a %F %H:%M:%S") -linux_version=$(uname -r | cut -d '-' -f1) -battery_status=$(cat /sys/class/power_supply/BAT0/status) -battery_percent=$(cat /sys/class/power_supply/BAT0/capacity) -#audio_volume=$(awk -F"[][]" '/Left:/ { print $2 }' <(amixer sget Master)) -audio_volume=$(pamixer --get-volume)% -disk_usage=$(df -kh / | grep dev | awk '{print $5}') -mem_used=$(free | awk '/Mem/{printf("%.2f%"), $3/$2*100}') -local_ip=$(ip addr show wlp58s0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1') - -# ๐Ÿ’Ž ๐Ÿ’ป ๐Ÿ’ก ๐Ÿ”Œ โšก ๐Ÿ“ \| -printf "๐Ÿ“ %3s | ๐Ÿ’Ž %7s | ๐Ÿ’ป %s | ๐Ÿ“ถ %s | ๐Ÿง %7s | ๐Ÿ”‹ %7s | ๐Ÿ”‰ %4s | %s\n" \ - "$disk_usage" "$mem_used" "$uptimef" "$local_ip" "$linux_version" "$battery_percent% ($battery_status)" "$audio_volume" "$datef" -sleep 1 diff --git a/files/home/.zsh_preferences b/files/home/.zsh_preferences deleted file mode 100644 index 2677a0e..0000000 --- a/files/home/.zsh_preferences +++ /dev/null @@ -1,2 +0,0 @@ -_ZSH_PREF_NO_PFETCH=0 -_ZSH_PREF_NO_NONSENSE=0 \ No newline at end of file diff --git a/files/home/.zsh_scripts b/files/home/.zsh_scripts deleted file mode 100644 index 7537861..0000000 --- a/files/home/.zsh_scripts +++ /dev/null @@ -1,49 +0,0 @@ -__is_arch() { - . /etc/os-release - if [ "$ID" = "arch" ]; then return 0; else return 1; fi -} - -pkg_once() { - if [ ! __is_arch ]; then - printf "This command is only for Arch Linux.\n" - return - fi - if [ ! -n "$1" ]; then - printf "Usage: pkg_once [command]\n" - printf "command is optional; if there is no command the package name is ran\n" - return - fi - printf "Installing $1...\n" - yay -S --noconfirm $1 > /dev/null - - if [ ! -n "$2" ]; then $1; else $2; fi - printf "Remoiving $1..." - yay -R --noconfirm $1 > /dev/null - echo "done.\n" -} - -rando () { - case $1 in - *|d|default) tr -dc A-Za-z0-9 ?@[\]^_`{|}~' > $file - fi - chmod +x $file - printf '%s' $file -} - -alias docurr="docker run -itd --rm --name current" diff --git a/files/home/.zshrc b/files/home/.zshrc deleted file mode 100644 index ec4a6f4..0000000 --- a/files/home/.zshrc +++ /dev/null @@ -1,35 +0,0 @@ -export GPG_TTY=$(tty) -source ~/.zsh_preferences - -# paths -export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" - -if [ $_ZSH_PREF_NO_NONSENSE != 1 ]; then -# ZSH -export ZSH="$HOME/.oh-my-zsh" - -ZSH_THEME="afowler" -plugins=(git docker docker-compose node zsh-autosuggestions zsh-syntax-highlighting) -source $ZSH/oh-my-zsh.sh - -source ~/.zsh_scripts - -# ALIASES -alias open="xdg-open" -alias nobeep="sudo modprobe -r pcspkr" -alias bl="sudo light -S" -alias kssh="kitty +kitten ssh" -alias get_idf='. $HOME/esp/esp-idf/export.sh' -alias get_rust='. $HOME/.cargo/env' -alias s="title $HOST && cmatrix -rs && clear" - -# COSMETICS -if [ $_ZSH_PREF_NO_PFETCH != 1 ]; then fastfetch; fi - -else -PS1="$(whoami)@$(cat /etc/hostname) $ " -fi - -alias q="exit" -export PATH="${PATH}:/home/${USER}/.local/bin" -export SSH_AUTH_SOCK="/run/user/1000/keyring/ssh" diff --git a/files/root/etc/pacman.conf b/files/root/etc/pacman.conf deleted file mode 100644 index 12cabfa..0000000 --- a/files/root/etc/pacman.conf +++ /dev/null @@ -1,100 +0,0 @@ -# -# /etc/pacman.conf -# -# See the pacman.conf(5) manpage for option and repository directives - -# -# GENERAL OPTIONS -# -[options] -# The following paths are commented out with their default values listed. -# If you wish to use different paths, uncomment and update the paths. -#RootDir = / -#DBPath = /var/lib/pacman/ -#CacheDir = /var/cache/pacman/pkg/ -#LogFile = /var/log/pacman.log -#GPGDir = /etc/pacman.d/gnupg/ -#HookDir = /etc/pacman.d/hooks/ -HoldPkg = pacman glibc -#XferCommand = /usr/bin/curl -L -C - -f -o %o %u -#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u -#CleanMethod = KeepInstalled -Architecture = auto - -# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup -#IgnorePkg = -#IgnoreGroup = - -#NoUpgrade = -#NoExtract = - -# Misc options -#UseSyslog -#Color -#NoProgressBar -CheckSpace -#VerbosePkgLists -ParallelDownloads = 5 - -# By default, pacman accepts packages signed by keys that its local keyring -# trusts (see pacman-key and its man page), as well as unsigned packages. -SigLevel = Required DatabaseOptional -LocalFileSigLevel = Optional -#RemoteFileSigLevel = Required - -# NOTE: You must run `pacman-key --init` before first using pacman; the local -# keyring can then be populated with the keys of all official Arch Linux -# packagers with `pacman-key --populate archlinux`. - -# -# REPOSITORIES -# - can be defined here or included from another file -# - pacman will search repositories in the order defined here -# - local/custom mirrors can be added here or in separate files -# - repositories listed first will take precedence when packages -# have identical names, regardless of version number -# - URLs will have $repo replaced by the name of the current repo -# - URLs will have $arch replaced by the name of the architecture -# -# Repository entries are of the format: -# [repo-name] -# Server = ServerName -# Include = IncludePath -# -# The header [repo-name] is crucial - it must be present and -# uncommented to enable the repo. -# - -# The testing repositories are disabled by default. To enable, uncomment the -# repo name header and Include lines. You can add preferred servers immediately -# after the header, and they will be used before the default mirrors. - -#[testing] -#Include = /etc/pacman.d/mirrorlist - -[core] -Include = /etc/pacman.d/mirrorlist - -[extra] -Include = /etc/pacman.d/mirrorlist - -#[community-testing] -#Include = /etc/pacman.d/mirrorlist - -[community] -Include = /etc/pacman.d/mirrorlist - -# If you want to run 32 bit applications on your x86_64 system, -# enable the multilib repositories as required here. - -#[multilib-testing] -#Include = /etc/pacman.d/mirrorlist - -[multilib] -Include = /etc/pacman.d/mirrorlist - -# An example of a custom package repository. See the pacman manpage for -# tips on creating your own repositories. -#[custom] -#SigLevel = Optional TrustAll -#Server = file:///home/custompkgs diff --git a/files/root/etc/pacman.d/mirrorlist b/files/root/etc/pacman.d/mirrorlist deleted file mode 100644 index 013da94..0000000 --- a/files/root/etc/pacman.d/mirrorlist +++ /dev/null @@ -1,11 +0,0 @@ -# Mirrorlist for NL setup - -# Private mirror -Server = https://arch.neo.faulty.nl/$repo/os/$arch - -# Public mirrors -Server = http://mirror.mikrogravitation.org/archlinux/$repo/os/$arch -Server = http://mirror.wtnet.de/archlinux/$repo/os/$arch -Server = http://mirror.pagenotfound.de/archlinux/$repo/os/$arch -Server = http://mirror.informatik.tu-freiberg.de/arch/$repo/os/$arch -Server = http://ftp.snt.utwente.nl/pub/os/linux/archlinux/$repo/os/$arch diff --git a/gpackage.list b/gpackage.list deleted file mode 100644 index 2f78a0b..0000000 --- a/gpackage.list +++ /dev/null @@ -1,3 +0,0 @@ -alacritty -sway -kanshi diff --git a/files/home/.config/alacritty/alacritty.yml b/home/.config/alacritty/alacritty.yml similarity index 100% rename from files/home/.config/alacritty/alacritty.yml rename to home/.config/alacritty/alacritty.yml diff --git a/files/home/.vimrc b/home/.vimrc old mode 100755 new mode 100644 similarity index 96% rename from files/home/.vimrc rename to home/.vimrc index abb89b3..6f12643 --- a/files/home/.vimrc +++ b/home/.vimrc @@ -1,2 +1,3 @@ set number set relativenumber + diff --git a/hop.sh b/hop.sh deleted file mode 100755 index 06a1d1b..0000000 --- a/hop.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# need to hop? this script copies the important stuff. - -tar \ - --exclude={node_modules,target,dist,cache} \ - -cvf \ - ${TAR_FILE:-backup.tar} \ - ~/.ssh \ - ~/.config \ - ~/.mozilla \ - ~/Documents \ - ~/Pictures \ - ~/code \ - ~/environments diff --git a/package.list b/package.list deleted file mode 100644 index 1e45b12..0000000 --- a/package.list +++ /dev/null @@ -1,4 +0,0 @@ -curl -vim -zsh -docker diff --git a/scripts/00-install-requirements.sh b/scripts/00-install-requirements.sh deleted file mode 100644 index 33a1cf5..0000000 --- a/scripts/00-install-requirements.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -# This file only installs what is needed for the sync to perform... - -$SUDO $PM $PM_INSTALL $PM_NOCONFIRM \ - rsync \ No newline at end of file diff --git a/scripts/05-zsh.sh b/scripts/05-zsh.sh deleted file mode 100644 index 5a2c865..0000000 --- a/scripts/05-zsh.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -$SUDO $PM $PM_INSTALL $PM_NOCONFIRM \ - zsh \ - cmake # for fastfetch - -# install fastfetch -[ -d /tmp/fastfetch ] || \ - git clone https://github.com/LinusDierheimer/fastfetch /tmp/fastfetch - -if [ ! -f /tmp/fastfetch/build/fastfetch ]; then -pushd /tmp/fastfetch - mkdir -p build - pushd build - cmake .. - cmake --build . --target fastfetch - $SUDO mv fastfetch /usr/local/bin/fastfetch - popd -popd -fi - -# install omz -bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended || echo "zsh not installed" - -# favourite omz plugins -PL_DIR=${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions -[ -d "$PL_DIR" ] || git clone https://github.com/zsh-users/zsh-autosuggestions $PL_DIR -PL_DIR=${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting -[ -d "$PL_DIR" ] || git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $PL_DIR - -# set default shell -$SUDO usermod $USER --shell /bin/zsh \ No newline at end of file diff --git a/scripts/10-copy-files.sh b/scripts/10-copy-files.sh deleted file mode 100644 index e5c4941..0000000 --- a/scripts/10-copy-files.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -HOME_FILES=${HOME_FILES:-./files/home} -ROOT_FILES=${ROOT_FILES:-./files/root} - -# overwrite files but preserve files surrounding -rsync -av $HOME_FILES/ $HOME -$SUDO rsync -av $ROOT_FILES/ / \ No newline at end of file diff --git a/scripts/20-install-pkgs.sh b/scripts/20-install-pkgs.sh deleted file mode 100644 index 912f9cc..0000000 --- a/scripts/20-install-pkgs.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -PACKAGE_LIST=${PACKAGE_LIST:-./package.list} -GRAPHICAL_PACKAGE_LIST=${GRAPHICAL_PACKAGE_LIST:-./gpackage.list} - -_APPLICATIONS="" -while read -r pkg; do - [ -z "$pkg" ] && continue - [ "$(echo "$pkg" | cut -c1)" = "#" ] && continue - _APPLICATIONS="$_APPLICATIONS $pkg" -done < "$PACKAGE_LIST" - -if [ "${NO_GRAPHICS:-no}" = "no" ]; then - if [ -f "$GRAPHICAL_PACKAGE_LIST" ]; then - while read -r pkg; do - [ -z "$pkg" ] && continue - [ "$(echo "$pkg" | cut -c1)" = "#" ] && continue - _APPLICATIONS="$_APPLICATIONS $pkg" - done < "$GRAPHICAL_PACKAGE_LIST" - fi -fi - -$SUDO $PM $PM_INSTALL $PM_NOCONFIRM $_APPLICATIONS diff --git a/scripts/30-dwm.sh b/scripts/30-dwm.sh deleted file mode 100644 index 10a440a..0000000 --- a/scripts/30-dwm.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh - -# This file configures builds and installs DWM. - -[ "${NO_GRAPHICS:-no}" = "yes" ] && return 0 - -# install dependencies -$SUDO $PM $PM_INSTALL $PM_NOCONFIRM \ - feh \ - network-manager-applet \ - alsa-utils \ - dstat \ - curl \ - flameshot \ - dmenu \ - i3lock - -# clone -[ -d /tmp/dotfiles-dwm ] || git clone https://git.suckless.org/dwm /tmp/dotfiles-dwm - -# config -cp ./files/dwm/config.h /tmp/dotfiles-dwm/config.h - -# build, patch and install -pushd /tmp/dotfiles-dwm - -# patches -curl https://dwm.suckless.org/patches/systray/dwm-systray-6.4.diff -o /tmp/dwm-systray.diff -git apply -3 /tmp/dwm-systray.diff - -$SUDO make install -popd - -# dwm boot/manage scripts -chmod +x ./files/dwm/*.sh - -$SUDO cp ./files/dwm/dwm-start.sh /usr/local/bin/dwm-start -$SUDO cp ./files/dwm/dwm-status.sh /usr/local/bin/dwm-status -$SUDO cp ./files/dwm/dwm-sync.sh /usr/local/bin/dwm-sync -$SUDO cp ./files/dwm/dwm-lock.sh /usr/local/bin/dwm-lock - -$SUDO chmod +x /usr/local/bin/dwm-* - -# DM entry -$SUDO cp ./files/dwm/dwm.desktop /usr/share/xsessions/dwm.desktop - -# background -rm -rf $HOME/Pictures/background.* -curl https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/i/9757d496-239b-46c5-baea-6873cbfe9b3d/ddkbeml-015b05e6-6f8f-471e-a3a4-1c4360127ea6.jpg -o $HOME/Pictures/background.jpg diff --git a/sync.sh b/sync.sh old mode 100755 new mode 100644 index b44e920..c3a4b09 --- a/sync.sh +++ b/sync.sh @@ -1,24 +1,118 @@ #!/bin/sh -SUDO=${SUDO:-sudo} +osreleaseprop() { + cat /etc/os-release | grep -e "^$1=" | sed 's/ID=//' +} -PM=${PM:-pacman} -PM_INSTALL=${PM_INSTALL:--S} -PM_NOCONFIRM=${PM_NOCONFIRM:---noconfirm} - -set -e - -main() { - if [ ! -z "$@" ]; then - . ./scripts/$@ - exit 0 +elevated() { + s=${SUDO:-sudo} + if [ ! "$s" = "none" ]; then + if ! which $s &> /dev/null; then + echo "command \"$s\" not found" + exit 1 + fi + else + s="" fi - for script in ./scripts/* ; do - echo "# exec $script" - . $script + $s $@ +} + +DISTRO=$(osreleaseprop ID) +if [ ! -d "distros/$DISTRO" ]; then + echo "$DISTRO is not supported." + exit 1 +fi + +pm() { + elevated "sh distros/$DISTRO/pm.sh $@" +} + +install_package_list() { + pkgs="" + [ -f "distros/${1:-$DISTRO}/package.list" ] || return 1 + for pkg in $(cat distros/${1:-$DISTRO}/package.list | sed 's/#.*$//'); do + pkgs="$pkgs $pkg" + done + pm -i $pkgs +} + +run_scripts() { + cmd=$1 + shift + case $cmd in + sys) + dir="distros/${1:-$DISTRO}/sys-scripts" + [ -d "$dir" ] || return + for s in $(ls $dir); do + echo "# running $dir/$s..." + elevated sh $dir/$s || exit 1 + done + ;; + user) + dir="distros/${1:-$DISTRO}/user-scripts" + [ -d "$dir" ] || return + for s in $(ls $dir); do + echo "# running $dir/$s..." + sh $dir/$s || exit 1 + done + ;; + esac +} + +overlay() { + [ -d "distros/${1:-$DISTRO}/root" ] || return 0 + elevated cp -r distros/${1:-$DISTRO}/root / +} + +__step_update() { + echo "# updating system..." + pm -u +} + +__step_install_package_list() { + echo "# installing package lists..." + install_package_list any + install_package_list +} + +__step_run_system_scripts() { + echo "# running system scripts..." + run_scripts sys any + run_scripts sys +} + +__step_run_user_scripts() { + echo "# running user scripts..." + run_scripts user any + run_scripts user +} + +__step_overlay() { + echo "# overlaying root directories..." + overlay any + overlay +} + +__step_link_home() { + echo "# linking all home files..." + trackingfile=".dotfiles/$(git rev-parse HEAD)-links" + for item in $(find ./home -type f); do + path=$(echo $item | sed "s/\.\/home//") + [ -z "$path" ] && continue + path="$HOME$path" + mkdir -p $(dirname $path) &> /dev/null + ln $item $path && echo "$path" >> $trackingfile done } -main "$@" +mkdir -p .dotfiles &> /dev/null -echo "# OK" +if [ -n "$1" ]; then + $(printf "__step_%s" "$1") +else + __step_update + __step_install_package_list + __step_run_system_scripts + __step_run_user_scripts + __step_overlay +fi diff --git a/unlink.sh b/unlink.sh new file mode 100644 index 0000000..3650aa8 --- /dev/null +++ b/unlink.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +for linkfile in $@; do + echo "# processing linkfile $linkfile..." + for link in $(cat $linkfile); do + echo "# unlinking $link..." + unlink $link + done + rm -rf $linkfile +done \ No newline at end of file From ed88d0a5b55107383f48040187cc487886562f90 Mon Sep 17 00:00:00 2001 From: Didier Date: Wed, 23 Aug 2023 06:16:08 +0200 Subject: [PATCH 2/8] fix: add link home step --- sync.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/sync.sh b/sync.sh index c3a4b09..593f38a 100644 --- a/sync.sh +++ b/sync.sh @@ -114,5 +114,6 @@ else __step_install_package_list __step_run_system_scripts __step_run_user_scripts + __step_link_home __step_overlay fi From bfa0f9a0c70de14cb70a286b2a48cd6942ab2f74 Mon Sep 17 00:00:00 2001 From: Didier Date: Wed, 23 Aug 2023 06:36:14 +0200 Subject: [PATCH 3/8] feat: add some utils like tracking --- skip_steps.sh | 7 +++++++ sync.sh | 27 ++++++++++++++++++++------- unlink.sh | 2 +- 3 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 skip_steps.sh diff --git a/skip_steps.sh b/skip_steps.sh new file mode 100644 index 0000000..b6e9ee1 --- /dev/null +++ b/skip_steps.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +mkdir .dotfiles &>/dev/null + +for item in ${@:-update install_package_list run_system_scripts run_user_scripts link_home overlay}; do + echo "executed_step:$item" >> .dotfiles/pending_sync +done \ No newline at end of file diff --git a/sync.sh b/sync.sh index 593f38a..4b8f01a 100644 --- a/sync.sh +++ b/sync.sh @@ -99,21 +99,34 @@ __step_link_home() { for item in $(find ./home -type f); do path=$(echo $item | sed "s/\.\/home//") [ -z "$path" ] && continue + grep -q "$path" $trackingfile &> /dev/null && continue path="$HOME$path" mkdir -p $(dirname $path) &> /dev/null ln $item $path && echo "$path" >> $trackingfile done } +step() { + if ! grep -q "executed_step:$1" .dotfiles/pending_sync &> /dev/null; then + $(printf "__step_%s" "$1") + echo "executed_step:$1" >> .dotfiles/pending_sync + fi +} + mkdir -p .dotfiles &> /dev/null +touch .dotfiles/pending_sync if [ -n "$1" ]; then - $(printf "__step_%s" "$1") + step $1 else - __step_update - __step_install_package_list - __step_run_system_scripts - __step_run_user_scripts - __step_link_home - __step_overlay + echo "started_sync:$(date)" >> .dotfiles/log + step update + step install_package_list + step run_system_scripts + step run_user_scripts + step link_home + step overlay + echo "finished_sync:$(date)" >> .dotfiles/log fi + +unlink .dotfiles/pending_sync diff --git a/unlink.sh b/unlink.sh index 3650aa8..44e593c 100644 --- a/unlink.sh +++ b/unlink.sh @@ -1,6 +1,6 @@ #!/bin/sh -for linkfile in $@; do +for linkfile in ${@:-$(find .dotfiles -type f -name *-links)}; do echo "# processing linkfile $linkfile..." for link in $(cat $linkfile); do echo "# unlinking $link..." From 09709a39f74de7e8ed48bd119d63874250c7859a Mon Sep 17 00:00:00 2001 From: Didier Date: Wed, 23 Aug 2023 06:47:44 +0200 Subject: [PATCH 4/8] fix: stuff --- sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sync.sh b/sync.sh index 4b8f01a..89ed355 100644 --- a/sync.sh +++ b/sync.sh @@ -7,7 +7,7 @@ osreleaseprop() { elevated() { s=${SUDO:-sudo} if [ ! "$s" = "none" ]; then - if ! which $s &> /dev/null; then + if ! command -v $s &> /dev/null; then echo "command \"$s\" not found" exit 1 fi From 2d96f7592b319de3ed4d2732c8536773a17d736b Mon Sep 17 00:00:00 2001 From: Didier Date: Wed, 23 Aug 2023 06:49:14 +0200 Subject: [PATCH 5/8] add apline config --- distros/alpine/package.list | 1 + distros/alpine/root/etc/doas.conf | 1 + distros/alpine/sys-scripts/00-remove-sudo.sh | 5 +++++ 3 files changed, 7 insertions(+) create mode 100644 distros/alpine/package.list create mode 100644 distros/alpine/root/etc/doas.conf create mode 100644 distros/alpine/sys-scripts/00-remove-sudo.sh diff --git a/distros/alpine/package.list b/distros/alpine/package.list new file mode 100644 index 0000000..9d32a57 --- /dev/null +++ b/distros/alpine/package.list @@ -0,0 +1 @@ +doas \ No newline at end of file diff --git a/distros/alpine/root/etc/doas.conf b/distros/alpine/root/etc/doas.conf new file mode 100644 index 0000000..c50a253 --- /dev/null +++ b/distros/alpine/root/etc/doas.conf @@ -0,0 +1 @@ +permit persit wheel \ No newline at end of file diff --git a/distros/alpine/sys-scripts/00-remove-sudo.sh b/distros/alpine/sys-scripts/00-remove-sudo.sh new file mode 100644 index 0000000..2845cb8 --- /dev/null +++ b/distros/alpine/sys-scripts/00-remove-sudo.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +# removes sudo + +apk del sudo \ No newline at end of file From 661be1811ba0308d35f338702fd8f3db5c125e19 Mon Sep 17 00:00:00 2001 From: Didier Date: Wed, 23 Aug 2023 06:50:19 +0200 Subject: [PATCH 6/8] fix: alpine pm impl --- distros/alpine/pm.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/distros/alpine/pm.sh b/distros/alpine/pm.sh index 90eac36..7560ed9 100644 --- a/distros/alpine/pm.sh +++ b/distros/alpine/pm.sh @@ -6,8 +6,9 @@ while getopts "icru" opt; do ;; u) cmd="$cmd add" + ;; r) - cmd="$cmd remove" + cmd="$cmd del" ;; c) cmd="$cmd info -q" From 33ee95006d919c97a2c0d6611564ba02328e5f45 Mon Sep 17 00:00:00 2001 From: Didier Date: Fri, 1 Sep 2023 03:34:08 +0200 Subject: [PATCH 7/8] feat: final-ish version --- crates/20-vim/crate.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 crates/20-vim/crate.sh diff --git a/crates/20-vim/crate.sh b/crates/20-vim/crate.sh new file mode 100644 index 0000000..3210eac --- /dev/null +++ b/crates/20-vim/crate.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +describe="Install vim and it's stuff" +scripts="@distro @self" + +apply() { + [ -e "$HOME/.vimrc" ] || ln files/.vimrc $HOME/.vimrc + [ -e "$HOME/.ideavimrc" ] || ln files/.ideavimrc $HOME/.ideavimrc +} + +undo() { + unlink $HOME/.vimrc + unlink $HOME/.ideavimrc +} \ No newline at end of file From 721a9d18131c96666cf08074e54077288fd79b72 Mon Sep 17 00:00:00 2001 From: Didier Date: Fri, 1 Sep 2023 03:34:16 +0200 Subject: [PATCH 8/8] stuff --- .gitignore | 2 - README.md | 10 -- crates/00-system/crate.arch.sh | 11 ++ crates/00-system/crate.sh | 7 + .../00-system/files}/pacman.conf | 0 .../etc => crates/00-system/files}/sudoers | 0 crates/10-zsh/crate.arch.sh | 7 + crates/10-zsh/crate.sh | 41 ++++++ crates/10-zsh/files/.zshrc | 23 +++ crates/20-vim/crate.arch.sh | 7 + crates/20-vim/files/.ideavimrc | 10 ++ {home => crates/20-vim/files}/.vimrc | 1 - crates/30-alacritty/crate.arch.sh | 7 + crates/30-alacritty/crate.sh | 12 ++ .../30-alacritty/files}/alacritty.yml | 4 - distros/alpine/package.list | 1 - distros/alpine/pm.sh | 20 --- distros/alpine/root/etc/doas.conf | 1 - distros/alpine/sys-scripts/00-remove-sudo.sh | 5 - distros/any/package.list | 4 - distros/arch/package.list | 2 - distros/arch/pm.sh | 22 --- distros/arch/sys-scripts/00-reflector.sh | 12 -- distros/arch/user-scripts/00-yay.sh | 13 -- dot | 85 +++++++++++ skip_steps.sh | 7 - sync.sh | 132 ------------------ unlink.sh | 10 -- 28 files changed, 210 insertions(+), 246 deletions(-) delete mode 100644 .gitignore delete mode 100644 README.md create mode 100644 crates/00-system/crate.arch.sh create mode 100644 crates/00-system/crate.sh rename {distros/arch/root/etc => crates/00-system/files}/pacman.conf (100%) rename {distros/any/root/etc => crates/00-system/files}/sudoers (100%) create mode 100644 crates/10-zsh/crate.arch.sh create mode 100644 crates/10-zsh/crate.sh create mode 100644 crates/10-zsh/files/.zshrc create mode 100644 crates/20-vim/crate.arch.sh create mode 100644 crates/20-vim/files/.ideavimrc rename {home => crates/20-vim/files}/.vimrc (96%) create mode 100644 crates/30-alacritty/crate.arch.sh create mode 100644 crates/30-alacritty/crate.sh rename {home/.config/alacritty => crates/30-alacritty/files}/alacritty.yml (56%) delete mode 100644 distros/alpine/package.list delete mode 100644 distros/alpine/pm.sh delete mode 100644 distros/alpine/root/etc/doas.conf delete mode 100644 distros/alpine/sys-scripts/00-remove-sudo.sh delete mode 100644 distros/any/package.list delete mode 100644 distros/arch/package.list delete mode 100644 distros/arch/pm.sh delete mode 100644 distros/arch/sys-scripts/00-reflector.sh delete mode 100644 distros/arch/user-scripts/00-yay.sh create mode 100755 dot delete mode 100644 skip_steps.sh delete mode 100644 sync.sh delete mode 100644 unlink.sh diff --git a/.gitignore b/.gitignore deleted file mode 100644 index e0318d4..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.idea/ -.dotfiles/ \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index e6074a3..0000000 --- a/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# Dotfiles - -## `distros/` -This directory is meant to setup the distro to the liking of the user. -### `distros/*/root` -Contains files to overlay over the executing system. -### `distro/*/sys-scripts` -scripts that are ran as `root` -### `distro/*/user-scripts` -scripts that are ran as the user \ No newline at end of file diff --git a/crates/00-system/crate.arch.sh b/crates/00-system/crate.arch.sh new file mode 100644 index 0000000..ce3f7dd --- /dev/null +++ b/crates/00-system/crate.arch.sh @@ -0,0 +1,11 @@ +super_apply() { + pacman -S --needed sudo reflector + if ! grep -q "Reflector" /etc/pacman.d/mirrorlist; then + cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak + reflector -c NL -f 10 --threads 4 --save /etc/pacman.d/mirrorlist + else + echo "err: reflector already executed -- skipping..." + fi + + cp files/pacman.conf /etc/pacman.conf +} \ No newline at end of file diff --git a/crates/00-system/crate.sh b/crates/00-system/crate.sh new file mode 100644 index 0000000..2a73944 --- /dev/null +++ b/crates/00-system/crate.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +describe="Install stuff on the system!" + +super_apply() { + cp files/sudoers /etc/sudoers +} \ No newline at end of file diff --git a/distros/arch/root/etc/pacman.conf b/crates/00-system/files/pacman.conf similarity index 100% rename from distros/arch/root/etc/pacman.conf rename to crates/00-system/files/pacman.conf diff --git a/distros/any/root/etc/sudoers b/crates/00-system/files/sudoers similarity index 100% rename from distros/any/root/etc/sudoers rename to crates/00-system/files/sudoers diff --git a/crates/10-zsh/crate.arch.sh b/crates/10-zsh/crate.arch.sh new file mode 100644 index 0000000..b44c9ed --- /dev/null +++ b/crates/10-zsh/crate.arch.sh @@ -0,0 +1,7 @@ +super_apply() { + pacman -S --needed zsh cmake +} + +super_undo() { + pacman -R zsh +} \ No newline at end of file diff --git a/crates/10-zsh/crate.sh b/crates/10-zsh/crate.sh new file mode 100644 index 0000000..2e470d8 --- /dev/null +++ b/crates/10-zsh/crate.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +describe="Install zsh and oh-my-zsh!" +scripts="@distro @self" + +super_apply() { + [ -d /tmp/fastfetch ] || git clone https://github.com/LinusDierheimer/fastfetch /tmp/fastfetch + + if ! command -v fastfetch &> /dev/null; then + cd /tmp/fastfetch + mkdir -p build + cd build + cmake .. + cmake --build . --target fastfetch + mv fastfetch /usr/local/bin/fastfetch + fi + + usermod $USER --shell /bin/zsh +} + +super_undo() { + usermod $USER --shell /bin/bash +} + +apply() { + if [ ! -d "$HOME/.oh-my-zsh" ]; then + sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended + + PL_DIR=${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions + [ -d "$PL_DIR" ] || git clone https://github.com/zsh-users/zsh-autosuggestions $PL_DIR + PL_DIR=${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting + [ -d "$PL_DIR" ] || git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $PL_DIR + fi + + [ -e "$HOME/.zshrc" ] || ln files/.zshrc $HOME/.zshrc +} + +undo() { + unlink $HOME/.zshrc + rm -rf $HOME/.oh-my-zsh +} \ No newline at end of file diff --git a/crates/10-zsh/files/.zshrc b/crates/10-zsh/files/.zshrc new file mode 100644 index 0000000..58358a2 --- /dev/null +++ b/crates/10-zsh/files/.zshrc @@ -0,0 +1,23 @@ +export GPG_TTY=$(tty) + +# paths +export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" + +# ZSH +export ZSH="$HOME/.oh-my-zsh" + +ZSH_THEME="afowler" +plugins=(git docker docker-compose node zsh-autosuggestions zsh-syntax-highlighting) +source $ZSH/oh-my-zsh.sh + +# ALIASES +alias open="xdg-open" +alias nobeep="sudo modprobe -r pcspkr" +alias s="title $HOST && cmatrix -rs && clear" +alias q="exit" + +# COSMETICS +fastfetch + +export PATH="${PATH}:/home/${USER}/.local/bin" +export SSH_AUTH_SOCK="/run/user/1000/keyring/ssh" diff --git a/crates/20-vim/crate.arch.sh b/crates/20-vim/crate.arch.sh new file mode 100644 index 0000000..d95ce2d --- /dev/null +++ b/crates/20-vim/crate.arch.sh @@ -0,0 +1,7 @@ +super_apply() { + pacman -S --needed vim +} + +super_undo() { + echo "we never uninstall vim -_-" +} \ No newline at end of file diff --git a/crates/20-vim/files/.ideavimrc b/crates/20-vim/files/.ideavimrc new file mode 100644 index 0000000..115e47f --- /dev/null +++ b/crates/20-vim/files/.ideavimrc @@ -0,0 +1,10 @@ +source ~/.vimrc + +set scrolloff=5 +set incsearch + +map Q gq + +Plug 'machakann/vim-highlightedyank' +Plug 'tpope/vim-commentary' +Plug 'wellle/targets.vim' diff --git a/home/.vimrc b/crates/20-vim/files/.vimrc similarity index 96% rename from home/.vimrc rename to crates/20-vim/files/.vimrc index 6f12643..abb89b3 100644 --- a/home/.vimrc +++ b/crates/20-vim/files/.vimrc @@ -1,3 +1,2 @@ set number set relativenumber - diff --git a/crates/30-alacritty/crate.arch.sh b/crates/30-alacritty/crate.arch.sh new file mode 100644 index 0000000..a91b78b --- /dev/null +++ b/crates/30-alacritty/crate.arch.sh @@ -0,0 +1,7 @@ +super_apply() { + pacman -S --needed alacritty +} + +super_undo() { + pacman -R alacritty +} \ No newline at end of file diff --git a/crates/30-alacritty/crate.sh b/crates/30-alacritty/crate.sh new file mode 100644 index 0000000..3a433d2 --- /dev/null +++ b/crates/30-alacritty/crate.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +describe="Installs alacritty and configs" +scripts="@distro @self" + +apply() { + [ -e "$HOME/.config/alacritty/alacritty.yml" ] || ln files/alacritty.yml $HOME/.config/alacritty/alacritty.yml +} + +undo() { + unlink $HOME/.config/alacritty/alacritty.yml +} \ No newline at end of file diff --git a/home/.config/alacritty/alacritty.yml b/crates/30-alacritty/files/alacritty.yml similarity index 56% rename from home/.config/alacritty/alacritty.yml rename to crates/30-alacritty/files/alacritty.yml index 3bc0096..1a30120 100644 --- a/home/.config/alacritty/alacritty.yml +++ b/crates/30-alacritty/files/alacritty.yml @@ -1,7 +1,3 @@ -bell: - animation: 'Ease' - duration: 50 - color: '#555555' cursor: style: shape: 'Block' diff --git a/distros/alpine/package.list b/distros/alpine/package.list deleted file mode 100644 index 9d32a57..0000000 --- a/distros/alpine/package.list +++ /dev/null @@ -1 +0,0 @@ -doas \ No newline at end of file diff --git a/distros/alpine/pm.sh b/distros/alpine/pm.sh deleted file mode 100644 index 7560ed9..0000000 --- a/distros/alpine/pm.sh +++ /dev/null @@ -1,20 +0,0 @@ -cmd="apk" -while getopts "icru" opt; do - case $opt in - i) - cmd="$cmd add" - ;; - u) - cmd="$cmd add" - ;; - r) - cmd="$cmd del" - ;; - c) - cmd="$cmd info -q" - ;; - esac -done -shift $((OPTIND-1)) - -$cmd $@ \ No newline at end of file diff --git a/distros/alpine/root/etc/doas.conf b/distros/alpine/root/etc/doas.conf deleted file mode 100644 index c50a253..0000000 --- a/distros/alpine/root/etc/doas.conf +++ /dev/null @@ -1 +0,0 @@ -permit persit wheel \ No newline at end of file diff --git a/distros/alpine/sys-scripts/00-remove-sudo.sh b/distros/alpine/sys-scripts/00-remove-sudo.sh deleted file mode 100644 index 2845cb8..0000000 --- a/distros/alpine/sys-scripts/00-remove-sudo.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -# removes sudo - -apk del sudo \ No newline at end of file diff --git a/distros/any/package.list b/distros/any/package.list deleted file mode 100644 index 53b3000..0000000 --- a/distros/any/package.list +++ /dev/null @@ -1,4 +0,0 @@ -neofetch -git -vim -sudo \ No newline at end of file diff --git a/distros/arch/package.list b/distros/arch/package.list deleted file mode 100644 index c3e02c8..0000000 --- a/distros/arch/package.list +++ /dev/null @@ -1,2 +0,0 @@ -reflector # for scripts/00-reflector.sh -alacritty # favourite terminal emulator \ No newline at end of file diff --git a/distros/arch/pm.sh b/distros/arch/pm.sh deleted file mode 100644 index 0fd802c..0000000 --- a/distros/arch/pm.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -cmd="pacman --noconfirm" -while getopts "icru" opt; do - case $opt in - i) - cmd="$cmd -S" - ;; - u) - cmd="$cmd -Syyu" - ;; - r) - cmd="$cmd -R" - ;; - c) - cmd="$cmd -Q" - ;; - esac -done -shift $((OPTIND-1)) - -$cmd $@ \ No newline at end of file diff --git a/distros/arch/sys-scripts/00-reflector.sh b/distros/arch/sys-scripts/00-reflector.sh deleted file mode 100644 index 7d2aa9d..0000000 --- a/distros/arch/sys-scripts/00-reflector.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# Sets up fast mirrors on arch - -if ! pacman -Q reflector; then - echo "reflector was not installed" - exit 1 -fi - -cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak -reflector -c NL -f 10 --threads 4 --save /etc/pacman.d/mirrorlist -echo "Server = arch.neo.faulty.nl/$repo/os/$arch" >> /etc/pacman.d/mirrorlist \ No newline at end of file diff --git a/distros/arch/user-scripts/00-yay.sh b/distros/arch/user-scripts/00-yay.sh deleted file mode 100644 index 4ce4631..0000000 --- a/distros/arch/user-scripts/00-yay.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -# Installs yay. - -[ "$UID" = "0" ] || exit 0 - -yaytmpdir=$(mktemp -d) - -git clone https://aur.archlinux.org/yay $yaytmpdir -oldpwd=$(pwd) -cd $yaytmpdir -makepkg -si -cd $oldpwd diff --git a/dot b/dot new file mode 100755 index 0000000..7993255 --- /dev/null +++ b/dot @@ -0,0 +1,85 @@ +#!/bin/sh + +ask=0 + +is_function() { + type "$1" 2> /dev/null | sed "s/$1//" | grep -qwi function +} + +curr_distro() { + cat /etc/os-release | grep -G "^ID=" | sed 's/ID=//' +} + +include() { + [ -f "$1" ] || return 1 + . $1 + return 0 +} + +func() { + if is_function $(echo "super_$2"); then + sudo sh -c ". $1 && super_$2" + fi + is_function $2 && $2 +} + +get_command() { + case $1 in + a*) + printf "apply" + ;; + u*) + printf "undo" + ;; + *) + echo "err: not supported" >&2 + exit 1 + ;; + esac +} + +# only run this *in crate dir* +run_crate() { + include ./crate.sh || exit 1 + if [ -n "$describe" ]; then + echo "desc($(basename $PWD)): $describe" + fi + cmd=$(get_command $1) + scripts=${scripts:-"@self @distro"} + for s in $scripts; do + echo "exec($(basename $PWD)): $s/$cmd" + case $s in + @self) + func ./crate.sh $cmd + ;; + @distro) + unset -f super_$cmd + unset -f $cmd + include ./crate.$(curr_distro).sh + func ./crate.$(curr_distro).sh $cmd + unset -f super_$cmd + unset -f $cmd + include ./crate.sh + ;; + *) + sh $s + ;; + esac + done +} + +if [ $# -eq 2 ]; then + [ -d crates/*$1 ] || exit 1 + cd crates/*$1 + run_crate $2 + cd ../.. +else + [ $# -eq 0 ] && exit 2 + for crate in $(find ./crates -mindepth 1 -maxdepth 1 -type d | sort); do + cd $crate + run_crate $1 + cd ../.. + done +fi + + \ No newline at end of file diff --git a/skip_steps.sh b/skip_steps.sh deleted file mode 100644 index b6e9ee1..0000000 --- a/skip_steps.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -mkdir .dotfiles &>/dev/null - -for item in ${@:-update install_package_list run_system_scripts run_user_scripts link_home overlay}; do - echo "executed_step:$item" >> .dotfiles/pending_sync -done \ No newline at end of file diff --git a/sync.sh b/sync.sh deleted file mode 100644 index 89ed355..0000000 --- a/sync.sh +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/sh - -osreleaseprop() { - cat /etc/os-release | grep -e "^$1=" | sed 's/ID=//' -} - -elevated() { - s=${SUDO:-sudo} - if [ ! "$s" = "none" ]; then - if ! command -v $s &> /dev/null; then - echo "command \"$s\" not found" - exit 1 - fi - else - s="" - fi - $s $@ -} - -DISTRO=$(osreleaseprop ID) -if [ ! -d "distros/$DISTRO" ]; then - echo "$DISTRO is not supported." - exit 1 -fi - -pm() { - elevated "sh distros/$DISTRO/pm.sh $@" -} - -install_package_list() { - pkgs="" - [ -f "distros/${1:-$DISTRO}/package.list" ] || return 1 - for pkg in $(cat distros/${1:-$DISTRO}/package.list | sed 's/#.*$//'); do - pkgs="$pkgs $pkg" - done - pm -i $pkgs -} - -run_scripts() { - cmd=$1 - shift - case $cmd in - sys) - dir="distros/${1:-$DISTRO}/sys-scripts" - [ -d "$dir" ] || return - for s in $(ls $dir); do - echo "# running $dir/$s..." - elevated sh $dir/$s || exit 1 - done - ;; - user) - dir="distros/${1:-$DISTRO}/user-scripts" - [ -d "$dir" ] || return - for s in $(ls $dir); do - echo "# running $dir/$s..." - sh $dir/$s || exit 1 - done - ;; - esac -} - -overlay() { - [ -d "distros/${1:-$DISTRO}/root" ] || return 0 - elevated cp -r distros/${1:-$DISTRO}/root / -} - -__step_update() { - echo "# updating system..." - pm -u -} - -__step_install_package_list() { - echo "# installing package lists..." - install_package_list any - install_package_list -} - -__step_run_system_scripts() { - echo "# running system scripts..." - run_scripts sys any - run_scripts sys -} - -__step_run_user_scripts() { - echo "# running user scripts..." - run_scripts user any - run_scripts user -} - -__step_overlay() { - echo "# overlaying root directories..." - overlay any - overlay -} - -__step_link_home() { - echo "# linking all home files..." - trackingfile=".dotfiles/$(git rev-parse HEAD)-links" - for item in $(find ./home -type f); do - path=$(echo $item | sed "s/\.\/home//") - [ -z "$path" ] && continue - grep -q "$path" $trackingfile &> /dev/null && continue - path="$HOME$path" - mkdir -p $(dirname $path) &> /dev/null - ln $item $path && echo "$path" >> $trackingfile - done -} - -step() { - if ! grep -q "executed_step:$1" .dotfiles/pending_sync &> /dev/null; then - $(printf "__step_%s" "$1") - echo "executed_step:$1" >> .dotfiles/pending_sync - fi -} - -mkdir -p .dotfiles &> /dev/null -touch .dotfiles/pending_sync - -if [ -n "$1" ]; then - step $1 -else - echo "started_sync:$(date)" >> .dotfiles/log - step update - step install_package_list - step run_system_scripts - step run_user_scripts - step link_home - step overlay - echo "finished_sync:$(date)" >> .dotfiles/log -fi - -unlink .dotfiles/pending_sync diff --git a/unlink.sh b/unlink.sh deleted file mode 100644 index 44e593c..0000000 --- a/unlink.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -for linkfile in ${@:-$(find .dotfiles -type f -name *-links)}; do - echo "# processing linkfile $linkfile..." - for link in $(cat $linkfile); do - echo "# unlinking $link..." - unlink $link - done - rm -rf $linkfile -done \ No newline at end of file