nix #11
|
@ -16,7 +16,6 @@ let
|
|||
YARN_CACHE_FOLDER = "${config.xdg.cacheHome}/yarn";
|
||||
# TODO Some of that stuff is not really relavant any more
|
||||
};
|
||||
dotfilesPath = "$HOME/.dotfiles"; # FIXME I think we want it in ~/.config/dotfiles, also, should be an option
|
||||
in
|
||||
{
|
||||
|
||||
|
@ -133,6 +132,18 @@ in
|
|||
diff = "diff --color=auto";
|
||||
dmesg = "dmesg --ctime";
|
||||
wget = "wget --hsts-file ${config.xdg.cacheHome}/wget-hsts";
|
||||
|
||||
# Imported from scripts
|
||||
rms = ''${pkgs.findutils}/bin/find . -name "*.sync-conflict-*" -delete''; # Remove syncthing conflict files
|
||||
pw = ''${pkgs.pwgen}/bin/pwgen 32 -y''; # Generate passwords. ln((26*2+10)**32)/ln(2) ≅ 190 bits of entropy
|
||||
newestFile = ''${pkgs.findutils}/bin/find -type f -printf '%T+ %p\n' | sort | tail'';
|
||||
oldestFile = ''${pkgs.findutils}/bin/find -type f -printf '%T+ %p\n' | sort | head'';
|
||||
tracefiles = ''${pkgs.strace}/bin/strace -f -t -e trace=file'';
|
||||
} // lib.optionalAttrs config.frogeye.desktop.xorg {
|
||||
noise = ''${pkgs.sox}/bin/play -c 2 -n synth $'' + ''{1}noise'';
|
||||
beep = ''${pkgs.sox}/bin/play -n synth sine E5 sine A4 remix 1-2 fade 0.5 1.2 0.5 2> /dev/null'';
|
||||
# FIXME ALSA lib dlmisc.c:337:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_pulse.so (/nix/store/9b06fxbvm07iy9f9dvi5vk2iy9pk8hyz-alsa-lib-1.2.8/lib/alsa-lib/libasound_module_pcm_pulse.so: cannot open shared object file: No such file or directory)
|
||||
|
||||
} // lib.attrsets.mergeAttrsList (map (p: { "${p}" = "HOME=${config.xdg.cacheHome}/junkhome ${p}"; }) treatsHomeAsJunk);
|
||||
# TODO Maybe make nixpkg wrapper instead? So it also works from dmenu
|
||||
# Could also accept my fate... Home-manager doesn't necessarily make it easy to put things out of the home directory
|
||||
|
@ -399,6 +410,7 @@ in
|
|||
wget
|
||||
curl
|
||||
python3Packages.pip
|
||||
rename
|
||||
|
||||
# shell
|
||||
zsh-completions
|
||||
|
@ -425,9 +437,6 @@ in
|
|||
ncdu
|
||||
jdupes
|
||||
duperemove
|
||||
optipng
|
||||
libjpeg
|
||||
# FIXME reflac not available (but also a dumb shell script)
|
||||
|
||||
# local monitoring
|
||||
htop
|
||||
|
@ -490,9 +499,9 @@ in
|
|||
} // direnv;
|
||||
# TODO Session variables only get reloaded on login I think.
|
||||
sessionPath = [
|
||||
"$HOME/.local/bin"
|
||||
"${config.home.homeDirectory}/.local/bin"
|
||||
"${config.home.sessionVariables.GOPATH}"
|
||||
"${dotfilesPath}/config/scripts"
|
||||
"${config.frogeye.dotfiles.path}/config/nix/scripts"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -605,7 +605,6 @@
|
|||
twemoji-color-font
|
||||
gnome.gedit
|
||||
feh
|
||||
zathura
|
||||
zbar
|
||||
zathura
|
||||
meld
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ lib, ... }:
|
||||
{ lib, config, ... }:
|
||||
{
|
||||
options.frogeye = {
|
||||
extra = lib.mkEnableOption "Big software";
|
||||
|
@ -13,6 +13,13 @@
|
|||
fpga = lib.mkEnableOption "FPGA dev stuff";
|
||||
python = lib.mkEnableOption "Python dev stuff";
|
||||
};
|
||||
dotfiles = {
|
||||
path = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "${config.home.homeDirectory}/.dotfiles"; # FIXME I think we want it in ~/.config/dotfiles
|
||||
# FIXME References to this use config/nix subfolder, which we might want to make root
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
chrony = {
|
||||
enable = true;
|
||||
servers = map (n: "${toString n}.europe.pool.ntp.org") (lib.lists.range 0 3);
|
||||
extraConfig = "rtcsync";
|
||||
extraConfig = "rtcsync"; # See 23.11 release notes
|
||||
};
|
||||
|
||||
# Prevent power button from shutting down the computer.
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3 python3Packages.coloredlogs
|
||||
|
||||
import argparse
|
||||
import logging
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p bash openssh coreutils gawk gnused
|
||||
|
||||
# TODO More integrated with current config
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash
|
||||
#! nix-shell -p bash pass libnotify
|
||||
|
||||
# TODO Password changed?
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3 python3Packages.coloredlogs
|
||||
|
||||
"""
|
||||
Same as picture_name_date
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p bash findutils git gnumake
|
||||
|
||||
# Removes files that can be regenerated
|
||||
# from a dev environment
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3 python3Packages.coloredlogs python3Packages.progressbar2 ffmpeg
|
||||
|
||||
import datetime
|
||||
import hashlib
|
|
@ -1,5 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# FIXME
|
||||
|
||||
if [ "$(cat /etc/hostname)" = "curacao.geoffrey.frogeye.fr" ]
|
||||
then
|
||||
echo 10000 | sudo tee /sys/class/backlight/intel_backlight/brightness
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p bash docker gnugrep coreutils
|
||||
|
||||
# Find the dependent child image from an image
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p bash docker
|
||||
|
||||
docker unpause $(docker ps -q)
|
||||
docker kill $(docker ps -q)
|
||||
docker container prune -f
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/bash
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p bash tree coreutils
|
||||
|
||||
# Remplace le contenu d'un dossier par un fichier texte
|
||||
# relatant son arborescense
|
19
config/nix/scripts/emergency-clean
Executable file
19
config/nix/scripts/emergency-clean
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p bash
|
||||
|
||||
# Clears everything it can to save space
|
||||
|
||||
rm -rf $HOME/.cache
|
||||
if command -v pacman > /dev/null; then
|
||||
sudo pacman -Scc
|
||||
fi
|
||||
if command -v apt-get > /dev/null; then
|
||||
sudo apt-get clean
|
||||
fi
|
||||
if command -v nix-store > /dev/null; then
|
||||
sudo journalctl --vacuum-size=100M
|
||||
fi
|
||||
if command -v journalctl > /dev/null; then
|
||||
sudo journalctl --vacuum-size=100M
|
||||
fi
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p bash git gnugrep coreutils findutils
|
||||
|
||||
# From https://stackoverflow.com/a/2083563
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/bash
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p bash coreutils git gnused
|
||||
|
||||
# Replace git folders with a placeholder containing the remote and the commit
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# FIXME
|
||||
|
||||
if [ "$(cat /etc/hostname)" = "curacao.geoffrey.frogeye.fr" ]
|
||||
then
|
||||
echo 40000 | sudo tee /sys/class/backlight/intel_backlight/brightness
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3
|
||||
|
||||
import random
|
||||
import sys
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3
|
||||
|
||||
import random
|
||||
import sys
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p bash jq curl findutils coreutils
|
||||
|
||||
set -euo pipefail
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p bash
|
||||
|
||||
# Generates Lorem Ipsum
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3 python3Packages.coloredlogs ffmpeg
|
||||
|
||||
import logging
|
||||
import os
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3
|
||||
|
||||
"""
|
||||
Small script to convert music files in the form:
|
|
@ -1,5 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# FIXME
|
||||
|
||||
if [ "$(cat /etc/hostname)" = "curacao.geoffrey.frogeye.fr" ]
|
||||
then
|
||||
echo 1 | sudo tee /sys/class/backlight/intel_backlight/brightness
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3
|
||||
#! nix-shell -p python3 python3Packages.magic xdg-utils feh zathura
|
||||
# pylint: disable=C0103
|
||||
|
||||
"""
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p bash coreutils imagemagick libjpeg optipng ffmpeg diffutils
|
||||
|
||||
|
||||
# Optimizes everything the script can find in a folder,
|
||||
|
@ -11,6 +13,7 @@
|
|||
# TODO Lots of dupplicated code there
|
||||
# TODO Maybe replace part with https://github.com/toy/image_optim?
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
dir=${1:-$PWD}
|
||||
total=$(mktemp)
|
||||
echo -n 0 > $total
|
||||
|
@ -148,20 +151,18 @@ do
|
|||
|
||||
done <<< "$(find "$dir/" -type f -iname "*.png")"
|
||||
|
||||
# FLAC (requires reflac)
|
||||
# FLAC (requires ffmpeg)
|
||||
while read music
|
||||
do
|
||||
if [ -z "$music" ]; then continue; fi
|
||||
echo Processing $music
|
||||
|
||||
temp_dir=$(mktemp --directory)
|
||||
temp="$temp_dir/to_optimize.flac"
|
||||
temp=$(mktemp --suffix .flac)
|
||||
cp "$music" "$temp"
|
||||
reflac --best "$temp_dir"
|
||||
ffmpeg -8 -o "$temp"
|
||||
echo "→ Optimize done"
|
||||
|
||||
replace "$temp" "$music"
|
||||
rm -rf "$temp_dir"
|
||||
|
||||
done <<< "$(find "$dir/" -type f -iname "*.flac")"
|
||||
|
||||
|
@ -186,6 +187,6 @@ done <<< "$(find "$dir/" -type f -iname "*.flac")"
|
|||
# - I might want to keep editor data and/or ids for some of them
|
||||
# So rather use scour explicitely when needed
|
||||
|
||||
cleandev
|
||||
${SCRIPT_DIR}/cleandev
|
||||
|
||||
showtotal
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p bash pdftk inkscape gnused coreutils file
|
||||
|
||||
# Utility to write over a PDF file pages
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/bash
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p bash pdftk gnugrep gawk
|
||||
|
||||
# From https://stackoverflow.com/a/14736593
|
||||
for FILE in "$@"
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p bash pdftk coreutils
|
||||
|
||||
# Change the title of a PDF file
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3 python3Packages.coloredlogs python3Packages.exifread
|
||||
|
||||
import argparse
|
||||
import datetime
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3 python3Packages.pulsectl python3Packages.xlib
|
||||
|
||||
import sys
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3 python3Packages.coloredlogs
|
||||
|
||||
"""
|
||||
Same as picture_name_date
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p bash coreutils
|
||||
|
||||
# Moves a file to another place and put a symbolic link in place
|
||||
|
|
@ -1,4 +1,8 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3 python3Packages.coloredlogs python3Packages.r128gain
|
||||
|
||||
# TODO r128gain is not maintainted anymore
|
||||
|
||||
# Normalisation is done at the default of each program,
|
||||
# which is usually -89.0 dB
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3 python3Packages.coloredlogs python3Packages.progressbar2
|
||||
|
||||
# Handles sync-conflict files
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3
|
||||
#! nix-shell -p python3 python3Packages.coloredlogs python3Packages.configargparse python3Packages.filelock python3Packages.filelock python3Packages.requests python3Packages.yt-dlp ffmpeg
|
||||
# Also needs mpv but if I put it there it's not using the configured one
|
||||
|
||||
|
||||
"""
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3
|
||||
#! nix-shell -p python3 python3Packages.colorama python3Packages.configargparse
|
||||
|
||||
import base64
|
||||
import datetime
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3
|
||||
|
||||
import random
|
||||
import sys
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3
|
||||
|
||||
import os
|
||||
import shutil
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3 python3Packages.piexif
|
||||
|
||||
import os
|
||||
import sys
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3
|
||||
|
||||
import sys
|
||||
from math import inf
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3 python3Packages.coloredlogs python3Packages.magic unzip p7zip unrar gnutar gzip
|
||||
|
||||
import logging
|
||||
import os
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3 python3Packages.coloredlogs python3Packages.progresbar2 ffmpeg
|
||||
# pylint: disable=C0103
|
||||
|
||||
import logging
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3 ffmpeg
|
||||
|
||||
# Compress a video to make it fit under a certain size.
|
||||
# Usage: videoQuota SIZE SRC DST
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p bash curl ncurses
|
||||
|
||||
# change Paris to your default location
|
||||
request="v2.wttr.in/${1-Amsterdam}"
|
0
config/scripts/linuxColors → config/nix/unprocessed/config/linuxColors.sh
Executable file → Normal file
0
config/scripts/linuxColors → config/nix/unprocessed/config/linuxColors.sh
Executable file → Normal file
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p bash
|
||||
|
||||
# Removes CRLF (^M or \r) from a file
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ $USER != root ]
|
||||
then
|
||||
echo "This script should be run as root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! pacman -Qq pacman-mirrorlist &> /dev/null
|
||||
then
|
||||
pacman -S pacman-mirrorlist
|
||||
fi
|
||||
|
||||
if [ ! -f /etc/pacman.d/mirrorlist.pacnew ]
|
||||
then
|
||||
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.pacnew
|
||||
fi
|
||||
|
||||
egrep -o 'Server = .+' /etc/pacman.d/mirrorlist.pacnew | /usr/bin/rankmirrors -n 6 - > /etc/pacman.d/mirrorlist
|
|
@ -1,10 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
cd ~/.dotfiles/config/automatrop
|
||||
if [ -f ~/.config/automatrop/self_name ]
|
||||
then
|
||||
hostname=$(cat ~/.config/automatrop/self_name)
|
||||
else
|
||||
hostname="$HOSTNAME"
|
||||
fi
|
||||
ansible-playbook --diff playbooks/default.yml --limit $hostname --connection local "$@"
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env sh
|
||||
play -n synth sine E5 sine A4 remix 1-2 fade 0.5 1.2 0.5 2> /dev/null
|
||||
# echo
|
|
@ -1,190 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Handles dotfiles
|
||||
# Yes there are tons of similar scipts yet I wanted no more nor less than what I needed
|
||||
|
||||
# Config
|
||||
|
||||
if [ -z "$DOTHOME" ]; then
|
||||
DOTHOME="$HOME"
|
||||
fi
|
||||
if [ -z "$DOTREPO" ]; then
|
||||
DOTREPO="$HOME/.dotfiles"
|
||||
fi
|
||||
|
||||
# Common functions
|
||||
|
||||
# From http://stackoverflow.com/a/12498485
|
||||
function relativePath {
|
||||
# both $1 and $2 are absolute paths beginning with /
|
||||
# returns relative path to $2/$target from $1/$source
|
||||
source=$1
|
||||
target=$2
|
||||
|
||||
common_part=$source # for now
|
||||
result="" # for now
|
||||
|
||||
while [[ "${target#$common_part}" == "${target}" ]]; do
|
||||
# no match, means that candidate common part is not correct
|
||||
# go up one level (reduce common part)
|
||||
common_part="$(dirname $common_part)"
|
||||
# and record that we went back, with correct / handling
|
||||
if [[ -z $result ]]; then
|
||||
result=".."
|
||||
else
|
||||
result="../$result"
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $common_part == "/" ]]; then
|
||||
# special case for root (no common path)
|
||||
result="$result/"
|
||||
fi
|
||||
|
||||
# since we now have identified the common part,
|
||||
# compute the non-common part
|
||||
forward_part="${target#$common_part}"
|
||||
|
||||
|
||||
# and now stick all parts together
|
||||
if [[ -n $result ]] && [[ -n $forward_part ]]; then
|
||||
result="$result$forward_part"
|
||||
elif [[ -n $forward_part ]]; then
|
||||
# extra slash removal
|
||||
# result="${forward_part:1}" # Removes the . in the beginning...
|
||||
result="${forward_part#/}"
|
||||
fi
|
||||
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
|
||||
# Script common functions
|
||||
|
||||
function _dotfiles-install-dir { # dir
|
||||
local dir
|
||||
local absSource
|
||||
local absTarget
|
||||
local relTarget
|
||||
|
||||
dir="${1%/}"
|
||||
dir="${dir#/}"
|
||||
|
||||
ls -A "$DOTREPO/$dir" | while read file; do
|
||||
if [[ -z "$dir" && $(echo $file | grep '^\(\.\|LICENSE\|README\)') ]]; then
|
||||
continue
|
||||
fi
|
||||
if [[ $(echo $file | grep '^.dfrecur$') ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ -z "$dir" ]; then
|
||||
absSource="$DOTHOME/.$file"
|
||||
absTarget="$DOTREPO/$file"
|
||||
else
|
||||
absSource="$DOTHOME/.$dir/$file"
|
||||
absTarget="$DOTREPO/$dir/$file"
|
||||
fi
|
||||
relTarget="$(relativePath "$DOTHOME/$dir" "$absTarget")"
|
||||
recurIndicator="$absTarget/.dfrecur"
|
||||
|
||||
if [[ -h "$absTarget" ]]; then
|
||||
if [ -e "$absSource" ]; then
|
||||
if [ -h "$absSource" ]; then
|
||||
cmd="cp --no-dereference --force $absTarget $absSource"
|
||||
if [ $DRY_RUN ]; then
|
||||
echo $cmd
|
||||
else
|
||||
yes | $cmd
|
||||
fi
|
||||
else
|
||||
echo "[ERROR] $absSource already exists, but is not a link"
|
||||
fi
|
||||
else
|
||||
cmd="cp --no-dereference --force $absTarget $absSource"
|
||||
if [ $DRY_RUN ]; then
|
||||
echo $cmd
|
||||
else
|
||||
yes | $cmd
|
||||
fi
|
||||
fi
|
||||
elif [[ -f "$absTarget" || ( -d $absTarget && ! -f $recurIndicator ) ]]; then
|
||||
if [ -e "$absSource" ]; then
|
||||
if [ -h "$absSource" ]; then
|
||||
cmd="ln --symbolic --no-dereference --force $relTarget $absSource"
|
||||
if [ $DRY_RUN ]; then
|
||||
echo $cmd
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
else
|
||||
echo "[ERROR] $absSource already exists, but is not a symbolic link"
|
||||
fi
|
||||
else
|
||||
cmd="ln --symbolic --no-dereference $relTarget $absSource"
|
||||
if [ $DRY_RUN ]; then
|
||||
echo $cmd
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
fi
|
||||
elif [[ -d "$absTarget" && -f $recurIndicator ]]; then
|
||||
if [ -e "$absSource" ]; then
|
||||
if [ -d "$absSource" ]; then
|
||||
# echo "Directory $absSource already exists"
|
||||
_dotfiles-install-dir $dir/$file
|
||||
else
|
||||
echo "[ERROR] $absSource already exists, but is not a directory"
|
||||
fi
|
||||
else
|
||||
cmd="mkdir $absSource"
|
||||
if [ $DRY_RUN ]; then
|
||||
echo $cmd
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
_dotfiles-install-dir $dir/$file
|
||||
fi
|
||||
else
|
||||
echo "[WARNING] Skipped $absTarget"
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
# Script functions
|
||||
|
||||
function dotfiles_install {
|
||||
_dotfiles-install-dir /
|
||||
}
|
||||
|
||||
function dotfiles_help {
|
||||
command="$1"
|
||||
if [ -n "$command" ]; then
|
||||
if type "dotfiles_${command}_help" &> /dev/null; then
|
||||
shift
|
||||
"dotfiles_${command}_help" "$@"
|
||||
return $?
|
||||
fi
|
||||
fi
|
||||
echo "Usage: $0 COMMAND"
|
||||
echo
|
||||
echo "Commands:"
|
||||
echo " install Install dotfiles from repository"
|
||||
echo " help Get help with commands"
|
||||
echo
|
||||
echo "Environment variables:"
|
||||
echo " DOTHOME Where to install dotfiles"
|
||||
echo " DOTREPO Where do the dotfiles comes from"
|
||||
return 0
|
||||
}
|
||||
|
||||
# MAIN
|
||||
command="$1"
|
||||
shift
|
||||
if type "dotfiles_$command" &> /dev/null; then
|
||||
"dotfiles_$command" "$@"
|
||||
else
|
||||
dotfiles_help
|
||||
fi
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Clears everything it can to save space
|
||||
|
||||
rm -rf $HOME/.cache
|
||||
if which pacman &> /dev/null; then
|
||||
sudo pacman -Scc
|
||||
elif which apt-get &> /deb/null; then
|
||||
sudo apt-get clean
|
||||
fi
|
||||
if which journalctl &> /dev/null; then
|
||||
sudo journalctl --vacuum-size=100M
|
||||
fi
|
|
@ -1,10 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Return a list of packages sorted by size
|
||||
|
||||
(echo PACKAGE SIZE; \
|
||||
for A in /var/lib/pacman/local/*/desc; do
|
||||
(sed -n 2p $A; (grep '^%SIZE%$' $A -A1 | tail -1)) | tr '\n' ' '; echo
|
||||
done \
|
||||
| sort -nrk2) \
|
||||
| column -t
|
|
@ -1,2 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
find -type f -printf '%T+ %p\n' | sort | tail "$@"
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
play -c 2 -n synth ${1}noise
|
|
@ -1,2 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
find -type f -printf '%T+ %p\n' | sort | head "$@"
|
|
@ -1,62 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import urllib.request
|
||||
from pprint import pprint
|
||||
|
||||
import coloredlogs
|
||||
import ovh
|
||||
import xdg.BaseDirectory
|
||||
|
||||
coloredlogs.install(level="DEBUG", fmt="%(levelname)s %(message)s")
|
||||
log = logging.getLogger()
|
||||
|
||||
debug = None
|
||||
|
||||
|
||||
class OvhCli:
|
||||
ROOT = "https://api.ovh.com/1.0?null"
|
||||
|
||||
def __init__(self):
|
||||
self.cacheDir = os.path.join(xdg.BaseDirectory.xdg_cache_home, "ovhcli")
|
||||
# TODO Corner cases: links, cache dir not done, configurable cache
|
||||
if not os.path.isdir(self.cacheDir):
|
||||
assert not os.path.exists(self.cacheDir)
|
||||
os.makedirs(self.cacheDir)
|
||||
|
||||
def updateCache(self):
|
||||
log.info("Downloading the API description")
|
||||
rootJsonPath = os.path.join(self.cacheDir, "root.json")
|
||||
log.debug(f"{self.ROOT} -> {rootJsonPath}")
|
||||
urllib.request.urlretrieve(self.ROOT, rootJsonPath)
|
||||
with open(rootJsonPath, "rt") as rootJson:
|
||||
root = json.load(rootJson)
|
||||
basePath = root["basePath"]
|
||||
|
||||
for apiRoot in root["apis"]:
|
||||
fmt = "json"
|
||||
assert fmt in apiRoot["format"]
|
||||
path = apiRoot["path"]
|
||||
schema = apiRoot["schema"].format(format=fmt, path=path)
|
||||
apiJsonPath = os.path.join(self.cacheDir, schema[1:])
|
||||
apiJsonUrl = basePath + schema
|
||||
log.debug(f"{apiJsonUrl} -> {apiJsonPath}")
|
||||
apiJsonPathDir = os.path.dirname(apiJsonPath)
|
||||
if not os.path.isdir(apiJsonPathDir):
|
||||
os.makedirs(apiJsonPathDir)
|
||||
urllib.request.urlretrieve(apiJsonUrl, apiJsonPath)
|
||||
|
||||
def createParser(self):
|
||||
parser = argparse.ArgumentParser(description="Access the OVH API")
|
||||
return parser
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli = OvhCli()
|
||||
# cli.updateCache()
|
||||
parser = cli.createParser()
|
||||
args = parser.parse_args()
|
||||
print(args)
|
|
@ -1,9 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Generate strong enough password(s)
|
||||
|
||||
# This generates a password with ln((26*2+10)**32)/ln(2) ≅ 190 bits of entropy,
|
||||
# which is a bit above the recommended standars (128 bits) while still having
|
||||
# a 0 probability that the service will break because of incompatible character
|
||||
|
||||
pwgen 32 -y
|
|
@ -1,7 +0,0 @@
|
|||
coloredlogs>=10.0<11
|
||||
progressbar2>=3.47.0<4
|
||||
yt-dlp>=2021.10.22
|
||||
ConfigArgParse>=1.5<2
|
||||
asyncinotify
|
||||
ffmpeg
|
||||
r128gain
|
|
@ -1,2 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
find . -name "*.sync-conflict-*" -delete
|
|
@ -1,47 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Rename a list of files with a sed pattern
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 PATTERN [-d] < filelist"
|
||||
echo
|
||||
echo "Arguments:"
|
||||
echo " PATTERN Sed pattern to apply"
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " -d Dry run"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
pattern="$1"
|
||||
|
||||
dry=1
|
||||
if [[ -n "$2" ]]; then
|
||||
if [[ "$2" = '-d' ]]; then
|
||||
dry=0
|
||||
else
|
||||
usage
|
||||
fi
|
||||
fi
|
||||
|
||||
while read src
|
||||
do
|
||||
dst="$(echo "$src" | sed "$pattern")"
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "ERREUR Invalid sed pattern"
|
||||
exit 2
|
||||
fi
|
||||
if [[ $dry == 0 ]]; then
|
||||
echo "$src" → "$dst"
|
||||
else
|
||||
mv -- "$src" "$dst"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
#!/usr/bin/env sh
|
||||
strace -f -t -e trace=file $@
|
|
@ -1,20 +0,0 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"
|
||||
return 1
|
||||
fi
|
||||
|
||||
tmpfile=$( mktemp -t transferXXX )
|
||||
|
||||
if tty -s
|
||||
then
|
||||
basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g')
|
||||
curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile
|
||||
else
|
||||
curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile
|
||||
fi
|
||||
|
||||
cat $tmpfile
|
||||
rm -f $tmpfile
|
|
@ -1,18 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# Compresses video using FFMPEG using
|
||||
# FFMPEG's reasonable default settings
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
files = sys.argv[1:]
|
||||
|
||||
remove = False
|
||||
if "-r" in files:
|
||||
files.remove("-r")
|
||||
remove = True
|
||||
|
||||
for f in files:
|
||||
print(os.path.splitext(f))
|
Loading…
Reference in a new issue