mod: remodel

This commit is contained in:
Strix 2023-10-14 22:38:06 +02:00
parent 99c3f02a2d
commit 9434b666e5
No known key found for this signature in database
GPG key ID: 49B2E37B8915B774
4 changed files with 68 additions and 13 deletions

View file

@ -0,0 +1,9 @@
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
#}

View file

@ -12,6 +12,11 @@ bool() {
}
run() {
# Check if command starts with NO_RUN ($*) and remove it
if echo "$*" | grep -q "^NO_RUN"; then
return 0
fi
if bool "$DRY_RUN"; then
echo "DRY: + $*"
else
@ -21,7 +26,7 @@ run() {
}
is_graphical() {
command -v $PREF_TERM && return 0 || return 1
command -v $PREF_TERM > /dev/null && return 0 || return 1
}
command -v $SYS_SUDO || SYS_SUDO=""
command -v $SYS_SUDO > /dev/null || SYS_SUDO="NO_RUN"

View file

@ -1,4 +1,3 @@
curl
vim
zsh

62
sync.sh
View file

@ -4,6 +4,9 @@ SYNC_FILES=${SYNC_FILES:-yes}
INSTALL_PKGS=${INSTALL_PKGS:-yes}
RUN_CMDS=${RUN_CMDS:-yes}
PULL_GIT=${PULL_GIT:-yes}
TIME_TRACK=${TIME_TRACK:-no}
ARGS="$@"
. ./lib/lib.sh
@ -11,9 +14,13 @@ set -e # Exit on error
_install_pkgs() {
run $SYS_SUDO $PM_COMMAND $PM_UPDATE $PM_NOCONFIRM
_APPLICATIONS=""
while read -r pkg; do
run $SYS_SUDO $PM_COMMAND $PM_INSTALL $PM_NOCONFIRM $pkg
done <$1
[ -z "$pkg" ] && continue
[ "$(echo "$pkg" | cut -c1)" = "#" ] && continue
_APPLICATIONS="$_APPLICATIONS $pkg"
done <"$1"
run $SYS_SUDO $PM_COMMAND $PM_INSTALL $PM_NOCONFIRM $_APPLICATIONS
}
_sync_files() {
@ -38,25 +45,60 @@ _run_cmds() {
done <./command.list
}
ARGS="$@"
_skip_next_arg="n"
arg_handler() {
case $1 in
--graphical|-g)
bool "$INSTALL_PKGS" && _install_pkgs ./gpackage.list
;;
esac
for arg in $ARGS; do
bool $_skip_next_arg && continue
case $arg in
+files) SYNC_FILES=yes ;;
-files) SYNC_FILES=no ;;
+pkgs) INSTALL_PKGS=yes ;;
-pkgs) INSTALL_PKGS=no ;;
+cmds) RUN_CMDS=yes ;;
-cmds) RUN_CMDS=no ;;
+git) PULL_GIT=yes ;;
-git) PULL_GIT=no ;;
+) SYNC_FILES=yes; INSTALL_PKGS=yes; RUN_CMDS=yes; PULL_GIT=yes ;;
-) SYNC_FILES=no; INSTALL_PKGS=no; RUN_CMDS=no; PULL_GIT=no ;;
+*)
echo "# Unknown argument: $arg"
exit 1
;;
-*)
echo "# Unknown argument: $arg"
exit 1
;;
esac
done
}
main() {
arg_handler
echo "# hook: PULL_GIT"
bool "$PULL_GIT" && run git pull
echo "# hook: SYNC_FILES (/)"
bool "$SYNC_FILES" && run cp -a "./files/%HOME/." "$HOME"
echo "# hook: SYNC_FILES"
bool "$SYNC_FILES" && _sync_files
echo "# hook: INSTALL_PKGS"
bool "$INSTALL_PKGS" && _install_pkgs ./package.list
arg_handler "$@"
echo "# hook: RUN_CMDS"
bool "$RUN_CMDS" && _run_cmds
return 0
}
echo "# exec: start."
bool ${TIME_TRACK:-no} && time main "$@" || main "$@"
if bool $TIME_TRACK; then
time main "$@"
else
main "$@"
fi
echo "# exec: done."