mirror of
https://github.com/kmein/niveum
synced 2026-03-19 19:41:08 +01:00
Compare commits
11 Commits
ad2c922ab4
...
32fa3e75ea
| Author | SHA1 | Date | |
|---|---|---|---|
| 32fa3e75ea | |||
| 435aa4a365 | |||
| 8d955bf640 | |||
| a44d15a166 | |||
| b33e1d3569 | |||
| cba0f92a7a | |||
| 1f163d65cd | |||
| e816145b13 | |||
| 4cb62b382b | |||
| 0c6ec93443 | |||
| 15ef01268b |
114
.bin/mp3player-write
Executable file
114
.bin/mp3player-write
Executable file
@@ -0,0 +1,114 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Usage:
|
||||
# ./mp3_transfer.sh -s 1.3 /mnt/mp3player file1.m4a file2.m4a ...
|
||||
|
||||
set -e
|
||||
|
||||
# Default speed
|
||||
SPEED=1.0
|
||||
|
||||
# Parse options
|
||||
while getopts ":s:" opt; do
|
||||
case $opt in
|
||||
s)
|
||||
SPEED=$OPTARG
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
exit 1
|
||||
;;
|
||||
:)
|
||||
echo "Option -$OPTARG requires a value." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Shift past the options
|
||||
shift $((OPTIND -1))
|
||||
|
||||
# Check arguments
|
||||
if [ "$#" -lt 2 ]; then
|
||||
echo "Usage: $0 [-s speed] MOUNT_POINT FILE1 [FILE2 ...]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MOUNT_POINT=$1
|
||||
shift
|
||||
FILES=("$@")
|
||||
|
||||
# Check mount point exists
|
||||
if [ ! -d "$MOUNT_POINT" ]; then
|
||||
echo "Error: Mount point '$MOUNT_POINT' does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Estimate required space
|
||||
TOTAL_SIZE=0
|
||||
for f in "${FILES[@]}"; do
|
||||
if [ ! -f "$f" ]; then
|
||||
echo "Warning: File '$f' does not exist, skipping."
|
||||
continue
|
||||
fi
|
||||
# Get file size in bytes
|
||||
FILE_SIZE=$(stat --printf="%s" "$f")
|
||||
# Estimate mp3 output size: roughly 1/2 of original m4a (adjust if needed)
|
||||
TOTAL_SIZE=$((TOTAL_SIZE + FILE_SIZE / 2))
|
||||
done
|
||||
|
||||
# Get available space in bytes
|
||||
AVAILABLE=$(df --output=avail "$MOUNT_POINT" | tail -n 1)
|
||||
AVAILABLE=$((AVAILABLE * 1024)) # df reports in KB
|
||||
|
||||
if [ "$TOTAL_SIZE" -gt "$AVAILABLE" ]; then
|
||||
echo "Error: Not enough space on device. Required: $TOTAL_SIZE bytes, Available: $AVAILABLE bytes"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Enough space available. Starting conversion..."
|
||||
|
||||
sanitize_filename() {
|
||||
local name="$1"
|
||||
# Remove path, keep only base name
|
||||
name=$(basename "$name" .m4a)
|
||||
# Replace spaces and special chars with underscore
|
||||
name=$(echo "$name" | tr ' ' '_' | tr -cd '[:alnum:]_-')
|
||||
# Truncate to max 50 chars
|
||||
echo "${name:0:50}"
|
||||
}
|
||||
|
||||
# Convert and copy files
|
||||
for f in "${FILES[@]}"; do
|
||||
if [ ! -f "$f" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Determine the next prefix
|
||||
existing_prefixes=$(ls "$MOUNT_POINT" | grep -E '^[0-9].*\.mp3$' | sed -E 's/^([0-9]).*/\1/' | sort -n | uniq)
|
||||
for i in {0..9}; do
|
||||
if ! echo "$existing_prefixes" | grep -q "^$i$"; then
|
||||
PREFIX=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Using prefix: $PREFIX"
|
||||
|
||||
BASENAME=$(sanitize_filename "$f")
|
||||
OUT_PATTERN="$MOUNT_POINT/${PREFIX}%02d_${BASENAME}.mp3"
|
||||
|
||||
echo "Converting '$f' to '$OUT_PATTERN' at speed $SPEED..."
|
||||
|
||||
ffmpeg -i "$f" \
|
||||
-filter:a "atempo=$SPEED" -ar 44100 -ac 2 -c:a libmp3lame -b:a 128k \
|
||||
-f segment -segment_time 300 \
|
||||
"$OUT_PATTERN"
|
||||
|
||||
# Update prefix for next file
|
||||
# Count how many segments were created
|
||||
SEG_COUNT=$(ls "$MOUNT_POINT" | grep -E "^${PREFIX}[0-9]{2}_" | wc -l)
|
||||
PREFIX=$((PREFIX + SEG_COUNT))
|
||||
done
|
||||
|
||||
echo "All files processed successfully."
|
||||
@@ -4,6 +4,12 @@
|
||||
pkgs.zeroad
|
||||
pkgs.mari0
|
||||
pkgs.luanti # fka minetest
|
||||
# pkgs.openarena
|
||||
# pkgs.teeworlds
|
||||
pkgs.nethack
|
||||
# pkgs.freeciv
|
||||
# pkgs.lincity-ng
|
||||
# pkgs.superTuxKart
|
||||
];
|
||||
networking.firewall = {
|
||||
# for 0ad multiplayer
|
||||
|
||||
@@ -1 +1 @@
|
||||
{services.redshift.enable = false;}
|
||||
{ services.redshift.enable = true; }
|
||||
|
||||
@@ -6,15 +6,6 @@
|
||||
promptColours.success = "cyan";
|
||||
promptColours.failure = "red";
|
||||
in {
|
||||
environment.systemPackages = [pkgs.atuin];
|
||||
environment.variables.ATUIN_CONFIG_DIR = toString (pkgs.writeTextDir "/config.toml" ''
|
||||
auto_sync = true
|
||||
update_check = false
|
||||
sync_address = "http://zaatar.r:8888"
|
||||
sync_frequency = 0
|
||||
style = "compact"
|
||||
'');
|
||||
|
||||
programs.zsh = let
|
||||
zsh-completions = pkgs.fetchFromGitHub {
|
||||
owner = "zsh-users";
|
||||
@@ -67,13 +58,6 @@ in {
|
||||
zstyle ':vcs_info:*' formats "%c%u%F{cyan}%b%f"
|
||||
zstyle ':vcs_info:*' actionformats "(%a) %c%u%F{cyan}%b%f"
|
||||
|
||||
# atuin distributed shell history
|
||||
export ATUIN_NOBIND="true" # disable all keybdinings of atuin
|
||||
eval "$(atuin init zsh)"
|
||||
bindkey '^r' _atuin_search_widget # bind ctrl+r to atuin
|
||||
# use zsh only session history
|
||||
fc -p
|
||||
|
||||
precmd () {
|
||||
vcs_info
|
||||
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ] || [ -n "$SSH_CONNECTION" ]; then
|
||||
|
||||
@@ -16,8 +16,17 @@
|
||||
boot.initrd.kernelModules = [];
|
||||
boot.kernelModules = ["kvm-intel"];
|
||||
boot.extraModulePackages = [];
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
boot.loader.efi.canTouchEfiVariables = true;
|
||||
|
||||
boot = {
|
||||
loader = {
|
||||
efi.canTouchEfiVariables = true;
|
||||
systemd-boot = {
|
||||
enable = true;
|
||||
configurationLimit = 5;
|
||||
consoleMode = "max";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
boot.initrd.luks.devices."luks-aa6beb1b-3e54-4a0e-ac9c-e0c007d73cd5".device = "/dev/disk/by-uuid/aa6beb1b-3e54-4a0e-ac9c-e0c007d73cd5";
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ in {
|
||||
./go-webring.nix
|
||||
./gemini.nix
|
||||
./wallabag.nix
|
||||
./nethack.nix
|
||||
../../configs/monitoring.nix
|
||||
../../configs/mycelium.nix
|
||||
../../configs/tor.nix
|
||||
|
||||
60
systems/ful/nethack.nix
Normal file
60
systems/ful/nethack.nix
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
networking.firewall.allowedTCPPorts = [ 22 ];
|
||||
|
||||
containers.nethack = {
|
||||
autoStart = true;
|
||||
|
||||
forwardPorts = [
|
||||
{
|
||||
containerPort = 22;
|
||||
hostPort = 22;
|
||||
}
|
||||
];
|
||||
|
||||
config =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
system.stateVersion = "25.11";
|
||||
|
||||
networking.hostName = "nethack";
|
||||
services.openssh.enable = true;
|
||||
|
||||
environment.systemPackages = [ pkgs.nethack ];
|
||||
|
||||
programs.tmux.enable = true;
|
||||
programs.tmux.extraConfig = ''
|
||||
set -g mouse on
|
||||
set -g allow-rename off
|
||||
set -g detach-on-destroy off
|
||||
|
||||
unbind-key C-b
|
||||
set -g prefix None
|
||||
'';
|
||||
|
||||
users.users.nethack = {
|
||||
isNormalUser = true;
|
||||
home = "/home/nethack";
|
||||
createHome = true;
|
||||
shell = pkgs.bash;
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAA...yourkey"
|
||||
"ssh-ed25519 AAAA...friendkey"
|
||||
];
|
||||
};
|
||||
|
||||
services.openssh.settings = {
|
||||
PasswordAuthentication = false;
|
||||
PermitRootLogin = "no";
|
||||
};
|
||||
|
||||
services.openssh.extraConfig = ''
|
||||
Match User nethack
|
||||
ForceCommand ${pkgs.tmux}/bin/tmux attach -t nethack || \
|
||||
${pkgs.tmux}/bin/tmux new -s nethack ${pkgs.nethack}/bin/nethack
|
||||
AllowTcpForwarding no
|
||||
X11Forwarding no
|
||||
PermitTTY yes
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
{pkgs, ...}: {
|
||||
services.postgresqlBackup = {
|
||||
enable = true;
|
||||
databases = ["atuin"];
|
||||
};
|
||||
|
||||
services.postgresql.package = pkgs.postgresql_14;
|
||||
|
||||
services.atuin = {
|
||||
host = "0.0.0.0";
|
||||
openFirewall = true;
|
||||
openRegistration = true;
|
||||
port = 8888;
|
||||
enable = true;
|
||||
};
|
||||
}
|
||||
@@ -7,11 +7,9 @@
|
||||
inherit (import ../../lib) retiolumAddresses restic;
|
||||
in {
|
||||
imports = [
|
||||
./atuin.nix
|
||||
./backup.nix
|
||||
./gaslight.nix
|
||||
./hardware-configuration.nix
|
||||
./nas.nix
|
||||
../../configs/mycelium.nix
|
||||
./home-assistant.nix
|
||||
../../configs/monitoring.nix
|
||||
@@ -66,11 +64,9 @@ in {
|
||||
];
|
||||
};
|
||||
|
||||
services.logind = {
|
||||
lidSwitch = "ignore";
|
||||
lidSwitchDocked = "ignore";
|
||||
lidSwitchExternalPower = "ignore";
|
||||
};
|
||||
services.logind.settings.Login.HandleLidSwitchDocked = "ignore";
|
||||
services.logind.settings.Login.HandleLidSwitchExternalPower = "ignore";
|
||||
services.logind.settings.Login.HandleLidSwitch = "ignore";
|
||||
|
||||
services.illum.enable = true;
|
||||
|
||||
@@ -88,9 +84,6 @@ in {
|
||||
pkgs.python3 # for sshuttle
|
||||
];
|
||||
|
||||
# since 22.05 timeout fails?
|
||||
# systemd.services.systemd-networkd-wait-online.enable = false;
|
||||
|
||||
networking = {
|
||||
hostName = "zaatar";
|
||||
wireless.interfaces = ["wlp2s0"];
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
{ config, ... }:
|
||||
{
|
||||
users.extraUsers.nas = {
|
||||
isSystemUser = true;
|
||||
group = "nas";
|
||||
uid = 7451;
|
||||
};
|
||||
users.extraGroups.nas = {
|
||||
gid = 7452;
|
||||
};
|
||||
|
||||
fileSystems."/media/sd" = {
|
||||
device = "/dev/disk/by-id/5E4S5_0x4c585d15-part1";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"nofail"
|
||||
"defaults"
|
||||
"uid=${toString config.users.extraUsers.nas.uid}"
|
||||
"gid=${toString config.users.extraGroups.nas.gid}"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/media/hdd" = {
|
||||
device = "/dev/disk/by-id/0x50014ee658872039-part1";
|
||||
fsType = "ntfs";
|
||||
options = [ # ref https://askubuntu.com/a/113746
|
||||
"nofail"
|
||||
"defaults"
|
||||
"nls=utf8"
|
||||
"umask=000"
|
||||
"dmask=027"
|
||||
"fmask=137"
|
||||
"uid=${toString config.users.extraUsers.nas.uid}"
|
||||
"gid=${toString config.users.extraGroups.nas.gid}"
|
||||
"windows_names"
|
||||
];
|
||||
};
|
||||
|
||||
# ref https://dataswamp.org/~solene/2020-10-18-nixos-nas.html
|
||||
# ref https://www.reddit.com/r/NixOS/comments/relwsh/comment/hoapgrr/
|
||||
services.samba = {
|
||||
enable = true;
|
||||
securityType = "user";
|
||||
openFirewall = true;
|
||||
settings = {
|
||||
global = {
|
||||
"guest account" = "nobody";
|
||||
"hosts allow" = ["192.168.178." "127.0.0.1" "localhost"];
|
||||
"hosts deny" = ["0.0.0.0/0"];
|
||||
"map to guest" = "Bad User";
|
||||
"netbios name" = "zaatar";
|
||||
"security" = "user";
|
||||
"server role" = "standalone server";
|
||||
"server string" = "zaatar";
|
||||
"workgroup" = "WORKGROUP";
|
||||
};
|
||||
};
|
||||
shares.nas = {
|
||||
path = "/media";
|
||||
browseable = "yes";
|
||||
writable = "yes";
|
||||
# "read only" = "no";
|
||||
"guest ok" = "yes";
|
||||
"create mask" = "0644";
|
||||
"directory mask" = "0755";
|
||||
"force user" = config.users.extraUsers.nas.name;
|
||||
"force group" = config.users.extraUsers.nas.group;
|
||||
};
|
||||
};
|
||||
|
||||
services.samba-wsdd = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
};
|
||||
|
||||
networking.firewall.enable = true;
|
||||
networking.firewall.allowPing = true;
|
||||
}
|
||||
Reference in New Issue
Block a user