feat: simple install script until archmgr completed

This commit is contained in:
2026-06-18 11:23:48 +02:00
parent b167d40039
commit a776d1760a
15 changed files with 430 additions and 40 deletions
+7 -11
View File
@@ -7,7 +7,6 @@ alias cv='clear && nvim'
alias zs='zathura-sandbox' alias zs='zathura-sandbox'
alias z='zathura' alias z='zathura'
alias bt='bashtop' alias bt='bashtop'
alias vicfg='nvim ~/projects/nvim/'
alias fm='thunar .' alias fm='thunar .'
alias gl='git ls-files --others --exclude-standard' alias gl='git ls-files --others --exclude-standard'
alias gm='git ls-files -m' alias gm='git ls-files -m'
@@ -16,23 +15,20 @@ alias gp='git pull'
alias gpr='git pull --rebase' alias gpr='git pull --rebase'
alias gc='git commit -a -m' alias gc='git commit -a -m'
alias ga='git add ./*' alias ga='git add ./*'
alias cfh='nvim ~/projects/dotfiles/config/hypr/' alias cfh='nvim ~/projects/system/dotfiles/config/hypr/'
alias cfn='nvim ~/projects/nvim/' alias cfn='nvim ~/projects/system/nvim/'
alias cff='nvim ~/projects/dotfiles/config/fish/' alias cff='nvim ~/projects/system/dotfiles/config/fish/'
alias cfa='nvim ~/projects/dotfiles/config/astal/' alias cfa='nvim ~/projects/system/dotfiles/config/astal/'
alias cf='nvim ~/projects/dotfiles/' alias cf='nvim ~/projects/system/dotfiles/'
alias g='lazygit' alias g='lazygit'
alias open-webui='sudo systemctl start docker && sudo docker start -i open-webui'
alias ai='ollama serve'
alias ff='fastfetch' alias ff='fastfetch'
alias p='nvimpager -p' alias p='nvimpager -p'
alias latexdocs='zathura ~/projects/latex/docs/docs.pdf &>> /dev/null & disown' alias latexdocs='zathura ~/projects/latex/docs/docs.pdf &>> /dev/null & disown'
alias gccerr='gcc -Wall -Wextra -Wpedantic -Werror -Wmissing-prototypes -std=c99' alias gccerr='gcc -Wall -Wextra -Wpedantic -Werror -Wmissing-prototypes -std=c99'
alias linecount='cloc --vcs git .' alias linecount='cloc --vcs git .'
alias flutter='fvm flutter'
# Add scripts in ~/projects/dotfiles/scripts/ to path # Add custom scripts to path
fish_add_path -P ~/projects/dotfiles/scripts/ fish_add_path -P ~/projects/system/dotfiles/scripts/
function y function y
set tmp (mktemp -t "yazi-cwd.XXXXXX") set tmp (mktemp -t "yazi-cwd.XXXXXX")
+2 -2
View File
@@ -1,8 +1,8 @@
-- Determine current platform -- Determine current platform
local is_docked = false local is_docked = false
local laptop_config = false local laptop_config = false
local read_platform = io.popen("cat ~/.config/janishutz/platform-laptop") == "l" local read_platform = io.popen("cat ~/.config/janishutz/platform") == "l"
local read_docked = io.popen("cat ~/.config/janishutz/docked") == "y" local read_docked = io.popen("cat ~/.config/janishutz/docked") == "true"
if read_platform then if read_platform then
laptop_config = true laptop_config = true
-27
View File
@@ -1,27 +0,0 @@
#!/bin/sh
echo "
_ _ ( ) ( )_
(_) _ _ ___ (_) ___| |__ _ _| _)____
| |/ _ ) _ \ | __) _ \ ) ( ) | (_ )
| | (_| | ( ) | |__ \ | | | (_) | |_ / /_
_ | |\__ _)_) (_)_)____/_) (_)\___/ \__)____)
( )_| |
\___/
=> Migration to V4
-> WARNING: This will remove the old configurations from the system
"
confirmation=""
read -p "Do you really want to remove the old configuration files and update to the new configs? (y/N) " confirmation
if [[ "$confirmation" == "y" ]]; then
rm -rf ~/.config/hypr
rm ~/.config/platform
rm -rf ~/.config/rofi
rm -rf ~/.config/ags
rm -rf ~/.config/astal
else
echo "Aborting."
fi
+5
View File
@@ -0,0 +1,5 @@
#!/bin/sh
SCRIPT_DIR=$(dirname "$0")
node "$SCRIPT_DIR/util/auto-renamer/index.js" $@
+14
View File
@@ -0,0 +1,14 @@
#!/bin/sh
extension="out"
read -p "Pick extension to convert from: " extension
outfolder="out"
outext="mp4"
read -p "Output folder: " outfolder
read -p "Output extension: " outext
mkdir $outfolder
for file in *.$extension; do
ffmpeg -i "$file" "$outfolder/${file%.$extension}.$outext"
echo "\n\n==> Conversion complete\n\n"
done
+75
View File
@@ -0,0 +1,75 @@
#!/usr/bin/env bash
connect() {
read -sp $'Please enter your Encryption Password: ' encpass
echo "
==> Connecting"
TOKEN=$(cat ~/.local/share/ethz-vpn-connect/ethzvpntoken.secret | openssl enc -aes-256-cbc -pbkdf2 -d -a -k $encpass)
PASSWORD=$(cat ~/.local/share/ethz-vpn-connect/ethzvpnpass.secret | openssl enc -aes-256-cbc -pbkdf2 -d -a -k $encpass)
USERNAME=$(cat ~/.local/share/ethz-vpn-connect/ethzvpnusername.txt)
echo $PASSWORD | sudo openconnect -b -u $USERNAME@student-net.ethz.ch -g student-net --useragent=AnyConnect --no-external-auth --passwd-on-stdin --token-mode=totp --token-secret=sha1:base32:$TOKEN sslvpn.ethz.ch
if [ $? -ne 0 ]; then
echo ' ==> Failed to connect <=='
else
echo ' ==> Connected <==
'
fi
encpass=""
PASSWORD=""
TOKEN=""
}
disconnect() {
sudo killall -v -SIGINT openconnect
echo " ==> Disconnected"
}
setup() {
echo 'You are about to overwrite your secrets. Press ctrl + C to cancel.'
read -p 'Please enter your ETHZ-Username: ' USERNAME
read -sp 'Please choose and enter your Encryption Password (will be required when launching): ' encpass
echo ""
read -sp 'Please enter your ETHZ WLAN (= Radius) Password: ' PASSWORD
echo ""
read -sp 'Please enter your ETHZ OTP Secret: ' TOKEN
echo ""
if [[ -d ~/.local/share/ethz-vpn-connect ]]; then
rm -rf ~/.local/share/ethz-vpn-connect
fi
mkdir ~/.local/share/ethz-vpn-connect
echo $PASSWORD | openssl enc -aes-256-cbc -pbkdf2 -a -k $encpass >~/.local/share/ethz-vpn-connect/ethzvpnpass.secret
echo $TOKEN | openssl enc -aes-256-cbc -pbkdf2 -a -k $encpass >~/.local/share/ethz-vpn-connect/ethzvpntoken.secret
echo $USERNAME >~/.local/share/ethz-vpn-connect/ethzvpnusername.txt
encpass=""
PASSWORD=""
TOKEN=""
if [ $? -ne 0 ]; then
echo ' ==> Failed to set secrets <=='
else
echo ' ==> Secrets set <==\n'
fi
}
case "$1" in
'connect')
connect
;;
c)
connect
;;
'disconnect')
disconnect
;;
d)
disconnect
;;
dc)
disconnect
;;
setup)
setup
;;
*)
echo -e 'Usage: ethz-vpn [Option] \n [Option]: \n connect, c: Connect VPN \n disconnect, d, dc: Disconnect VPN \n setup: set secrets and eth-Username.\n'
;;
esac
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "Word count is $(pdftotext $1 - | tr -d '.' | wc -w)"
+6
View File
@@ -0,0 +1,6 @@
#!/bin/sh
SCRIPT_DIR=$(dirname "$0")
cp "$SCRIPT_DIR/../linters/clang-format" ./.clang-format
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
SCRIPT_DIR=$(dirname "$0")
cp "$SCRIPT_DIR/../linters/eslint.config.mjs" .
npm i --save-dev @eslint/js typescript-eslint @stylistic/eslint-plugin eslint-plugin-vue globals
+6
View File
@@ -0,0 +1,6 @@
#!/bin/sh
SCRIPT_DIR=$(dirname "$0")
cp "$SCRIPT_DIR/../linters/indentconfig.yaml" ./.latexindent.yaml
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
is_docked=$(cat ~/.config/janishutz/docked)
if [ $is_docked == "y" ]; then
echo "n" >~/.config/janishutz/docked
else
echo "y" >~/.config/janishutz/docked
fi
hyprctl reload
echo "Switched to docked mode"
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
enabled=$(hyprctl getoption input:kb_options | grep "caps:swapescape")
if [[ $enabled == "" ]]; then
hyprctl keyword input:kb_options "caps:swapescape"
notify-send "Swapescape enabled"
else
hyprctl keyword input:kb_options ""
notify-send "Swapescape disabled"
fi
+5
View File
@@ -0,0 +1,5 @@
#!/bin/sh
cd ~/projects/nvim/
git pull
./nvim-install.sh
+238
View File
@@ -0,0 +1,238 @@
const fs = require('fs');
const path = require('path');
const { argv } = require('process');
const config = {
// replace character of key with value, any character, apart from ['.', '_', '-', ' ']
'replace': {
'ä': 'ae',
'ö': 'oe',
'ü': 'ue',
',': '-',
'&': 'And',
},
'rules': {
'underscore-before-and-after-number': true, // Will not do trailing or leading for filename
'enforce-leading-zero': true, // adds a leading zero to any number below 10
'camel-case-rules': {
'enforce-snake-case-for-filetypes': ['py'], // using underscores
'enforce-kebab-case-for-filetypes': ['css', 'html', 'scss', 'tex'], // using hyphens
},
'file-start-letter': 'lower', // lower, upper, unchanged
'directory-start-letter': 'upper', // lower, upper, unchanged
'replace-dots-with': '', // will not replace as leading character to not break dotfiles
}
}
/**
* Recursively find all files with extension in a directory
* @param {string} dir The directory to search. Either absolute or relative path
* @param {string} extension The file extension to look for
* @param {boolean} cleanup If helper files (like .DS_STORE and Windows helpers should be auto-deleted)
* @param {string[]} ignoreList A list of filenames or directories to ignore
* @returns {{ files: string, directories: string }} returns a list of html files with their full path
*/
const treeWalker = (dir, extension, cleanup, ignoreList) => {
const ls = fs.readdirSync(dir);
const fileList = [];
const dirList = [];
for (let file in ls) {
if (fs.statSync(path.join(dir, ls[file])).isDirectory()) {
// Filter ignored directories
if (ignoreList === undefined || !ignoreList.includes(ls[file])) {
const newData = treeWalker(path.join(dir, ls[file]), extension, ignoreList);
const newFiles = newData.files;
dirList.push( path.join( dir, ls[ file ] ) );
for (let dir = 0; dir < newData.directories.length; dir++) {
dirList.push( newData.directories[dir] );
}
for (let file = 0; file < newFiles.length; file++) {
fileList.push(newFiles[file]);
}
}
} else if (extension == '*' || ls[file].includes(extension)) {
if (ignoreList === undefined || !ignoreList.includes(ls[file])) {
fileList.push(path.join(dir, ls[file]));
}
}
}
return { 'files': fileList, 'directories': dirList };
}
/**
* @param {string} filename The filename to fix according to the rules
* @returns {string} the fixed filename
*/
const fixName = ( fn, ft ) => {
let out = '';
const enforceSnake = config.rules['camel-case-rules']['enforce-snake-case-for-filetypes'].includes( ft );
const enforceKebab = config.rules['camel-case-rules']['enforce-kebab-case-for-filetypes'].includes( ft );
const isDir = ft === 'directory';
const startLetter = isDir ? config.rules['directory-start-letter'] : config.rules['file-start-letter'];
let nextUpperCase = false;
for ( let i = 0; i < fn.length; i++ ) {
const c = fn[i];
if ( c == '.' ) {
// Rule: Removed after number, allowed elsewhere
if ( i > 0 && /[0-9]/.test( fn[ i - 1 ] ) ) {
out += config.rules[ 'replace-dots-with' ];
} else {
out += '.';
}
} else if ( /[A-Z]/.test( c ) ) {
// If we reach a capital letter and enforce either kebab-case or snake_case, we can assume that this is the start of a CamelCase word
if ( enforceKebab ) {
out += '-' + c.toLowerCase();
} else if ( enforceSnake ) {
out += '_' + c.toLowerCase();
} else {
nextUpperCase = false;
if ( i == 0 && startLetter === 'lower' ) {
out += c.toLowerCase();
} else {
out += c;
}
}
} else if ( c == ' ' ) {
// We always replace spaces, the question is just to what
if ( enforceKebab ) {
out += '-';
} else if ( enforceSnake ) {
out += '_';
} else {
nextUpperCase = true;
}
} else if ( c == '_' ) {
// If we are not enforcing snake_case, then replace it
if ( !enforceSnake ) {
if ( needsUnderscore( i, fn ) ) {
out += '_';
} else if ( enforceKebab ) {
out += '-';
} else {
nextUpperCase = true;
}
} else {
out += '_'
}
} else if ( c == '-' ) {
// If we are not enforcing kebab-case
if ( !enforceKebab ) {
if ( enforceSnake ) {
out += '_';
} else {
nextUpperCase = true;
}
} else {
out += '-'
}
} else {
let curr = config.replace[ c ] === undefined ? c : config.replace[ c ];
if ( config.rules[ 'underscore-before-and-after-number' ] || config.rules['enforce-leading-zero'] ) {
if ( /[0-9]/.test( c ) ) {
if ( i < fn.length - 1 ) {
if ( config.rules['enforce-leading-zero'] ) {
const prevIsNumber = i > 0 && /[0-9]/.test( fn[i - 1] );
const nextIsNumber = /[0-9]/.test( fn[i + 1] );
if ( !nextIsNumber && ( i == 0|| !prevIsNumber ) ) {
curr = '0' + curr;
}
}
if ( config.rules['underscore-before-and-after-number'] ) {
if ( !( /[0-9]/.test( fn[ i + 1 ] ) ) && fn[ i + 1 ] != '_' ) {
curr += '_';
}
}
} else {
if ( config.rules['enforce-leading-zero'] && ( i > 0 && !( /[0-9]/.test( fn[i - 1] ) ) ) ) {
curr = '0' + curr;
}
}
} else {
if ( config.rules['underscore-before-and-after-number'] && /[0-9]/.test( fn[ i + 1 ] ) ) {
curr += '_';
}
}
}
if ( nextUpperCase || ( i == 0 && startLetter === 'upper' ) ) {
nextUpperCase = false;
out += curr.toUpperCase();
} else {
if ( i == 0 && startLetter === 'upper' ) {
out += curr.toUpperCase();
} else {
out += curr.toLowerCase();
}
}
}
}
return out;
}
const needsUnderscore = ( i, fn ) => {
return ( i > 0 && /[0-9]/.test( fn[ i - 1 ] ) ) || ( i < fn - 1 && /[0-9]/.test( fn[ i + 1 ] ) )
}
const separateDirAndFileAndFiletype = ( filename ) => {
const loc = filename.lastIndexOf( '/' ) + 1;
let ftl = filename.lastIndexOf( '.' ) + 1;
let fn = filename.substring( loc, ftl - 1 );
let ft = filename.substring( ftl );
if ( fs.statSync( filename ).isDirectory() ) {
ftl = filename.length;
fn = filename.substring( loc );
ft = 'directory';
}
const dir = filename.slice( 0, loc - 1 );
return { 'filename': fn, 'dir': dir, 'filetype': ft };
}
const fixDirName = ( directory, top ) => {
if ( directory === top ) {
return top;
}
const f = separateDirAndFileAndFiletype( directory );
return fixDirName( f.dir, top ) + '/' + fixName( f.filename, f.filetype );
}
if (argv[2] == '-h') {
console.log('auto-renamer [directory]\n\n=> Recursively rename files in directory');
} else if (argv[2] == '-v') {
console.log('auto-renamer version 1.0.0, developed by Janis Hutz (development@janishutz.com)');
} else {
// Recursively add all files in the directory
const fp = path.resolve( argv[2] );
const list = treeWalker(fp, '*', ['.git', '@girs']);
const files = list.files;
const directories = list.directories;
for (let i = 0; i < files.length; i++) {
const file = files[i];
const f = separateDirAndFileAndFiletype( file );
let fixedFile = fixName( f.filename, f.filetype );
// Rename
const fixedPath = f.dir + '/' + fixedFile + '.' + f.filetype;
console.log( file + ' -> ' + fixedPath );
fs.renameSync( file, fixedPath );
}
// Fix directory names after file names. Sort array by decending length
directories.sort( ( a, b ) => {
return b.length - a.length;
} );
// separate directories up until we reach the path of dir started in
for (let i = 0; i < directories.length; i++) {
const dir = directories[i];
const fixed = fixDirName( dir, fp );
console.log( dir + ' -> ' + fixed );
fs.renameSync( dir, fixDirName( dir, fp ) );
}
}
Executable
+39
View File
@@ -0,0 +1,39 @@
#!/bin/sh
echo "
_ _ ( ) ( )_
(_) _ _ ___ (_) ___| |__ _ _| _)____
| |/ _ ) _ \ | __) _ \ ) ( ) | (_ )
| | (_| | ( ) | |__ \ | | | (_) | |_ / /_
_ | |\__ _)_) (_)_)____/_) (_)\___/ \__)____)
( )_| |
\___/
=> Migration to V4
-> WARNING: This will remove the old configurations from the system
"
if ! [[ -f ~/.config/janishutz/platform ]]; then
platform=""
read -p "Choose on the platform (l/D): " platform
mkdir ~/.config/janishutz
if [ $platform != "l" ]; then
platform="d"
fi
echo "$platform" >~/.config/janishutz/platform
echo "n" >~/.config/janishutz/docked
fi
confirmation=""
read -p "Also install the system-wide environment file? (y/N) " confirmation
if [[ "$confirmation" == "y" ]]; then
sudo cp ./system/environment /etc/environment
fi
rm -rf ~/.config/hypr
rm ~/.config/platform
rm -rf ~/.config/rofi
rm -rf ~/.config/ags
rm -rf ~/.config/astal
cp ./config/* ~/.config