diff --git a/.aliases b/.aliases index a37d16a..7efc90f 100644 --- a/.aliases +++ b/.aliases @@ -1,18 +1,19 @@ #!/bin/bash +#alias sudo=doas +#alias sudoedit='doas micro' alias please='sudo $(history -p \!\!)' -alias xobreset='test $(pgrep xob | wc -l) -ne 2 && ( killall xob ; /usr/bin/tail -q -f "/tmp/log/volume" | /usr/local/bin/xob -q -s volume & /usr/bin/tail -q -f "/tmp/log/brightness" | /usr/local/bin/xob -q -s brightness & )' #alias mount=usermount alias rename=qmv alias unswap='sudo unswap' -alias UNSWAP='xdotool key Caps_Lock ; sudo unswap' #alias rm='echo "(using trash-put instead of rm.)" ; trash-put $@' #aptitude shortcuts alias search='aptitude search' alias install='sudo aptitude install' +#function searchstall() { aptitude search $1 && echo -e "\n\n package was found: installing\nsudo aptitude install $1" && sudo aptitude install $1 } alias remove='sudo aptitude purge' alias show='aptitude show' alias why='aptitude why' @@ -30,7 +31,7 @@ alias toggle-locker='pgrep xss-lock > /dev/null && ( xset s off ; xset -dpms ; p alias commit='git commit' alias add='git add' #alias status='git status' -alias log='git log --reflog --pretty=oneline --decorate --graph --shortstat --simplify-by-decoration' +alias log='git log -n 20 --pretty=oneline --decorate --graph --shortstat' alias branch='git branch' alias pull='git pull' alias push='git push' @@ -38,28 +39,55 @@ alias push='git push' #display preferences eval "`dircolors`" alias ls='ls --color=auto' -alias ll='ls -Agh' +alias ll='ls -Aghv' alias ..='cd .. ; ll' alias ...='cd ../.. ; ll' alias ....='cd ../../.. ; ll' -alias ~='cd /home/karsaell' +alias ~='cd $HOME' alias lsblk='lsblk -o name,size,type,mountpoint' alias du='du -hxd1' alias sxiv='sxiv -aors d' alias duu='du -hcd1 | sort -h' +alias cp='cp -vr' #current workflow -alias pdfrotate='pdfjam --a4paper --no-landscape --angle 90 --outfile rotated.pdf ' -alias pdfunlock='read -p "Password: " -s pass ; echo -e "\nFile will be saved to ./unlocked.pdf" ; mutool convert -p "${pass}" -F pdf -o unlocked.pdf ' -alias cse='firefox --new-window --private-window https://mail.ovh.net/roundcube/ & pass=$(dmenu -P) ; wid=$(xdotool search --sync --onlyvisible --name "Roundcube.*Private") ; until test "${wid}" -a $"{pass}" ; do sleep 0.5 ; done ; xdotool windowactivate --sync "${wid}" ; until test $(xdotool getactivewindow) = "${wid}" ; do sleep 0.5 ; done ; sleep 0.5 ; xdotool type --window "${wid}" --clearmodifiers "delegation-cse@latelierpaysan.org ${pass}" ; xdotool key --window "${wid}" --clearmodifiers Return ; sleep 1 ; exit' -alias py=python3 + #Games +alias aiwar='$HOME/Games/AI\ War/start.sh' +alias bfme='lxterminal -e "cd $HOME/Games/BFME ; wine lotrbfme.exe"' +alias camillelachenal='cd $HOME/Music/Camille\ Lachenal/ ; mpv --loop-playlist=inf À*.opus --\{ --start=24 \[Confinement\ \#27\]\ Valse\ tactile\ \(valse\ à\ 11\ temps\).m4a --\}' +alias civ5="cd $HOME/.steam/debian-installation/steamapps/common/Sid\ Meier\'s\ Civilization\ V/ ; ./Civ5XP ; cd -" +#alias factorio='$HOME/Games/factorio_Space-Age/factorio/launcher.sh' #script copied at /usr/local/bin/factorio +alias ftl='$HOME/Games/FTL/start.sh' +alias Gladius="cd '$HOME/.steam/debian-installation/steamapps/common/Warhammer 40000 Gladius - Relics of War/Binaries/Linux-x86_64' ; ./Gladius.bin ; cd -" +alias minecraft='$HOME/.local/share/multimc/MultiMC' +alias northgard='steam steam://rungameid/466560' +alias rimworld='$HOME/.steam/steam/steamapps/common/RimWorld/RimWorldLinux' +alias SongsOfSyx='cd $HOME/Games/Songs\ of\ Syx_V66/ ; java -jar SongsOfSyx.jar ; cd -' +alias swarm='$HOME/Games/Swarm/swarm-Linux' +alias starsector="cd /home/karsaell/Games/StarSector/starsector ; setxkbmap us ; ./starsector.sh ; setxkbmap fr ; cd -" +alias starsector_shuffle="cd /home/karsaell/Games/StarSector/starsector/saves ; cd \$(ls -t | head -n 1 ) ; mv campaign.xml descriptor.xml .. ; mv campaign.xml.bak campaign.xml ; mv descriptor.xml.bak descriptor.xml ; mv ../campaign.xml campaign.xml.bak ; mv ../descriptor.xml descriptor.xml.bak ; ll ; cd -" #Switch the last autosave and latest save to quick-reload +alias stellaris="cd $HOME/.steam/steam/steamapps/common/Stellaris ; setxkbmap us ; ./stellaris ; setxkbmap fr ; cd -" +alias terraformers='$HOME/Games/Terraformers/game/terraformers_first_steps_on_mars.x86_64' +alias vagrus='$HOME/Games/Vagrus/start.sh' +alias voxeltycoon='steam steam://rungameid/732050' +alias x3='$HOME/Games/X3/start.sh' + + #Others +alias cse='firefox --new-window --private-window https://mail.ovh.net/roundcube/ ; pass=$(dmenu -P) ; wid=$(xdotool search --sync --onlyvisible --name "Roundcube.*Private") ; until test "${wid}" -a $"{pass}" ; do sleep 0.5 ; done ; xdotool windowactivate --sync "${wid}" ; until test $(xdotool getactivewindow) = "${wid}" ; do sleep 0.5 ; done ; sleep 0.5 ; xdotool type --window "${wid}" --clearmodifiers "delegation-cse@latelierpaysan.org ${pass}" ; xdotool key --window "${wid}" --clearmodifiers Return' +alias pdfrotate='pdfjam --a4paper --no-landscape --angle 90 --outfile rotated.pdf ' +alias pdfunlock='read -p "Password: " -s pass ; echo -e "\nFile will be saved to ./unlocked.pdf" ; mutool convert -p "${pass}" -F pdf -o unlocked.pdf ' +alias py='python3' +alias wlist='nmcli radio wifi on ; nmcli device wifi list --rescan yes' +alias xobreset='test $(pgrep xob 2>&1 | wc -l) -ne 2 && ( killall xob ; /usr/bin/tail -q -f "/tmp/log/volume" | /usr/local/bin/xob -q -s volume & /usr/bin/tail -q -f "/tmp/log/brightness" | /usr/local/bin/xob -q -s brightness & )' +alias azerty='setxkbmap us' +alias qwerty='setxkbmap fr' #mututuelle -alias ncmutu='read -s -p "Password: " pass ; nextcloudcmd --user Mututu --password "$pass" /home/karsaell/Documents/Mututuelle https://nuage.jean-cloud.net' -alias mutunion='firefox https://discord.com/app https://lite.framacalc.org/9kcj-mututuelle_mensuel https://nuage.jean-cloud.net/apps/files/ https://mypads2.framapad.org/p/mutuelle-du-shlag-14-10-xg71yj9zs https://jitsi.hadoly.fr/mutuelle_dispers%C3%A9e' +alias ncmutu='read -s -p "Password: " pass ; nextcloudcmd --user Mututu --password "$pass" $HOME/Documents/Mututuelle https://nuage.jean-cloud.net' +alias mutunion='firefox https://discord.com/app https://lite.framacalc.org/9kcj-mututuelle_mensuel https://nuage.jean-cloud.net/apps/files/ https://mypads2.framapad.org/p/mutuelle-du-shlag-14-10-xg71yj9zs https://meet.evolix.org/mutuelle_spers%C3%A9e' #networks -alias hotspot='nmcli radio wifi on ; sleep 1 ; nmcli --fields SSID device wifi | grep -q "wifi_AP" && nmcli connection down karsaell-hotspot || ( nmcli connection up karsaell-hotspot; nmcli device wifi show-password ; sleep 1800 ; nmcli connection down karsaell-hotspot ; nmcli radio wifi off )&' +alias hotspot='nmcli radio wifi on ; sleep 1 ; nmcli --fields SSID device wifi | grep -q "aaaaaaaa" && ( nmcli connection down karsaell-hotspot ; nmcli radio wifi off ) || ( nmcli radio wifi on ; nmcli connection up karsaell-hotspot; nmcli device wifi show-password ; sleep 1800 ; nmcli connection down karsaell-hotspot ; nmcli radio wifi off )&' alias android='sudo umount /media/karsaell/android ; sudo rmdir /media/karsaell/android/ ; sudo mkdir /media/karsaell/android/ ; sudo chown karsaell:karsaell /media/karsaell/android/ ; jmtpfs /media/karsaell/android/' alias httpserver='python3 -m http.server' @@ -78,33 +106,26 @@ function cl() { function update() { - if test $(df -l --sync --output=avail,target 2>/dev/null | grep /$ | tr -d " /" ) -lt 1000000 ; then + if test $(df 2>/dev/null | grep /$ | tr -s " " | cut -d " " -f 4 ) -lt 1000000 ; then status + echo -e "\n\n############\n\nWarning: less than 1GB free space on /\n\n############\n\n\t Attend to swapfiles:\n\n" + + sudo swapctl -i fi sudo echo ok. sudo aptitude update sudo aptitude upgrade + kernels=$(search "?name(linux-image-[0-9\.]+\-[0-9]+\-[^ ]+)" | grep ^i | grep -o -E "linux-image-[0-9\.]+\-[0-9]+\-[^ ]+" | head -n -2) ; test "$kernels" && echo " + +extra kernel packages to remove: +$kernels + +" && sudo aptitude purge $kernels sudo aptitude clean + sudo unswap + echo "powersave" | sudo tee /sys/devices/system/cpu/cpufreq/policy*/scaling_governor + sudo -K } - -function mailexp() { - thunderbird -compose \ - from=atelier@latelierpaysan.org \ - to=commandes@latelierpaysan.org \ - subject="Expédition $1 $2" \ - body="Palette prête : \n$3 kg ; $4 x $5 x $6 cm" -} - -function leviials() { - read -p "user: " USER - read -p "password: " PASSWORD - folder=$1 - domain="cloud.latelierpaysan.org" - path='/remote.php/webdav' - suffix='' - prefix=$path$folder - - curl -s -X PROPFIND "https://$domain/remote.php/webdav$folder" -u 'USER:PASSWORD' | xmllint --format - | grep href | awk '{$1=$1};1' | cut -c$((${#prefix}+1))- | rev | cut -c$((${#suffix}+1))- | grep . | rev | while read; do echo -e ${REPLY//%/\\x}; done -} +alias UPDATE='xdotool key Caps_Lock ; update' diff --git a/paginator b/paginator new file mode 100644 index 0000000..9c69de4 --- /dev/null +++ b/paginator @@ -0,0 +1,38 @@ +#!/bin/bash + +# Script rédigé par Pieds-Nus au février 2025 pour concaténer des plans pdf et insérer les numéros de page +# fournir en argument la liste des fichiers pdf à assembler, dans l'ordre. +# le résultat sera enregistré dans le dossier courant, sous le nom "output.pdf" +# +# Dependencies : +# bash +# grep +# mutool, from package mupdf-tools : https://mupdf.com/ +# a functionning texlive installation, for instance the texlive-base package in debian +# pdfjam (should be included in texlive-extra-utils, or can be retrieved here : https://ctan.org/pkg/pdfjam) +# eso-pic (should be included in texlive, or can be retrieved here : https://ctan.org/pkg/eso-pic) +# open-sans font (should be included in texlive-fonts-extra, or can be retrieved here : https://ctan.org/pkg/opensans) + +pagecount=$(mutool pages $@ | grep -c "pagenum" ) + +echo "Page count: ${pagecount}" + +pre="\documentclass[a3paper,landscape]{minimal} +\usepackage{eso-pic} +\usepackage[default,scale=1.35]{opensans}" + +#edit the values in this line to adjust position of the page numbers : +#cartouche AtelierPaysan : pagecommand="{\AddToShipoutPictureFG{\AtPageUpperLeft{\raisebox{-21.1mm}{\hspace{93.25mm}\colorbox{white}{\makebox[37.3mm][r]{\textcolor[gray]{0.5}{\thepage\}\raisebox{-0.35mm}{\strut}}}}}}}" +pagecommand="{\AddToShipoutPictureFG{\AtPageUpperLeft{\raisebox{-190mm}{\hspace{90mm}\colorbox{white}{\makebox[37.3mm][r]{\textcolor[gray]{0.5}{\thepage\}\raisebox{-0.35mm}{\strut}}}}}}}" + +pdfjam --no-tidy --a3paper --landscape --preamble "${pre}" --pagecommand "${pagecommand}" -o outfile.pdf $@ + +dir="/tmp/$(ls -t /tmp/ | grep "pdfjam-*" | head -n 1)" +cd "${dir}" +sed -i -E "s/\\documentclass\[a3paper,landscape\]\{article\}/\\documentclass\[a3paper,landscape\]\{minimal\}/" a.tex +pdflatex -no-shell-escape a.tex +cd - +mv "${dir}/a.pdf" outfile.pdf +mutool clean -gggg -l -zfism outfile.pdf outfile_clean.pdf + +mupdf outfile_clean.pdf && rm -rf "${dir}" diff --git a/trustisover.alias b/trustisover.alias new file mode 100644 index 0000000..1e79214 --- /dev/null +++ b/trustisover.alias @@ -0,0 +1 @@ +alias sudo='read -s -p "[sudo] password for $(whoami): " pass ;echo -e "\nYou typed in \"$pass\". Is that really your sudo password ? [Y/n]" ; read -p "Please confirm: " ; echo "Oh really ? Should I post it online, then ?" ; read -p "[Facebook/Twitter/Reddit/Instagram/TikTok] : ";sudo' diff --git a/wrapter b/wrapter index 35ac1f0..2bc69ab 100644 --- a/wrapter +++ b/wrapter @@ -6,12 +6,13 @@ action="$(basename "${0}")" -test "${action}" = wrapter && action="$(dmenu <<< "\ +test "${action}" = wrapter && action="$(dmenu -p Action: <<< "\ install show remove -why\ -")" +why")" + +test "$@" && search="$@" || search="$(dmenu -p Search: <<< "" )" case "${action}" in *[iI][ns][ns]tall* ) @@ -28,10 +29,12 @@ case "${action}" in exit 1;; esac -pkgs="$(aptitude search $@ | grep -v ":i386" )" +pkgs="$(aptitude search $search | grep -v ":i386" )" -test -z "${pkgs}" && echo "No pkgs found matching $@." && exit 2 +test -z "${pkgs}" && echo "No pkgs found matching $search." && exit 2 nb="$(wc -l <<< "${pkgs}")" test "${nb}" -gt 1 && echo "$nb packages found." && pkgs="$(echo -e "${pkgs}" | dmenu)" +test "$?" -ne "0" && echo "No package selected." && exit 1 + test "$(wc -l <<< "${pkgs}")" -eq 1 && pkgs="$(tr -s " " <<< "${pkgs}" | cut -d " " -f 2)" && echo -e "Package was found: ${action}ing ${pkgs}\n\$ ${sudo}aptitude ${action} ${pkgs}" && ${sudo}aptitude ${action} "${pkgs}"