the newest thing for extrem power usage

This commit is contained in:
Sebastian Moser
2025-04-06 14:38:03 +02:00
parent 2bdcfe6695
commit 12fcb7050a
2 changed files with 130 additions and 3 deletions

View File

@@ -5,7 +5,7 @@
enable = true;
enableCompletion = true;
historyFile = if hostname == "main" then "/home/$USER/work/app-data/${hostname}/bash-history" else "/home/$USER/here/bash-history";
historyFile = if hostname == "main" then "/home/$USER/work/app-data/${hostname}/bash-history" else "/home/$USER/host/bash-history";
historyFileSize = 100000;
historyControl = [ "ignoredups" ];
historyIgnore = [
@@ -92,8 +92,8 @@
export NIXPKGS_ALLOW_UNFREE=1
# the commit hash of nixpkgs 23.11
export nip="nixpkgs/71db8c7a02f3be7cb49b495786050ce1913246d3"
export nup="nixpkgs/2a34566b67bef34c551f204063faeecc444ae9da"
export nip="nixpkgs/${self.inputs.nixpkgs.rev}"
export nup="nixpkgs/${self.inputs.nixpkgs-unstable.rev}"
# needed to make ssh -X work
# see: https://unix.stackexchange.com/questions/412065/ssh-connection-x11-connection-rejected-because-of-wrong-authentication
@@ -138,6 +138,17 @@
complete -W "mosatop acern" rp
# function to create a tmpdir, to use for some temporary work....
# made this, to not just keep cluttering my $HOME... with all kinds of projects
function mt () {
export TOPDIR=$HOME/tmp
mkdir -p $TOPDIR
cd $(${pkgs.python3}/bin/python ${self}/scripts/quick-tmp-dir.py "$@")
}
# so that programms i spawn from my shell don't have so high cpu priority
[ which renice 2>/dev/null ] && renice -n 9 $$ > /dev/null

116
scripts/quick-tmp-dir.py Normal file
View File

@@ -0,0 +1,116 @@
import sys
import os
import shutil
banned_names = []
topdir = os.environ["TOPDIR"]
if topdir.endswith("/"):
topdir = topdir[0:-1]
pwd = os.getcwd()
chars_right = {
"index" : "rfvbgt",
"middle": "ed",
"ring": "ws",
"pinky": "",
}
chars_left = {
"index" : "hnzujm",
"middle": "ik",
"ring": "lo",
"pinky": "dp",
}
chars_as_list = list(chars_right.values()) + list(chars_left.values())
listing = os.listdir(topdir)
def check(name):
#print("######## name:", name)
chose_this_name = True
for item in listing:
if item.startswith(name):
chose_this_name = False
break;
if chose_this_name:
path = topdir + "/" + name
os.mkdir(path)
print("Created tmpdir at:", path, file=sys.stderr)
print(path, end="")
exit()
# if arg1 is "c" ... clear all empty dirs in topdir
try:
tmp = sys.argv[1]
except:
tmp = ""
if tmp == "c":
print("Removing all empty tmp-dirs", file=sys.stderr)
tmpdirs = os.listdir(topdir)
#print("tmpdirs...", tmpdirs, file=sys.stderr)
for el in tmpdirs:
path = topdir + "/" + el
if os.listdir(path) == []:
print("- removing...", path, file=sys.stderr)
os.rmdir(path)
# exit without cd'ing anywhere
print(pwd, end="")
exit()
# if we are in a sub dir of topdir
# we want to rename the current tmpdir to argv[1]
if pwd.startswith(topdir):
name = ""
for arg in sys.argv[1:]:
name += "_" + arg
if name == "":
print("Would rename, but no name given as argv[1]", file=sys.stderr)
# exit without cd'ing anywhere
print(pwd, end="")
exit()
name = name[1:]
len_topdir = len(topdir.split("/"))
old_arr = pwd.split("/")[0:len_topdir +1]
old = "/".join(old_arr)
new = topdir + "/" + name
print("Renaming", old, "to", new)
shutil.move(old, new)
print(new, end="")
exit()
# exit without cd'ing anywhere
print(pwd, end="")
exit()
for finger_one in chars_as_list:
for finger_two in chars_as_list:
if finger_one is not finger_two:
for char_one in finger_one:
for char_two in finger_two:
if char_one is not char_two:
name = char_one + char_two
if name not in banned_names:
check(name)