1

Compare commits

...

5 Commits

4 changed files with 198 additions and 108 deletions

View File

@ -2,22 +2,22 @@
; NIXOS
; ===========================
% nixos, nixos-rebuild, flake
% nixos
# Rebuild a flake system derivation
sudo nixos-rebuild <type> --flake .#<flake>
$ type: echo -e "switch\nbuild\nboot"
$ flake: echo -e "nixinator\nnixtop"
% nixos, nix-store, closure, dependency
% nixos
# Find out why a package is included in the closure when building the system derivation
nix why-depends /run/current-system nixpkgs#<package>
% nixos, nix-store, storepath, link
% nixos
# Find the storepath of an executable in the users path
readlink -f $(which <executable>)
$ executable: bash -c "compgen -c"
% nixos, nix-store, storepath, libraries
% nixos
# Find the wanted dynamic libraries of an executable in the users path
ldd $(readlink -f $(which <executable>))
$ executable: bash -c "compgen -c"
@ -26,36 +26,55 @@ $ executable: bash -c "compgen -c"
; SHELL
; ===========================
% shell, process
% shell
# Launch a detached process with suppressed output
<command> &>/dev/null &; disown
% yes, head, file
% shell
# Generate a large text file
yes "The quick brown fox jumps over the lazy dog" | head -c <size> > <output>
% fish, for, loop
% shell
# For-loop in fish shell
for o in <objects>; <action>; end
% find
% shell
# Find files under a certain size in the current directory
find . -type f -name "<glob>" -size -<size>
% awk
# Select a column
awk -F<separator> '{print <print>}'
$ separator: echo -e "' '\t\tWhitespace\n'[ ]'\t\tSingle Space\n'\\\t'\t\tTabs" --- --column 1
% mime
# Determine the mime-type of a file
file --mime-type <file>
$ file: eza -f -1
% mime
# Query the default app for a mime type
xdg-mime query default <mimetype>
% mime
# Query the default app for a file
xdg-mime query default $(file --mime-type <file> | awk -F' ' '{print $2}')
$ file: eza -f -1
; ===========================
; CODING
; CODE
; ===========================
% objdump, disassemble
% code
# Disassemble an object file
objdump -d -S -M intel "<file>" | bat -l nasm
$ file: eza -f -1
; ===========================
; DOCUMENTS
; DOCS
; ===========================
% pdftocairo, pdf, svg
% docs
# Extract svg figure from pdf page
pdftocairo -f <page> -l <page> -svg "<input>" "<output>"
$ input: eza -f -1
@ -64,11 +83,11 @@ $ input: eza -f -1
; YT-DLP
; ===========================
% yt-dlp, mp4
% yt-dlp
# Download mp4 video in best quality
yt-dlp -f 'bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4] / bv*+ba/b' --recode-video mp4 "<url>"
% yt-dlp, mp3
% yt-dlp
# Download mp3 video in best quality
yt-dlp -f 'ba' --extract-audio --audio-format mp3 "<url>"
@ -76,33 +95,33 @@ yt-dlp -f 'ba' --extract-audio --audio-format mp3 "<url>"
; FFMPEG
; ===========================
% ffmpeg, slowmo
% ffmpeg
# Create a slow motion version of a video with interpolated/blended frames
ffmpeg -i "<input>" -filter:v "minterpolate='mi_mode=mci:mc_mode=aobmc:vsbmc=1:fps=<doublefps>',setpts=2*PTS" output.mp4
$ input: eza -f -1
% ffmpeg, cropdetect
% ffmpeg
# Detect black bar dimensions automatically by looking at the first 10 frames
ffmpeg -i "<input>" -vframes 10 -vf cropdetect -f null -
$ input: eza -f -1
% ffmpeg, cropdetect, preview
% ffmpeg
# Preview video with applied crop settings
ffplay -vf crop=<width>:<height>:<x>:<y> "<input>"
$ input: eza -f -1
% ffmpeg, cropdetect, render
% ffmpeg
# Re-encode the video with applied crop settings
ffmpeg -i "<input>" -vf crop=<width>:<height>:<x>:<y> -c:a copy output.mp4
$ input: eza -f -1
% ffmpeg, video compression, h265, render, reencode
% ffmpeg
# Reencode and compress the video using the h265 codec
ffmpeg -i "<input>" -vcodec libx265 -crf <quality> "out_<input>"
$ input: eza -f -1
$ quality: echo -e "24\n25\n26\n27\n28\n29\n30\n"
% ffmpeg, video compression, h256, render, reencode
% ffmpeg
# Reencode and compress multiple videos using the h265 codec
fish -c "for name in <files>; ffmpeg -i '$name' -vcodec libx265 -crf <quality> 'out_$name'; end"
$ quality: echo -e "24\n25\n26\n27\n28\n29\n30\n"

View File

@ -76,6 +76,8 @@ rec {
"$mainMod, T" = ["exec, kitty"];
"$mainMod, E" = ["exec, kitty"];
"$mainMod, N" = ["exec, neovide"];
"$mainMod SHIFT, N" = ["exec, neovide ${config.paths.dotfiles}/navi/christoph.cheat"];
"$mainMod CTRL, N" = ["exec, kitty navi"];
"$mainMod, P" = ["exec, hyprpicker --autocopy --format=hex"];
"$mainMod, S" = ["exec, grim -g \"$(slurp)\""];
@ -217,12 +219,21 @@ rec {
# This only works when HM is installed as a system module,
# as nixosConfig won't be available otherwise.
xdg = {
enable = true;
mime.enable = true;
mimeApps = {
enable = true;
associations.added = nixosConfig.xdg.mime.addedAssociations;
associations.removed = nixosConfig.xdg.mime.removedAssociations;
inherit (nixosConfig.xdg.mime) defaultApplications; # Equal to "defaultApplications = nixosConfig.xdg.mime.defaultApplications"
defaultApplications = nixosConfig.xdg.mime.defaultApplications;
};
# TODO: What about desktop portals? They're configured in system config, do I need to do sth here?
portal = {
enable = nixosConfig.xdg.portal.enable;
xdgOpenUsePortal = nixosConfig.xdg.portal.xdgOpenUsePortal;
config.common.default = nixosConfig.xdg.portal.config.common.default;
extraPortals = nixosConfig.xdg.portal.extraPortals;
};
};
@ -671,12 +682,16 @@ rec {
};
};
systemd.user.tmpfiles.rules = [
# Fix Discord rich presence for Flatpak
"L %t/discord-ipc-0 - - - - app/com.discordapp.Discord/discord-ipc-0"
# "L %t/discord-ipc-0 - - - - app/com.discordapp.DiscordCanary/discord-ipc-0"
];
systemd = {
user = {
tmpfiles.rules = [
# Fix Discord rich presence for Flatpak
"L %t/discord-ipc-0 - - - - app/com.discordapp.Discord/discord-ipc-0"
# "L %t/discord-ipc-0 - - - - app/com.discordapp.DiscordCanary/discord-ipc-0"
];
# Nicely reload system units when changing configs
systemd.user.startServices = "sd-switch";
# Nicely reload system units when changing configs
startServices = "sd-switch";
};
};
}

View File

@ -1,7 +1,4 @@
# TODO: Use the home-manager module instead of generating my own scuffed config files
#
# TODO: The keys to reset the workspaces need to depend on actual workspace config
# TODO: The border color does not fit the current theme
{
config,
lib,

View File

@ -147,75 +147,22 @@ with mylib.networking; {
supportedLocales = ["en_US.UTF-8/UTF-8" "de_DE.UTF-8/UTF-8"];
};
# XDG
xdg.portal = {
enable = true;
xdgOpenUsePortal = true;
wlr.enable = false; # Hyprland has its own portal automatically enabled...
extraPortals = with pkgs; [
xdg-desktop-portal-gtk
# xdg-desktop-portal-kde
# xdg-desktop-portal-hyprland # Already enabled by hyprland system module
# xdg-desktop-portal-termfilechooser # Filepicker using nnn
];
};
# See https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
xdg.mime = rec {
enable = true;
removedAssociations = {
"application/pdf" = [
"chromium-browser.desktop"
"com.google.Chrome.desktop"
"firefox.desktop"
];
"text/plain" = [
"firefox.desktop"
"code.desktop"
];
"text/html" = [
"chromium-browser.desktop"
"com.google.Chrome.desktop"
];
"application/xhtml+xml" = [
"chromium-browser.desktop"
"com.google.Chrome.desktop"
];
};
defaultApplications = let
textEditor = "neovide.desktop"; # Helix.desktop
fileBrowser = "yazi.desktop";
webBrowser = "firefox.desktop";
pdfViewer = "org.pwmt.zathura.desktop";
imageViewer = "imv.desktop";
audioPlayer = "vlc.desktop"; # mov.desktop
videoPlayer = "vlc.desktop";
textMimeTypes = [
xdg = {
# See https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
# Find .desktop files: fd ".*\.desktop" / | grep --color=auto -E neovide
mime = let
textTypes = [
"text/css"
"text/csv"
"text/javascript"
"text/plain"
"text/xml"
"application/json"
"application/ld+json"
"application/x-sh"
"text/plain"
"application/xml"
"text/xml"
];
fileBrowserMimeTypes = [
"inode/directory"
];
webBrowserMimeTypes = [
"text/html"
"application/xhtml+xml"
];
pdfMimeTypes = [
"application/pdf"
];
imageMimeTypes = [
imageTypes = [
"image/apng"
"image/avif"
"image/bmp"
@ -226,7 +173,7 @@ with mylib.networking; {
"image/tiff"
"image/webp"
];
audioMimeTypes = [
audioTypes = [
"audio/aac"
"audio/mpeg"
"audio/ogg"
@ -236,7 +183,7 @@ with mylib.networking; {
"audio/3gpp"
"audio/3gpp2"
];
videoMimeTypes = [
videoTypes = [
"video/x-msvideo"
"video/mp4"
"video/mpeg"
@ -246,21 +193,128 @@ with mylib.networking; {
"video/3gpp"
"video/3gpp2"
];
mkAssociation = app: type: {${type} = app;};
mkAssociations = app: types: lib.mergeAttrsList (builtins.map (mkAssociation app) types);
in
lib.mergeAttrsList [
(mkAssociations textEditor textMimeTypes)
(mkAssociations fileBrowser fileBrowserMimeTypes)
(mkAssociations webBrowser webBrowserMimeTypes)
(mkAssociations pdfViewer pdfMimeTypes)
(mkAssociations imageViewer imageMimeTypes)
(mkAssociations audioPlayer audioMimeTypes)
(mkAssociations videoPlayer videoMimeTypes)
webTypes = [
"text/uri-list"
"text/x-uri"
"text/html"
"application/xhtml+xml"
"x-scheme-handler/https"
];
in rec {
enable = true;
addedAssociations = defaultApplications;
defaultApplications = let
associations = {
"neovide.desktop" = textTypes ++ [];
"yazi.desktop" = ["inode/directory"];
"firefox.desktop" = webTypes ++ [];
"org.pwmt.zathura.desktop" = ["application/pdf"];
"imv-dir.desktop" = imageTypes ++ []; # imv-dir autoselects the directory so next/prev works
"vlc.desktop" = audioTypes ++ videoTypes ++ [];
};
# Applied to a single app and a single type
mkAssociation = app: type: {${type} = [app];}; # Result: { "image/jpg" = ["imv.desktop"]; }
# Applied to a single app and a list of types
mkAssociations = app: types: lib.mergeAttrsList (builtins.map (mkAssociation app) types); # Result: { "image/jpg" = ["imv.desktop"]; "image/png" = ["imv.desktop"]; ... }
in
# Apply to a list of apps each with a list of types
lib.mergeAttrsList (lib.mapAttrsToList mkAssociations associations);
addedAssociations = defaultApplications;
removedAssociations = let
fromTextTypes = [
"nvim.desktop"
];
fromImageTypes = [
"imv.desktop"
"chromium-browser.desktop"
"org.kde.krita.desktop"
"krita.desktop"
"krita_svg.desktop"
"krita_raw.desktop"
"krita_heif.desktop"
"krita_webp.desktop"
"krita_gif.desktop"
"krita_brush.desktop"
"krita_xcf.desktop"
"krita_jpeg.desktop"
"krita_spriter.desktop"
"krita_jxl.desktop"
"krita_ora.desktop"
"krita_csv.desktop"
"krita_tga.desktop"
"krita_psd.desktop"
"krita_png.desktop"
"krita_tiff.desktop"
"krita_exr.desktop"
"krita_qimageio.desktop"
"krita_pdf.desktop"
"krita_jp2.desktop"
"krita_heightmap.desktop"
"krita_kra.desktop"
"krita_krz.desktop"
];
fromAudioTypes = [];
fromVideoTypes = [];
fromWebTypes = [
"chromium-browser.desktop"
"com.google.Chrome.desktop"
];
# Applied to a list of apps and a single type
removeAssociation = apps: type: {${type} = apps;};
# Applied to a list of apps and a list of types: For each type the list of apps should be removed
removeAssociations = apps: types: lib.mergeAttrsList (builtins.map (removeAssociation apps) types);
in
lib.mergeAttrsList [
{
"application/pdf" = [
"chromium-browser.desktop"
"com.google.Chrome.desktop"
"firefox.desktop"
];
"text/plain" = [
"firefox.desktop"
"code.desktop"
];
}
# Only activate those if applications to remove are specified: (len from...Types) > 0
(lib.optionalAttrs (builtins.lessThan 0 (builtins.length fromTextTypes))
(removeAssociations fromTextTypes textTypes))
(lib.optionalAttrs (builtins.lessThan 0 (builtins.length fromImageTypes))
(removeAssociations fromImageTypes imageTypes))
(lib.optionalAttrs (builtins.lessThan 0 (builtins.length fromAudioTypes))
(removeAssociations fromAudioTypes audioTypes))
(lib.optionalAttrs (builtins.lessThan 0 (builtins.length fromVideoTypes))
(removeAssociations fromVideoTypes videoTypes))
(lib.optionalAttrs (builtins.lessThan 0 (builtins.length fromWebTypes))
(removeAssociations fromWebTypes webTypes))
];
};
# XDG
portal = {
enable = true;
xdgOpenUsePortal = false;
config.common.default = ["*"]; # https://discourse.nixos.org/t/clicked-links-in-desktop-apps-not-opening-browers/29114/26
wlr.enable = false; # Hyprland has its own portal automatically enabled...
extraPortals = with pkgs; [
xdg-desktop-portal-gtk
# xdg-desktop-portal-kde
# xdg-desktop-portal-hyprland # Already enabled by hyprland system module
# xdg-desktop-portal-termfilechooser # Filepicker using nnn
];
};
};
fonts = {
@ -368,7 +422,12 @@ with mylib.networking; {
# pay-respects.enable = true; # The new fuck
xwayland.enable = true;
nix-ld.enable = true; # Load dynamically linked executables
hyprland.enable = true;
hyprland = {
enable = true;
xwayland.enable = true;
withUWSM = true;
};
nh = {
enable = true;