diff options
| author | Nantha Sorubakanthan <nantha@mielota.com> | 2026-04-13 21:45:43 +0200 |
|---|---|---|
| committer | Nantha Sorubakanthan <nantha@mielota.com> | 2026-04-13 21:45:43 +0200 |
| commit | 0c913f1e421b9d47c052350c4c1d619e4ac6a297 (patch) | |
| tree | c9124ff04b9252836221c41d2ca2fa133d166251 /artix/home/.local/bin | |
Initial commit
Diffstat (limited to 'artix/home/.local/bin')
| -rwxr-xr-x | artix/home/.local/bin/camera | 3 | ||||
| -rwxr-xr-x | artix/home/.local/bin/dirtymem | 2 | ||||
| -rwxr-xr-x | artix/home/.local/bin/dlm | 3 | ||||
| -rwxr-xr-x | artix/home/.local/bin/edit | 10 | ||||
| -rw-r--r-- | artix/home/.local/bin/exestub.sh | 19 | ||||
| -rwxr-xr-x | artix/home/.local/bin/gitlc | 20 | ||||
| -rwxr-xr-x | artix/home/.local/bin/gitzero | 18 | ||||
| -rwxr-xr-x | artix/home/.local/bin/helper | 247 | ||||
| -rwxr-xr-x | artix/home/.local/bin/jar2exe | 8 | ||||
| -rwxr-xr-x | artix/home/.local/bin/javasrc | 3 | ||||
| -rw-r--r-- | artix/home/.local/bin/march.sh | 135 | ||||
| -rwxr-xr-x | artix/home/.local/bin/spawn-alacritty-cwd | 31 |
12 files changed, 499 insertions, 0 deletions
diff --git a/artix/home/.local/bin/camera b/artix/home/.local/bin/camera new file mode 100755 index 0000000..2707e32 --- /dev/null +++ b/artix/home/.local/bin/camera @@ -0,0 +1,3 @@ +#! /bin/sh + +ffplay -hide_banner -loglevel error -stats -window_title Webcam -fflags +nobuffer -fast /dev/video0 diff --git a/artix/home/.local/bin/dirtymem b/artix/home/.local/bin/dirtymem new file mode 100755 index 0000000..aef0195 --- /dev/null +++ b/artix/home/.local/bin/dirtymem @@ -0,0 +1,2 @@ +#! /bin/sh +while true; do printf "$(grep Dirty /proc/meminfo)\r"; sleep 0.1; done diff --git a/artix/home/.local/bin/dlm b/artix/home/.local/bin/dlm new file mode 100755 index 0000000..bb45a5d --- /dev/null +++ b/artix/home/.local/bin/dlm @@ -0,0 +1,3 @@ +#! /bin/sh + +yt-dlp -x -t mp3 --no-playlist $1 diff --git a/artix/home/.local/bin/edit b/artix/home/.local/bin/edit new file mode 100755 index 0000000..c6f8288 --- /dev/null +++ b/artix/home/.local/bin/edit @@ -0,0 +1,10 @@ +#! /bin/sh + +eval TARGET_FILE=$(cat ~/.local/share/dox/quickconfig | grep "#$1\$$" | awk -F "#" '{print $1}') + +if [ "$TARGET_FILE" != "" ]; then + nvim $TARGET_FILE +else + echo "Unknown config file. Use one below :" + grep -o "#.*\$$" ~/.local/share/dox/quickconfig | tr -d '#' | tr -d '$' +fi diff --git a/artix/home/.local/bin/exestub.sh b/artix/home/.local/bin/exestub.sh new file mode 100644 index 0000000..33ac55a --- /dev/null +++ b/artix/home/.local/bin/exestub.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# https://stackoverflow.com/questions/4330936/how-can-i-convert-a-jar-to-an-exe + +MYSELF=`which "$0" 2>/dev/null` +[ $? -gt 0 -a -f "$0" ] && MYSELF="./$0" +JAVA_OPT="" +PROG_OPT="" + +while [ $# -gt 0 ] ; do + case $1 in + -Xm*) JAVA_OPT="$JAVA_OPT $1" ;; + -D*) JAVA_OPT="$JAVA_OPT $1" ;; + *) PROG_OPT="$PROG_OPT $1" ;; + esac + shift +done + +exec java $JAVA_OPT -jar $MYSELF $PROG_OPT diff --git a/artix/home/.local/bin/gitlc b/artix/home/.local/bin/gitlc new file mode 100755 index 0000000..8dd982f --- /dev/null +++ b/artix/home/.local/bin/gitlc @@ -0,0 +1,20 @@ +#! /bin/bash + +git log --format="%aN" --numstat | \ +awk ' +NF==0 { next } + +$1 ~ /^[0-9]+$/ { + add[author]+=$1 + del[author]+=$2 + next +} + +$1 == "-" { next } + +author=$0 + +END { + for (a in add) + printf "%s : +%d / -%d / net %d\n", a, add[a], del[a], add[a]-del[a] +}' diff --git a/artix/home/.local/bin/gitzero b/artix/home/.local/bin/gitzero new file mode 100755 index 0000000..6006f50 --- /dev/null +++ b/artix/home/.local/bin/gitzero @@ -0,0 +1,18 @@ +#! /bin/sh + +read -p "You really want to nuke your remote repo? (yes/no) $(git remote get-url origin) " confirmation + +if [ "$confirmation" = "yes" ]; then + mv .git/config . + rm -rf .git + git init + rm .git/config + mv config .git/ + echo "I will push to :" + git remote get-url origin + git add . + git commit -m "Initial commit" + git push -u --force origin main +else + echo "Abort." +fi diff --git a/artix/home/.local/bin/helper b/artix/home/.local/bin/helper new file mode 100755 index 0000000..57b0b52 --- /dev/null +++ b/artix/home/.local/bin/helper @@ -0,0 +1,247 @@ +#! /bin/sh + +# Can override this ENV variables +quiet=${quiet:-0} +format=${format:-"pdf"} +typst_src_dir=${typst_src_dir:-"drafts"} +typst_output_dir=${typst_output_dir:-"content"} + +blue="\033[34m" +bold_blue="\033[1;34m" +green="\033[32m" +bold_green="\033[1;32m" +yellow="\033[33m" +red="\033[31m" +no_color="\033[0m" + +colored_output() { + color_name=$1 + shift + case $color_name in + blue) + color=$blue;; + bold_blue) + color=$bold_blue;; + green) + color=$green;; + bold_green) + color=$bold_green;; + yellow) + color=$yellow;; + red) + color=$red;; + *) + color=$no_color;; + esac + + printf "${color}$@${no_color}\n" +} + +helper_log() { + + if [ $quiet -gt 0 ]; then + return 0 + fi + + log_request=$1 + shift + case $log_request in + info) + log_level=$(colored_output blue INFO);; + success) + log_level=$(colored_output green SUCCESS);; + warn) + log_level=$(colored_output yellow WARNING);; + testing) + log_level=$(colored_output yellow TEST);; + err) + log_level=$(colored_output red ERROR);; + fail) + log_level=$(colored_output red FAILED);; + *) + log_level=? + esac + + if [ $log_level != "FAILED" ] && [ $log_level != "ERROR" ]; then + printf "[$log_level] $@\n" + else + printf "[$log_level] $@\n >&2" + fi +} + +display_help() { + echo -e " +$(colored_output bold_green "Usage:") + + $(colored_output bold_blue "helper") COMMAND + + or + + $(colored_output bold_blue "helper") + > COMMAND + > COMMAND + > quit + + +$(colored_output bold_green "Commands:") + + $(colored_output bold_blue "help") + Prints help. + + $(colored_output bold_blue "quit") + Quit helper. + + $(colored_output bold_blue "check") + Checks that all dependencies are installed + + $(colored_output bold_blue "sync") + git pull + + $(colored_output bold_blue "build") + Compiles typst file in pdf. + There's other formats, see ENV vars section + + $(colored_output bold_blue "clean") + Deletes all typst compiled files of a given format + + +$(colored_output bold_green "ENV vars:") + + $(colored_output bold_blue "quiet") + Make the helper silent : + quiet=1 ./helper COMMANDE + default value : 0 + + $(colored_output bold_blue "format") + You can change the target format of helper's commands + Example : format=png ./helper build will compile all typst source code into png + default value : pdf + + $(colored_output bold_blue "typst_src_dir") + Directory with the typst source code + default value : drafts + + $(colored_output bold_blue "typst_output_dir") + Target directory with compiled typst + default value : content +" +} + +greet_user() { + helper_log info "hi $(whoami)" +} + +unknown_cmd() { + echo "??? get help with './helper help'" +} + +eval_input() { + case $1 in + help)display_help;; + quit)echo "bye $(whoami) ♥" ; exit 0;; + check)check;; + sync)sync;; + build)build;; + clean)clean;; + *)unknown_cmd;; + esac +} + +check() { + helper_log testing "Checking dependencies." + git -v > /dev/null 2>&1 || (helper_log fail "git isn't installed ???" && exit 1) + typst --version > /dev/null 2>&1 || (helper_log fail "typst isn't installed" && exit 1) + helper_log success "You're all good :)" +} + +sync() { + git pull +} + +build() { + typ_files="$(find $typst_src_dir -name "*.typ")" + + compiled=0 + + for file in $typ_files; do + target_path=$(echo $file | sed "s/"$typst_src_dir"/"$typst_output_dir"/g; s/\.typ$/."$format"/g") + target_dir=$(dirname $target_path) + + if ! [ -d $target_dir ]; then + mkdir -p $target_dir + fi + + if [ -f $target_path ]; then + helper_log warn "File $file is already compiled here : $target_path, aborting." + else + helper_log info "Compiling $file here : $target_path" + typst compile $file $target_path + if [ -f $target_path ]; then + helper_log success "Successfully compiled $file here : $target_path ." + compiled=$(expr $compiled + 1) + else + helper_log fail "Couldn't compile $file here : $target_path" + fi + fi + done + + helper_log info "Found : $(echo "$typ_files" | wc -l) Typst files." + helper_log info "Compiled : $compiled $format." +} + +clean() { + build_files="$(find $typst_output_dir -name "*.$format")" + + deleted=0 + + for file in $build_files; do + helper_log info "Deleting $file" + rm $file + if ! [ -f $file ]; then + helper_log success "Successfully deleted $file ." + deleted=$(expr $deleted + 1) + else + helper_log fail "Couldn't delete $file ." + fi + done + + helper_log info "Found : $(echo "$build_files" | wc -l) Typst files." + helper_log info "Deleted : $deleted $format." + + empty_dirs="$(find . -type d -empty -not -path "*/.git/*")" + + while [ "$empty_dirs" != "" ]; do + if [ -n "$empty_dirs" ]; then + helper_log warn "$(echo "$empty_dirs" | wc -l) empty dirs found." + helper_log info "deleting empty dirs" + + for dir in $empty_dirs; do + helper_log info "Deleting $dir" + rmdir $dir && helper_log success "Successfully deleted $dir." || helper_log fail "Couldn't delete $dir" + done + fi + empty_dirs="$(find . -type d -empty -not -path "*/.git/*")" + done +} + +if ! [ -d $typst_src_dir ]; then + mkdir $typst_src_dir +fi + +if ! [ -d $typst_output_dir ]; then + mkdir $typst_output_dir +fi + +if [ $# -eq 0 ]; then + greet_user + while true; do + echo -n "> " + read user_input + eval_input $user_input + done +elif [ $# -eq 1 ]; then + eval_input $1 +else + unknown_cmd +fi + diff --git a/artix/home/.local/bin/jar2exe b/artix/home/.local/bin/jar2exe new file mode 100755 index 0000000..5aa127b --- /dev/null +++ b/artix/home/.local/bin/jar2exe @@ -0,0 +1,8 @@ +#! /bin/sh + +set -e + +[ -z $1 ] && echo "found 0 argument" && exit 1 +[ -z $2 ] && echo "found 1 argument" && exit 1 + +cat ~/.local/bin/exestub.sh $1 > $2 && chmod -v +x $2 diff --git a/artix/home/.local/bin/javasrc b/artix/home/.local/bin/javasrc new file mode 100755 index 0000000..09134ba --- /dev/null +++ b/artix/home/.local/bin/javasrc @@ -0,0 +1,3 @@ +#! /bin/sh + +find src/main/java -name "*.java" -not -name "package-info.java" -exec cat {} + | sed -e '/^\s*\/\//d' -e '/^\s*$/d' diff --git a/artix/home/.local/bin/march.sh b/artix/home/.local/bin/march.sh new file mode 100644 index 0000000..64d758a --- /dev/null +++ b/artix/home/.local/bin/march.sh @@ -0,0 +1,135 @@ +#! /bin/sh + +# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + +# FILL THOSE VARS +rootpasswd="" +username="" +userpasswd="" + +hostname="" + +# ajouter amd-ucode ou intel-ucode +packages="linux linux-firmware sof-firmware base base-devel grub efibootmgr networkmanager terminus-font neovim pipewire pipewire-pulse wireplumber git" + +echo "Sécurité active, supprimez moi du script pour lancer l'installation." ; exit 1 + +# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + +catch_failure() { + echo "Une erreur est survenue. Arrêt du programme" + sleep 3 + exit 1 +} + +close() { + echo "Fin, redémarrage dans 10 secondes." + echo "TODO : se connecter à internet, décommenter wheel dans sudoers, xdg-user-dirs-update" + sleep 10 + reboot +} + +ch() { + arch-chroot /mnt /bin/sh -c "$@" || catch_failure +} + +### Main + +echo " + +███╗ ███╗ █████╗ ██████╗ ██████╗██╗ ██╗ +████╗ ████║██╔══██╗██╔══██╗██╔════╝██║ ██║ +██╔████╔██║███████║██████╔╝██║ ███████║ +██║╚██╔╝██║██╔══██║██╔══██╗██║ ██╔══██║ +██║ ╚═╝ ██║██║ ██║██║ ██║╚██████╗██║ ██║ +╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ + +Mon script personnel pour installer Arch. +Téléchargement : https://mielota.com/march.sh + +Démarrage du programme dans 5 secondes ! Toutes les données du disque seront effacées ! +" +sleep 5 + +echo "Configuration de timedatectl..." +timedatectl set-timezone Europe/Paris || catch_failure + +echo "Partition des disques..." +( +echo g +echo n +echo 1 +echo +echo +1G +echo t +echo 1 +echo 1 +echo n +echo 2 +echo +echo +echo w +) | fdisk "/dev/nvme0n1" &> /dev/null || catch_failure + +echo "Formattage du disque..." + +echo "Formattage du ESP..." +yes | mkfs.fat -F 32 -n ESP /dev/nvme0n1p1 || catch_failure + +echo "Formattage du ROOT..." +yes | mkfs.ext4 -L ROOT /dev/nvme0n1p2 || catch_failure + +echo "Montage des partitions..." + +echo "Montage de ROOT sur /mnt" +mount /dev/disk/by-label/ROOT /mnt || catch_failure + +echo "Montage de ESP sur /mnt/boot/EFI" +mount --mkdir /dev/disk/by-label/ESP /mnt/boot/EFI || catch_failure + +echo "Configuration des mirroirs de pacstrap... (peut prendre un moment)" +reflector --country France --age 10 --protocol https --sort rate --save /etc/pacman.d/mirrorlist || catch_failure + +echo "Installation des paquets de base sur le système..." +pacstrap -K /mnt --noconfirm $packages || catch_failure + +echo "Génération du fstab..." +genfstab -U /mnt >> /mnt/etc/fstab || catch_failure + +echo "ARCH CHROOT" +echo "Configurer le temps..." +ch "ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime" +ch "hwclock --systohc" + +echo "Configuration des langues..." +ch "echo 'fr_FR.UTF-8 UTF-8' >> /etc/locale.gen" +ch "locale-gen" +ch "echo 'LANG=fr_FR.UTF-8' > /etc/locale.conf" + +echo "Configuration du KEYMAP vconsole..." +ch "echo -e 'KEYMAP=fr-latin1\nXKBLAYOUT=fr\nXKBMODEL=pc105\nXKBOPTIONS=terminate:ctrl_alt_bksp\nFONT=ter-132b' > /etc/vconsole.conf" + +echo "Application du hostname $hostname..." +ch "echo '$hostname' > /etc/hostname" + +echo "Activation du service NetworkManager..." +ch "systemctl enable NetworkManager" + +echo "Configuration du mot de passe root" +ch "echo 'root:$rootpasswd' | chpasswd" + +echo "Configuration de l'utilisateur $username" +ch "useradd -m -G wheel $username" + +echo "Configuration du mot de passe de $username" +ch "echo '$username:$userpasswd' | chpasswd" + +echo "Installation de GRUB" +ch "grub-install --target=x86_64-efi --efi-directory=/boot/EFI" + +echo "Génération de grub.cfg..." +ch "grub-mkconfig -o /boot/grub/grub.cfg" + +close diff --git a/artix/home/.local/bin/spawn-alacritty-cwd b/artix/home/.local/bin/spawn-alacritty-cwd new file mode 100755 index 0000000..dcadff8 --- /dev/null +++ b/artix/home/.local/bin/spawn-alacritty-cwd @@ -0,0 +1,31 @@ +#!/bin/bash + +ACTIVE_WINDOW_INFO=$(hyprctl activewindow -j) + +CLASS=$(echo "$ACTIVE_WINDOW_INFO" | jq -r '.class') +PID=$(echo "$ACTIVE_WINDOW_INFO" | jq -r '.pid') + +if [[ "$CLASS" == "Alacritty" ]]; then + + if [[ -z "$PID" || "$PID" == "null" ]]; then + alacritty + exit 0 + fi + + CHILD_PID=$(pgrep -P "$PID" | head -n 1) + + if [[ -z "$CHILD_PID" ]]; then + alacritty + exit 0 + fi + + if [[ -e "/proc/$CHILD_PID/cwd" ]]; then + SHELL_CWD=$(readlink -f "/proc/$CHILD_PID/cwd") + alacritty --working-directory "$SHELL_CWD" + else + alacritty + fi + +else + alacritty +fi |
