From a10fba3601c55a6a99c70b61b2ced643a12bc325 Mon Sep 17 00:00:00 2001 From: Mathieu Rousseau Date: Sun, 27 Oct 2024 15:15:21 -0400 Subject: [PATCH] initial commit --- .gitignore | 24 ++++++ LICENSE | 25 ++++++ README.md | 1 + btrfs-backup-stats.sh | 2 + btrfs-backup.sh | 126 +++++++++++++++++++++++++++++ btrfs-move-fast.sh | 60 ++++++++++++++ github-init-repo-priv.sh | 46 +++++++++++ github-init-repo-pub.sh | 46 +++++++++++ hypr-toggle-layouts.sh | 3 + kinetic_energy.py | 40 +++++++++ nextcloud-sync.sh | 47 +++++++++++ note-dailies.sh | 2 + note-grep.sh | 2 + note-journal.sh | 2 + note-new-from-template.sh | 2 + note-new.sh | 2 + note-quick-switch.sh | 2 + note-search-by-tags.sh | 2 + notes-dmenu.sh | 54 +++++++++++++ post-sleep-check.sh | 10 +++ powers.py | 8 ++ qr_make.py | 12 +++ rofi-beats-linux.sh | 156 ++++++++++++++++++++++++++++++++++++ rsync4duplicati.sh | 47 +++++++++++ ssh-tunnel-pluton.sh | 4 + update_pacman_mirrorlist.sh | 14 ++++ wallpaper-converter.sh | 31 +++++++ waybar-toggle-tray.sh | 5 ++ wlkill.sh | 23 ++++++ 29 files changed, 798 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100755 btrfs-backup-stats.sh create mode 100755 btrfs-backup.sh create mode 100755 btrfs-move-fast.sh create mode 100755 github-init-repo-priv.sh create mode 100755 github-init-repo-pub.sh create mode 100755 hypr-toggle-layouts.sh create mode 100755 kinetic_energy.py create mode 100755 nextcloud-sync.sh create mode 100755 note-dailies.sh create mode 100755 note-grep.sh create mode 100755 note-journal.sh create mode 100755 note-new-from-template.sh create mode 100755 note-new.sh create mode 100755 note-quick-switch.sh create mode 100755 note-search-by-tags.sh create mode 100755 notes-dmenu.sh create mode 100755 post-sleep-check.sh create mode 100755 powers.py create mode 100755 qr_make.py create mode 100755 rofi-beats-linux.sh create mode 100755 rsync4duplicati.sh create mode 100755 ssh-tunnel-pluton.sh create mode 100755 update_pacman_mirrorlist.sh create mode 100755 wallpaper-converter.sh create mode 100755 waybar-toggle-tray.sh create mode 100755 wlkill.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..77a3d6a --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +.env +data/ +node_modules/ +venv/ +__pycache__/ +*.pyc +*.pyo +*.pyd +.Python +*.log +logs/ +npm-debug.log* +coverage/ +.cache/ +*.pem +*.key +vendor/ +storage/ +bootstrap/cache/ +composer.lock +docker-compose.override.yml +docker-compose.yml +.dockerignore +*.sqlite3 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a0f7ec4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,25 @@ + GLWT(Good Luck With That) Public License + Copyright (c) Everyone, except Author + +Everyone is permitted to copy, distribute, modify, merge, sell, publish, +sublicense or whatever they want with this software but at their OWN RISK. + + Preamble + +The author has absolutely no clue what the code in this project does. +It might just work or not, there is no third option. + + + GOOD LUCK WITH THAT PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION, AND MODIFICATION + + 0. You just DO WHATEVER YOU WANT TO as long as you NEVER LEAVE A +TRACE TO TRACK THE AUTHOR of the original product to blame for or hold +responsible. + +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +Good luck and Godspeed. diff --git a/README.md b/README.md new file mode 100644 index 0000000..cc09178 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# duct-tape diff --git a/btrfs-backup-stats.sh b/btrfs-backup-stats.sh new file mode 100755 index 0000000..4c5bf9b --- /dev/null +++ b/btrfs-backup-stats.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +sudo btrfs filesystem du -s /run/media/mathieu/ext_ssd/backups diff --git a/btrfs-backup.sh b/btrfs-backup.sh new file mode 100755 index 0000000..95e676d --- /dev/null +++ b/btrfs-backup.sh @@ -0,0 +1,126 @@ +#!/usr/bin/env bash + +# Config +SOURCE="/home" +LOCAL_DEST="/snapshots" +DEST="/run/media/mathieu/ext_ssd/backups" +KEEP_LOCAL=10 # Nombre de snapshots locaux à conserver +KEEP_DISTANT=31 # Nombre de snapshots distant à conserver +# KEEP_DAILY=7 # Rétention des snapshots distants +# KEEP_WEEKLY=4 +# KEEP_MONTHLY=6 +DATE=$(date +"%Y-%m-%d_%H-%M-%S") +SNAPSHOT_NAME="$DATE" +LAST_RUN_FILE="$DEST/.last_run" +LAST_SNAPSHOT_FILE="$DEST/.last_snapshot" + +get_age_days() { + local file=$1 + local file_time=$(date -r "$file" +%s) + local current_time=$(date +%s) + echo $(((current_time - file_time) / 86400)) +} + +if ! mountpoint -q "$DEST/.."; then + echo "Erreur: Le disque externe n'est pas monté sur $DEST" + exit 1 +fi + +# Vérifier la dernière exécution +if [ -f "$LAST_RUN_FILE" ]; then + last_run=$(cat "$LAST_RUN_FILE") + days_since_last_run=$((($(date +%s) - $(date -d "$last_run" +%s)) / 86400)) + if [ $days_since_last_run -gt 7 ]; then + echo "Attention: $days_since_last_run jours se sont écoulés depuis la dernière sauvegarde." + fi +else + echo "Première exécution détectée." +fi + +# Créer un nouveau snapshot en lecture seule de /home +if sudo btrfs subvolume snapshot -r "$SOURCE" "$LOCAL_DEST/$SNAPSHOT_NAME"; then + echo "Snapshot local créé avec succès: $LOCAL_DEST/$SNAPSHOT_NAME" +else + echo "Erreur lors de la création du snapshot local" + exit 1 +fi + +# Envoyer le snapshot vers la destination +if [ -f "$LAST_SNAPSHOT_FILE" ]; then + last_snapshot=$(cat "$LAST_SNAPSHOT_FILE") + if [ -d "$LOCAL_DEST/$last_snapshot" ]; then + echo "Envoi d'un snapshot incrémentiel..." + if sudo btrfs send -p "$LOCAL_DEST/$last_snapshot" "$LOCAL_DEST/$SNAPSHOT_NAME" | sudo btrfs receive "$DEST"; then + echo "Snapshot incrémental envoyé avec succès vers $DEST/$SNAPSHOT_NAME" + else + echo "Erreur lors de l'envoi du snapshot incrémentiel. Tentative d'envoi complet..." + if sudo btrfs send "$LOCAL_DEST/$SNAPSHOT_NAME" | sudo btrfs receive "$DEST"; then + echo "Snapshot complet envoyé avec succès vers $DEST/$SNAPSHOT_NAME" + else + echo "Erreur lors de l'envoi du snapshot complet" + sudo btrfs subvolume delete "$LOCAL_DEST/$SNAPSHOT_NAME" + exit 1 + fi + fi + else + echo "Le snapshot précédent n'existe pas localement. Envoi d'un snapshot complet..." + if sudo btrfs send "$LOCAL_DEST/$SNAPSHOT_NAME" | sudo btrfs.receive "$DEST"; then + echo "Snapshot complet envoyé avec succès vers $DEST/$SNAPSHOT_NAME" + else + echo "Erreur lors de l'envoi du snapshot complet" + sudo btrfs subvolume delete "$LOCAL_DEST/$SNAPSHOT_NAME" + exit 1 + fi + fi +else + echo "Aucun snapshot précédent trouvé. Envoi d'un snapshot complet..." + if sudo btrfs send "$LOCAL_DEST/$SNAPSHOT_NAME" | sudo btrfs receive "$DEST"; then + echo "Snapshot complet envoyé avec succès vers $DEST/$SNAPSHOT_NAME" + else + echo "Erreur lors de l'envoi du snapshot complet" + sudo btrfs subvolume delete "$LOCAL_DEST/$SNAPSHOT_NAME" + exit 1 + fi +fi + +# Mettre à jour les fichiers de suivi +date +"%Y-%m-%d %H:%M:%S" >"$LAST_RUN_FILE" +echo "$SNAPSHOT_NAME" >"$LAST_SNAPSHOT_FILE" + +# Fonction de nettoyage des snapshots locaux +cleanup_local_snapshots() { + echo "Nettoyage des snapshots locaux..." + local snapshots=($(ls -1d "$LOCAL_DEST"/20*_*-*-* | sort -r)) + local count=0 + for snapshot in "${snapshots[@]}"; do + if [ $count -ge $KEEP_LOCAL ]; then + echo "Suppression du snapshot local: $snapshot" + sudo btrfs subvolume delete "$snapshot" + fi + count=$((count + 1)) + done +} + +# Fonction de nettoyage des snapshots sur la destination +cleanup_remote_snapshots() { + echo "Nettoyage des snapshots distants..." + cd "$DEST" || exit + + local snapshots=($(ls -1d 20*_*-*-* | sort -r)) + + for snapshot in "${snapshots[@]}"; do + local age=$(get_age_days "$snapshot") + + # Supprimer tous les snapshots plus vieux que 31 jours + if [ $age -gt $KEEP_DISTANT ]; then + echo "Suppression du snapshot distant: $snapshot" + sudo btrfs subvolume delete "$snapshot" + fi + done +} + +# Exécuter le nettoyage +cleanup_local_snapshots +cleanup_remote_snapshots + +echo "Sauvegarde et nettoyage terminés" diff --git a/btrfs-move-fast.sh b/btrfs-move-fast.sh new file mode 100755 index 0000000..aef125b --- /dev/null +++ b/btrfs-move-fast.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash + +# Vérifier les arguments +if [ $# -lt 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +# Le dernier argument est toujours la destination +DEST_DIR="${@: -1}" +# Tous les arguments sauf le dernier sont considérés comme des motifs source +SOURCE_PATTERNS=("${@:1:$#-1}") + +# Créer le répertoire de destination s'il n'existe pas +mkdir -p "$DEST_DIR" + +# Fonction pour déplacer rapidement un snapshot +move_snapshot_fast() { + local src=$1 + local dest=$2 + local snapshot_name=$(basename "$src") + + echo "Déplacement rapide du snapshot $src vers $dest/$snapshot_name" + + # Créer un nouveau snapshot read-write à la destination + sudo btrfs subvolume snapshot "$src" "$dest/$snapshot_name" + + if [ $? -eq 0 ]; then + echo "Nouveau snapshot créé avec succès." + + # Supprimer l'ancien snapshot + echo "Suppression de l'ancien snapshot..." + sudo btrfs subvolume delete "$src" + + if [ $? -eq 0 ]; then + echo "Ancien snapshot supprimé avec succès." + else + echo "Erreur lors de la suppression de l'ancien snapshot. Veuillez le supprimer manuellement." + fi + else + echo "Erreur lors de la création du nouveau snapshot." + fi +} + +# Parcourir tous les motifs source +for pattern in "${SOURCE_PATTERNS[@]}"; do + # Utiliser la commande find pour gérer les jokers + while IFS= read -r -d $'\0' snapshot; do + if [ -d "$snapshot" ]; then + # Vérifier si c'est un sous-volume BTRFS + if sudo btrfs subvolume show "$snapshot" &> /dev/null; then + move_snapshot_fast "$snapshot" "$DEST_DIR" + else + echo "Ignoré: $snapshot n'est pas un sous-volume BTRFS." + fi + fi + done < <(find "$(dirname "$pattern")" -maxdepth 1 -mindepth 1 -type d -name "$(basename "$pattern")" -print0) +done + +echo "Opération terminée." diff --git a/github-init-repo-priv.sh b/github-init-repo-priv.sh new file mode 100755 index 0000000..55528bb --- /dev/null +++ b/github-init-repo-priv.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +project_name=$(basename "$(pwd)") +gitignore_source="$HOME/dotfiles/misc/gitignore" +license="$HOME/dotfiles/misc/license" + +# Initialisation du dépôt git local +git init || { + echo "Erreur lors de l'initialisation du dépôt git" >&2 + exit 1 +} + +# Configuration des fichiers de base +if [[ -f "$gitignore_source" ]]; then + cat "$gitignore_source" >.gitignore +else + echo "Erreur : le fichier .gitignore source est introuvable." >&2 + exit 1 +fi + +touch .env && echo "MY_ENV=$project_name" >>.env + +echo "# $project_name" >README.md + +if [[ -f "$license" ]]; then + cat "$license" >LICENSE +else + echo "Erreur : le fichier 'LICENSE' source est introuvable." >&2 + exit 1 +fi + +# Création du dépôt GitHub +if ! command -v gh &>/dev/null; then + echo "Erreur : GitHub CLI (gh) n'est pas installé." >&2 + exit 1 +fi + +gh repo create "$project_name" --private --source=. --remote=origin || { + echo "Erreur lors de la création du dépôt GitHub." >&2 + exit 1 +} + +git add . && git commit -m "initial commit" && git push --set-upstream origin main + +echo "Le dépôt GitHub '$project_name' a été créé avec succès à l'adresse \ + https://github.com/isingasimplesong/$project_name" diff --git a/github-init-repo-pub.sh b/github-init-repo-pub.sh new file mode 100755 index 0000000..400b4d6 --- /dev/null +++ b/github-init-repo-pub.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +project_name=$(basename "$(pwd)") +gitignore_source="$HOME/dotfiles/misc/gitignore" +license="$HOME/dotfiles/misc/license" + +# Initialisation du dépôt git local +git init || { + echo "Erreur lors de l'initialisation du dépôt git" >&2 + exit 1 +} + +# Configuration des fichiers de base +if [[ -f "$gitignore_source" ]]; then + cat "$gitignore_source" >.gitignore +else + echo "Erreur : le fichier .gitignore source est introuvable." >&2 + exit 1 +fi + +touch .env && echo "MY_ENV=$project_name" >>.env + +echo "# $project_name" >README.md + +if [[ -f "$license" ]]; then + cat "$license" >LICENSE +else + echo "Erreur : le fichier 'LICENSE' source est introuvable." >&2 + exit 1 +fi + +# Création du dépôt GitHub +if ! command -v gh &>/dev/null; then + echo "Erreur : GitHub CLI (gh) n'est pas installé." >&2 + exit 1 +fi + +gh repo create "$project_name" --public --source=. --remote=origin || { + echo "Erreur lors de la création du dépôt GitHub." >&2 + exit 1 +} + +git add . && git commit -m "initial commit" && git push --set-upstream origin main + +echo "Le dépôt GitHub '$project_name' a été créé avec succès à l'adresse \ + https://github.com/isingasimplesong/$project_name" diff --git a/hypr-toggle-layouts.sh b/hypr-toggle-layouts.sh new file mode 100755 index 0000000..27e9e00 --- /dev/null +++ b/hypr-toggle-layouts.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +TOGGLE_PATH="/home/mathieu/.config/hypr/modules/envvar.conf" +sed -i 's/master/passeplat/;s/dwindle/master/;s/passeplat/dwindle/' $TOGGLE_PATH diff --git a/kinetic_energy.py b/kinetic_energy.py new file mode 100755 index 0000000..36e6efc --- /dev/null +++ b/kinetic_energy.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 + +import argparse + +# get kinetic energy for any object you know the speed and weight +# To use, just run python3 kinetic_energy.py --speed 30 --weight 1500 +# speed is in Km/h, weight in Kg + + +def calculate_energy(weight, velocity): + # Convert weight from kg to Newtons (1 kg = 9.81 N) + mass = weight * 9.81 + + # Calculate kinetic energy (in Joules) + kinetic_energy = 0.5 * mass * (velocity**2) + + return kinetic_energy + + +def convert_kmh_to_ms(kmh): + return kmh * (1000 / 3600) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + description="Calculate kinetic energy of a moving vehicle" + ) + parser.add_argument( + "-s", type=float, required=True, help="Velocity in kilometers per hour" + ) + parser.add_argument("-w", type=float, required=True, help="Weight in kilograms") + args = parser.parse_args() + + velocity_km = args.s + velocity_ms = convert_kmh_to_ms(velocity_km) + weight = args.w + + energy = calculate_energy(weight, velocity_ms) + + print(f"Kinetic Energy: {energy:.2f} J") diff --git a/nextcloud-sync.sh b/nextcloud-sync.sh new file mode 100755 index 0000000..a609bf8 --- /dev/null +++ b/nextcloud-sync.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +# Nextcloud server URL +NEXTCLOUD_URL="https://nc.2027a.net" + +# User credentials +USERNAME="mathieu" +PASSWORD="" + +# Define local and remote directory pairs +SYNC_DIRS=( + "/home/mathieu/Dev:/Dev" + "/home/mathieu/Documents:/Documents" + "/home/mathieu/Images:/Images" +) + +# Function to sync a single directory +sync_directory() { + local_dir=$1 + remote_path=$2 + + echo "Syncing $local_dir to $remote_path" + nextcloudcmd \ + --user "$USERNAME" \ + --password "$PASSWORD" \ + --non-interactive \ + --silent \ + --path "$remote_path" \ + "$local_dir" \ + "$NEXTCLOUD_URL" + + if [ $? -eq 0 ]; then + echo "Sync completed successfully for $local_dir" + else + echo "Sync failed for $local_dir" + fi +} + +# Main script +echo "Starting Nextcloud synchronization" + +for pair in "${SYNC_DIRS[@]}"; do + IFS=':' read -r local_dir remote_path <<< "$pair" + sync_directory "$local_dir" "$remote_path" +done + +echo "Synchronization process completed" diff --git a/note-dailies.sh b/note-dailies.sh new file mode 100755 index 0000000..517e589 --- /dev/null +++ b/note-dailies.sh @@ -0,0 +1,2 @@ +!#/usr/bin/env bash +cd ~/Notes && nvim +'autocmd VimEnter * ObsidianDailies' all/Todo.md diff --git a/note-grep.sh b/note-grep.sh new file mode 100755 index 0000000..a84acf3 --- /dev/null +++ b/note-grep.sh @@ -0,0 +1,2 @@ +!#/usr/bin/env bash +cd ~/Notes && nvim +'autocmd VimEnter * ObsidianSearch' all/Todo.md diff --git a/note-journal.sh b/note-journal.sh new file mode 100755 index 0000000..31d0142 --- /dev/null +++ b/note-journal.sh @@ -0,0 +1,2 @@ +!#/usr/bin/env bash +cd ~/Notes && nvim +'autocmd VimEnter * ObsidianToday' all/Todo.md diff --git a/note-new-from-template.sh b/note-new-from-template.sh new file mode 100755 index 0000000..bc6ef89 --- /dev/null +++ b/note-new-from-template.sh @@ -0,0 +1,2 @@ +!#/usr/bin/env bash +cd ~/Notes && nvim +'autocmd VimEnter * ObsidianNewFromTemplate' all/Todo.md diff --git a/note-new.sh b/note-new.sh new file mode 100755 index 0000000..67ec034 --- /dev/null +++ b/note-new.sh @@ -0,0 +1,2 @@ +!#/usr/bin/env bash +cd ~/Notes && nvim +'autocmd VimEnter * ObsidianNew' all/Todo.md diff --git a/note-quick-switch.sh b/note-quick-switch.sh new file mode 100755 index 0000000..8fac7a3 --- /dev/null +++ b/note-quick-switch.sh @@ -0,0 +1,2 @@ +!#/usr/bin/env bash +cd ~/Notes && nvim +'autocmd VimEnter * ObsidianQuickSwitch' all/Todo.md diff --git a/note-search-by-tags.sh b/note-search-by-tags.sh new file mode 100755 index 0000000..6c9bfa3 --- /dev/null +++ b/note-search-by-tags.sh @@ -0,0 +1,2 @@ +!#/usr/bin/env bash +cd ~/Notes && nvim +'autocmd VimEnter * ObsidianTags' all/Todo.md diff --git a/notes-dmenu.sh b/notes-dmenu.sh new file mode 100755 index 0000000..b50b63d --- /dev/null +++ b/notes-dmenu.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +options=$(cat <<-END +Nouvelle note +Depuis un modèle +Journal +Journaux récents +Chercher dans le contenu +Chercher dans le titre +Chercher par tags +Réviser Inbox +Todo +Accueil +END +) + +selected=$(echo -e "$options" | rofi -i -dmenu -p "Carnet :") + +case "$selected" in + "Nouvelle note") + kitty -e /home/mathieu/.local/bin/note-new.sh + ;; + "Depuis un modèle") + kitty -e /home/mathieu/.local/bin/note-new-from-template.sh + ;; + "Journal") + kitty -e /home/mathieu/.local/bin/note-journal.sh + ;; + "Journaux récents") + kitty -e /home/mathieu/.local/bin/note-dailies.sh + ;; + "Chercher dans le contenu") + kitty -e /home/mathieu/.local/bin/note-grep.sh + ;; + "Chercher par nom") + kitty -e /home/mathieu/.local/bin/note-quick-switch.sh + ;; + "Chercher par tags") + kitty -e /home/mathieu/.local/bin/note-search-by-tags.sh + ;; + "Réviser Inbox") + kitty -e nvim ~/Notes/inbox/* + ;; + "Todo") + kitty -e nvim ~/Notes/all/Todo.md + ;; + "Accueil") + kitty -e nvim ~/Notes/all/Home.md + ;; + *) + echo "Option non valide ou annulée." + ;; +esac + diff --git a/post-sleep-check.sh b/post-sleep-check.sh new file mode 100755 index 0000000..9702d69 --- /dev/null +++ b/post-sleep-check.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +LAST_RUN=$(systemctl --user show snapshot-reminder.service --property=ExecMainExitTimestamp | cut -d= -f2) +CURRENT_TIME=$(date +%s) +LAST_RUN_SECONDS=$(date -d "$LAST_RUN" +%s) +TIME_DIFF=$((CURRENT_TIME - LAST_RUN_SECONDS)) + +if [ $TIME_DIFF -gt 86400 ]; then # 86400 secondes = 24 heures + systemctl --user start snapshot-reminder.service +fi diff --git a/powers.py b/powers.py new file mode 100755 index 0000000..cf5f5af --- /dev/null +++ b/powers.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 + +# display 2^ +powers = list(range(1,16)) + +for int in powers: + power = 2 ** int + print(f"2^{int} vaut {power}") diff --git a/qr_make.py b/qr_make.py new file mode 100755 index 0000000..7426754 --- /dev/null +++ b/qr_make.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +import os +import qrcode + +img = qrcode.make(input("string: ")) + +qr_path = os.path.expanduser("~/code_qr.png") +img.save(qr_path, "PNG") + +os.system("xdg-open " + qr_path) +exit() diff --git a/rofi-beats-linux.sh b/rofi-beats-linux.sh new file mode 100755 index 0000000..7463012 --- /dev/null +++ b/rofi-beats-linux.sh @@ -0,0 +1,156 @@ +#!/usr/bin/env bash + +# This script provides a simple way to listen to various radio stations using +# the mpv media player. It displays a menu with a list of radio stations, and +# allows the user to select one using the rofi application launcher. Upon +# selecting a station, a notification will be sent with the station's name, +# and the station will start playing using mpv with specified volume level. + +# If the script is run while a station is already playing, it will stop the +# currently playing station. + +# The script supports a variety of radio stations, that can easily be adjusted to user's preferences + +# Note: This script requires mpv and rofi to be installed. + +# add more args here according to preference +ARGS="--volume=50" + +notification(){ +# change the icon to whatever you want. Make sure your notification server +# supports it and already configured. + +# Now it will receive argument so the user can rename the radio title +# to whatever they want + + notify-send "On écoute: " "$@" --icon=media-tape +} + +menu(){ + printf "1. FIP\n" + printf "2. ICI Première\n" + printf "3. FIP Nouveautés\n" + printf "4. FIP Jazz\n" + printf "5. FIP Groove\n" + printf "6. FIP Reggae\n" + printf "7. FIP Monde\n" + printf "8. P4k1d3rm!\n" + printf "9. TSF Jazz\n" + printf "11. France Culture\n" + printf "12. France Info\n" + printf "13. France Inter\n" + printf "14. France Musique\n" + printf "15. RFI Monde\n" + printf "16. Radio Ouistiti\n" + printf "17. Lofi Girl - Beats to sleep\n" + printf "18. Lofi Girl - Beats to relax/study\n" + printf "19. Synthwave - Retrowave - Retro Electro Livestream\n" +} + +main() { + choice=$(menu | rofi -dmenu | cut -d. -f1) + + case $choice in + 1) + notification "FIP 📻🎶"; + URL="http://icecast.radiofrance.fr/fip-hifi.aac" + + break + ;; + 2) + notification "ICI Première 📻"; + URL="http://cbcmp3.ic.llnwd.net/stream/cbcmp3_P-2QMTL0_MTL" + break + ;; + 3) + notification "FIP Nouveautés 📻🎶"; + URL="http://direct.fipradio.fr/live/fip-webradio5.mp3" + break + ;; + 4) + notification "FIP Jazz 📻🎶"; + URL="http://direct.fipradio.fr/live/fip-webradio2.mp3" + break + ;; + 5) + notification "FIP Groove 📻🎶"; + URL="http://direct.fipradio.fr/live/fip-webradio3.mp3" + break + ;; + 6) + notification "FIP Reggae 📻🎶"; + URL="http://direct.fipradio.fr/live/fip-webradio6.mp3" + break + ;; + 7) + notification "FIP Monde 📻🌍🎶"; + URL="http://direct.fipradio.fr/live/fip-webradio4.mp3" + break + ;; + 8) + notification "P4k1D3rm! 📻🎶"; + URL="https://www.youtube.com/watch?v=iiXtSKQCa4s" + break + ;; + 9) + notification "TSF Jazz 📻🎶"; + URL="http://tsfjazz.ice.infomaniak.ch/tsfjazz-high" + break + ;; + 10) + notification "HOT 97 New York 📻🎶"; + URL="https://24883.live.streamtheworld.com/KVEGFM.mp3" + break + ;; + 11) + notification "France culture 📻"; + URL="http://icecast.radiofrance.fr/franceculture-hifi.aac" + break + ;; + 12) + notification "France Info 📻"; + URL="http://icecast.radiofrance.fr/franceinfo-hifi.aac" + break + ;; + 13) + notification "France Inter 📻"; + URL="http://icecast.radiofrance.fr/franceinter-hifi.aac" + break + ;; + 14) + notification "France Musique 📻🎶"; + URL="http://icecast.radiofrance.fr/francemusique-hifi.aac" + break + ;; + 15) + notification "RFI Monde 📻"; + URL="http://live02.rfi.fr/rfimonde-96k.mp3" + break + ;; + 16) + notification "Radio Ouistiti 📻🎶"; + URL="http://ouistiti.stream2net.eu:8100/;" + break + ;; + 17) + notification "Lofi Girl - beats to sleep 📻🎶"; + URL="https://www.youtube.com/watch?v=rUxyKA_-grg" + break + ;; + 18) + notification "Lofi Girl - beats to relax/study 📻🎶"; + URL="https://www.youtube.com/watch?v=jfKfPfyJRdk" + break + ;; + 19) + notification "Synthwave - Retrowave - Retro Electro Livestream 📻🎶"; + URL="https://www.youtube.com/watch?v=9P23oE6ekwQ" + break + ;; + esac + # run mpv with args and selected url + # added title arg to make sure the pkill command kills only this instance of mpv + mpv --no-video $ARGS --title="radio-mpv" $URL +} + +pkill -f radio-mpv || main diff --git a/rsync4duplicati.sh b/rsync4duplicati.sh new file mode 100755 index 0000000..1f0c43e --- /dev/null +++ b/rsync4duplicati.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +MOUNT_POINT="/backups" +DEST="/backups/radium" +SOURCE="/home/mathieu/.config/rsync/in-rsync4duplicati.txt" +EXCLUDE="/home/mathieu/.config/rsync/ex-rsync4duplicati.txt" +LOG_FILE="/home/mathieu/.local/logs/rsync4duplicati.log" +NOTIFY_TITLE="Rsync" + +source /root/secrets +USER_KEY="$PUSHOVER_USER_KEY" +API_TOKEN="$PUSHOVER_API_TOKEN" + +# Fonction pour logger +log_message() { + echo "$(date +"%Y-%m-%d %H:%M:%S") - $1 - $2" >> "$LOG_FILE" +} + +# Fonction pour envoyer une notification Pushover +send_pushover_notification() { + curl -s \ + --form-string "token=$API_TOKEN" \ + --form-string "user=$USER_KEY" \ + --form-string "message=$1" \ + --form-string "title=$NOTIFY_TITLE" \ + https://api.pushover.net/1/messages.json +} + +# Vérification du point de montage +if ! mountpoint -q "$MOUNT_POINT"; then + log_message "ERROR" "Point de montage $MOUNT_POINT absent" + send_pushover_notification "Échec de rsync4duplicati : /backups non monté" + exit 1 +fi + +# rsync +while IFS= read -r ligne +do + echo "$ligne" + if rsync -r -t -p -o -g -x --progress --delete -l -z -s --exclude-from "$EXCLUDE" "$ligne" "$DEST"; then + log_message "OK" "Rsync réussi pour $ligne" + else + ERROR_MSG=$(rsync -r -t -p -o -g -x --progress --delete -l -z -s --exclude-from "$EXCLUDE" "$ligne" "$DEST" 2>&1) + log_message "ERROR" "Rsync échoué pour $ligne: $ERROR_MSG" + send_pushover_notification "Échec de rsync4duplicati pour $ligne: voir le log pour plus de détails" + fi +done < "$SOURCE" diff --git a/ssh-tunnel-pluton.sh b/ssh-tunnel-pluton.sh new file mode 100755 index 0000000..5ef2c50 --- /dev/null +++ b/ssh-tunnel-pluton.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# crée un tunnel ssh exposant pluton:port sur localhost:port +ssh -L 5001:localhost:5001 -L 8200:localhost:8200 pluton diff --git a/update_pacman_mirrorlist.sh b/update_pacman_mirrorlist.sh new file mode 100755 index 0000000..f9f8d22 --- /dev/null +++ b/update_pacman_mirrorlist.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# Récupère les meilleurs miroirs +mirrors=$(curl -s "https://archlinux.org/mirrorlist/?country=CA&country=US&protocol=https&use_mirror_status=on" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 5 -) + +# Sauvegarde l'ancien miroir +sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak + +# Ecrit la nouvelle liste de miroirs avec les permissions nécessaires +echo "$mirrors" | sudo tee /etc/pacman.d/mirrorlist >/dev/null + +# Affiche un message de confirmation +echo "Mirrorlist updated. New mirrors are:" +cat /etc/pacman.d/mirrorlist diff --git a/wallpaper-converter.sh b/wallpaper-converter.sh new file mode 100755 index 0000000..c0e4a69 --- /dev/null +++ b/wallpaper-converter.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# Vérifier si ImageMagick est installé +if ! command -v convert &>/dev/null; then + echo "ImageMagick n'est pas installé" + exit 1 +fi + +input_dir="$HOME/Images/walls" +output_dir="$HOME/Images/walls_converted" + +mkdir -p "$output_dir" + +# Compteur pour le renommage séquentiel +count=1 + +# Parcourir tous les fichiers PNG, WebP et JPG dans le répertoire d'entrée +find "$input_dir" -type f \( -iname "*.png" -o -iname "*.webp" -o -iname "*.jpg" -o -iname "*.jpeg" \) | while read file; do + # Générer le nouveau nom de fichier + new_name=$(printf "wall-%04d.webp" "$count") + + # Convertir et renommer le fichier + magick "$file" "$output_dir/$new_name" + + echo "Converti : $file -> $output_dir/$new_name" + + # Incrémenter le compteur + ((count++)) +done + +echo "Conversion terminée. Les nouveaux fichiers sont dans $output_dir" diff --git a/waybar-toggle-tray.sh b/waybar-toggle-tray.sh new file mode 100755 index 0000000..8e42abb --- /dev/null +++ b/waybar-toggle-tray.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +CONFIG_PATH="$HOME/.config/waybar/config.jsonc" +sed -i 's#^\s*//\("tray",\)#\1#;t;s#^\s*\("tray",\)#//\1#' $CONFIG_PATH +killall -SIGUSR2 waybar diff --git a/wlkill.sh b/wlkill.sh new file mode 100755 index 0000000..af8eb01 --- /dev/null +++ b/wlkill.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Obtenir l'ID de la fenêtre active +WINDOW_ID=$(hyprctl activewindow -j | jq '.address') + +if [ -z "$WINDOW_ID" ]; then + notify-send "Erreur" "Aucune fenêtre active trouvée" + exit 1 +fi + +# Obtenir le PID du processus +PID=$(hyprctl clients -j | jq ".[] | select(.address == $WINDOW_ID) | .pid") + +if [ -z "$PID" ]; then + notify-send "Erreur" "Impossible de trouver le PID de la fenêtre" + exit 1 +fi + +# Tuer le processus +kill -9 $PID + +# Notifier l'utilisateur +notify-send "Fenêtre tuée" "PID: $PID"