From c0706de7f53fc6fcda0e7d25c3157c9b60f5cc8a Mon Sep 17 00:00:00 2001 From: Lucas Date: Thu, 18 Jun 2026 10:10:37 +0200 Subject: [PATCH] feat: add user script tracking --- scripts/batt-info | 78 ++++++++++++++++++++++++++++++++++++++ scripts/batt-toggle | 9 +++++ scripts/dotpush.sh | 55 +++++++++++++++++++++++++++ scripts/download-youtube | 9 +++++ scripts/hypridle-launch | 6 +++ scripts/mkinitcpio-eco | 3 ++ scripts/mkinitcpio-eco.bak | 2 + scripts/power-monitor | 9 +++++ scripts/waybar-dual.sh | 6 +++ scripts/waybar-solo.sh | 5 +++ scripts/webcam | 2 + 11 files changed, 184 insertions(+) create mode 100755 scripts/batt-info create mode 100755 scripts/batt-toggle create mode 100755 scripts/dotpush.sh create mode 100755 scripts/download-youtube create mode 100755 scripts/hypridle-launch create mode 100755 scripts/mkinitcpio-eco create mode 100755 scripts/mkinitcpio-eco.bak create mode 100755 scripts/power-monitor create mode 100755 scripts/waybar-dual.sh create mode 100755 scripts/waybar-solo.sh create mode 100755 scripts/webcam diff --git a/scripts/batt-info b/scripts/batt-info new file mode 100755 index 0000000..9fe72a2 --- /dev/null +++ b/scripts/batt-info @@ -0,0 +1,78 @@ +#!/bin/bash + +BAT_PATH="/sys/class/power_supply/BAT0" +if [ ! -d "$BAT_PATH" ]; then + echo "Batterie non trouvée" + exit 1 +fi + +# Lire les informations +capacity=$(cat "$BAT_PATH/capacity" 2>/dev/null) +status=$(cat "$BAT_PATH/status" 2>/dev/null) +charge_now=$(cat "$BAT_PATH/charge_now" 2>/dev/null) # µAh +current_now=$(cat "$BAT_PATH/current_now" 2>/dev/null) # µA +voltage_now=$(cat "$BAT_PATH/voltage_now" 2>/dev/null) # µV +max_limit=$(cat "$BAT_PATH/charge_control_end_threshold" 2>/dev/null) + +# Valeurs par défaut +[ -z "$capacity" ] && capacity=0 +[ -z "$status" ] && status="Unknown" +[ -z "$max_limit" ] && max_limit=100 + +# Calcul de la puissance (si voltage et courant disponibles) +# if [ -n "$voltage_now" ] && [ -n "$current_now" ] && [ "$current_now" -gt 0 ]; then +# wattage=$(echo "scale=1; $voltage_now * $current_now / 1000000000000" | bc) +# else +# wattage="" +# fi + +wattage=$(cat /tmp/power_now 2>/dev/null) + +# Calcul du temps restant (en minutes) si en décharge +time_str="" +if [ "$status" = "Discharging" ] && [ -n "$charge_now" ] && [ -n "$current_now" ] && [ "$current_now" -gt 0 ]; then + time_h=$(echo "scale=2; $charge_now / $current_now" | bc) + time_min=$(echo "$time_h * 60" | bc | cut -d. -f1) + if [ -n "$time_min" ] && [ "$time_min" -gt 0 ]; then + hours=$(( time_min / 60 )) + minutes=$(( time_min % 60 )) + time_str=$(printf "%d:%02d" $hours $minutes) + fi +fi + +# Affichage selon l'état +if [ "$status" = "Charging" ]; then + icon="⚡" + if [ -n "$wattage" ]; then + text="${icon} ${capacity}% (${wattage}W - ${max_limit}%)" + else + text="${icon} ${capacity}% (${max_limit}%)" + fi +elif [ "$status" = "Discharging" ]; then + # Icône batterie selon le niveau + if [ $capacity -le 20 ]; then + icon="" + elif [ $capacity -le 40 ]; then + icon="" + elif [ $capacity -le 60 ]; then + icon="" + elif [ $capacity -le 80 ]; then + icon="" + else + icon="" + fi + if [ -n "$time_str" ] && [ -n "$wattage" ]; then + text="${icon} ${capacity}% (${time_str} - ${wattage}W - ${max_limit}%)" + else + text="${icon} ${capacity}% (${max_limit}%)" + fi +else + icon="" + if [ -n "$wattage" ]; then + text="${icon} ${capacity}% (${wattage}W - ${max_limit}%)" + else + text="${icon} ${capacity}% (${max_limit}%)" + fi +fi + +echo "$text" diff --git a/scripts/batt-toggle b/scripts/batt-toggle new file mode 100755 index 0000000..2a97f3b --- /dev/null +++ b/scripts/batt-toggle @@ -0,0 +1,9 @@ +#!/bin/bash +current=$(cat /sys/class/power_supply/BAT0/charge_control_end_threshold) +if [ "$current" -eq 80 ]; then + sudo cctk --PrimaryBattChargeCfg=Custom:95-100 + notify-send "Batterie" "Charge standard (100%)" +else + sudo cctk --PrimaryBattChargeCfg=Custom:50-80 + notify-send "Batterie" "Charge limitée à 80%" +fi diff --git a/scripts/dotpush.sh b/scripts/dotpush.sh new file mode 100755 index 0000000..7f9a2aa --- /dev/null +++ b/scripts/dotpush.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env zsh + +# ============================================================ +# Définition locale de la commande config +# ============================================================ +config() { + /usr/bin/git --git-dir="$HOME/.dotfiles" --work-tree="$HOME" "$@" +} + +# ============================================================ +# Script de sauvegarde interactif (ordre corrigé) +# ============================================================ +cd ~ + +# 1. Stager TOUS les fichiers autorisés par la whitelist +echo "⏳ Staging des fichiers autorisés..." +config add . + +# 2. Vérifier ce qui est EFFECTIVEMENT dans le stage (prêt à être commité) +local staged_changes=$(config status -s) + +if [[ -z "$staged_changes" ]]; then + echo "📭 Aucun fichier n'a été ajouté au stage (vérifiez votre .dotfilesignore)." + echo " Rien à committer." + exit 0 +fi + +# 3. Afficher le contenu du stage (ce qui va VRAIMENT partir) +echo "📦 Voici les fichiers qui seront DANS le commit :" +echo "-----------------------------------------------------" +config status -s +echo "-----------------------------------------------------" +echo "" + +# 4. Demander le message de commit +echo -n "✏️ Entrez le message de commit (ou Entrée pour auto) : " +read -r msg + +if [[ -z "$msg" ]]; then + msg="Sauvegarde auto $(date '+%Y-%m-%d %H:%M')" + echo "⏩ Message auto : \"$msg\"" +fi + +# 5. Commiter +config commit -m "$msg" + +# 6. Pousser +if config remote | grep -q origin; then + echo "🚀 Push vers origin master..." + config push origin master + echo "✅ Sauvegarde terminée !" +else + echo "⚠️ Aucun remote 'origin' configuré." + echo " Ajoutez-le avec : config remote add origin git@github.com:votre-pseudo/dotfiles.git" +fi diff --git a/scripts/download-youtube b/scripts/download-youtube new file mode 100755 index 0000000..9e6e7e7 --- /dev/null +++ b/scripts/download-youtube @@ -0,0 +1,9 @@ +#!/bin/bash +# Usage: ./download-youtube 'URL' + +if [ -z "$1" ]; then + echo "Erreur : donne une URL YouTube en argument." + exit 1 +fi + +yt-dlp -x --audio-format flac --embed-thumbnail --add-metadata "$1" diff --git a/scripts/hypridle-launch b/scripts/hypridle-launch new file mode 100755 index 0000000..a688ce5 --- /dev/null +++ b/scripts/hypridle-launch @@ -0,0 +1,6 @@ +#!/bin/bash +if [ -f /run/eco_mode ]; then + exec hypridle -c ~/.config/hypr/hypridle-eco.conf +else + exec hypridle -c ~/.config/hypr/hypridle.conf +fi diff --git a/scripts/mkinitcpio-eco b/scripts/mkinitcpio-eco new file mode 100755 index 0000000..a7cf16e --- /dev/null +++ b/scripts/mkinitcpio-eco @@ -0,0 +1,3 @@ +#!/bin/bash +latest_kver=$(ls /lib/modules | sort -V | tail -n1) +sudo mkinitcpio -k "$latest_kver" -c /etc/mkinitcpio-eco.conf -g /boot/initramfs-linux-eco.img diff --git a/scripts/mkinitcpio-eco.bak b/scripts/mkinitcpio-eco.bak new file mode 100755 index 0000000..ee2110e --- /dev/null +++ b/scripts/mkinitcpio-eco.bak @@ -0,0 +1,2 @@ +#!/bin/bash +sudo mkinitcpio -c /etc/mkinitcpio-eco.conf -g /boot/initramfs-linux-eco.img diff --git a/scripts/power-monitor b/scripts/power-monitor new file mode 100755 index 0000000..6b0f762 --- /dev/null +++ b/scripts/power-monitor @@ -0,0 +1,9 @@ +#!/bin/bash +RAPL0="/sys/class/powercap/intel-rapl:0/energy_uj" +RAPL1="/sys/class/powercap/intel-rapl:1/energy_uj" +while true; do + e1=$(( $(cat "$RAPL0") + $(cat "$RAPL1") )) + sleep 2 + e2=$(( $(cat "$RAPL0") + $(cat "$RAPL1") )) + echo "scale=1; ($e2 - $e1) / 2000000" | bc > /tmp/power_now +done diff --git a/scripts/waybar-dual.sh b/scripts/waybar-dual.sh new file mode 100755 index 0000000..0e2ccb7 --- /dev/null +++ b/scripts/waybar-dual.sh @@ -0,0 +1,6 @@ +#!/bin/bash +export GTK_THEME="Adwaita:dark" +killall waybar +sleep 0.5 +waybar -c ~/.config/waybar/config.jsonc & +waybar -c ~/.config/waybar/config-hdmi.jsonc & diff --git a/scripts/waybar-solo.sh b/scripts/waybar-solo.sh new file mode 100755 index 0000000..21d4c2f --- /dev/null +++ b/scripts/waybar-solo.sh @@ -0,0 +1,5 @@ +#!/bin/bash +export GTK_THEME="Adwaita:dark" +killall waybar +sleep 0.5 +waybar -c ~/.config/waybar/config.jsonc & diff --git a/scripts/webcam b/scripts/webcam new file mode 100755 index 0000000..49aa3e2 --- /dev/null +++ b/scripts/webcam @@ -0,0 +1,2 @@ +#/bin/bash! +ffplay -fflags nobuffer -flags low_delay -framedrop /dev/video2