Major config overhaul: use custom modules, setup for multi-host config, and less boilerplate

This commit is contained in:
Emmet K
2025-02-09 16:50:26 -06:00
parent 1fa8b17b07
commit 0453901d17
303 changed files with 3560 additions and 5566 deletions

47
modules/user/README.org Normal file
View File

@@ -0,0 +1,47 @@
#+title: User-level Nix Modules
#+author: Emmet
Separate Nix files can be imported as modules using an import block:
#+BEGIN_SRC nix
imports = [ import1.nix
import2.nix
...
];
#+END_SRC
My user-level Nix modules are organized into this directory:
- [[./app][app]] - Apps or collections of apps bundled with my configs
- [[./app/browser][browser]] - Used to set default browser
- [[./app/dmenu-scripts][dmenu-scripts]]
- [[./app/doom-emacs][doom-emacs]]
- [[./app/flatpak][flatpak]] - Installs flatpak as a utility (flatpaks must be installed manually)
- [[./app/games][games]] - Gaming setup
- [[./app/git][git]]
- [[./app/keepass][keepass]]
- [[./app/ranger][ranger]]
- [[./app/terminal][terminal]] - Configuration for terminal emulators
- [[./app/virtualization][virtualization]] - Virtualization and compatability layers
- [[./lang][lang]] - Various bundled programming languages
- I will probably get rid of this in favor of a shell.nix for every project, once I learn how that works
- [[./pkgs][pkgs]] - "Package builds" for packages not in the Nix repositories
- [[./pkgs/pokemon-colorscripts.nix][pokemon-colorscripts]]
- [[./pkgs/rogauracore.nix][rogauracore]] - not working yet
- [[./shell][shell]] - My default bash and zsh configs
- [[./shell/sh.nix][sh]] - bash and zsh configs
- [[./shell/cli-collection.nix][cli-collection]] - Curated useful CLI utilities
- [[./style][style]] - Stylix setup (system-wide base16 theme generation)
- [[./wm][wm]] - Window manager, compositor, wayland compositor, and/or desktop environment setups
- [[./wm/hyprland][hyprland]]
- [[./wm/xmonad][xmonad]]
- [[./wm/picom][picom]]
** Variables imported from flake.nix
Variables can be imported from [[../flake.nix][flake.nix]] by setting the =extraSpecialArgs= block inside the flake (see [[../flake.nix][my flake]] for more details). This allows variables to merely be managed in one place ([[../flake.nix][flake.nix]]) rather than having to manage them in multiple locations.
I use this to pass a few attribute sets:
- =userSettings= - Settings for the normal user (see [[../flake.nix][flake.nix]] for more details)
- =systemSettings= - Settings for the system (see [[../flake.nix][flake.nix]] for more details)
- =inputs= - Flake inputs (see [[../flake.nix][flake.nix]] for more details)
- =pkgs= - Set to unstable for client devices and stable for server devices
- =pkgs-stable= - Allows me to include stable versions of packages along with (my default) unstable versions of packages
- =pkgs-unstable= - Allows me to force unstable versions of packages on server devices

View File

@@ -0,0 +1,22 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.art;
in {
options = {
userSettings.art = {
enable = lib.mkEnableOption "Enable art apps";
};
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
gimp
krita
pinta
inkscape
libresprite
];
userSettings.blender.enable = true;
};
}

View File

@@ -0,0 +1,28 @@
import os
import bpy
# load prefs
prefs = bpy.context.preferences
# ui
prefs.view.ui_scale = 1.2
prefs.view.show_tooltips_python = True
prefs.view.render_display_type = 'SCREEN'
prefs.view.filebrowser_display_type = 'SCREEN'
prefs.view.gizmo_size_navigate_v3d = 50
# status bar
prefs.view.show_statusbar_stats = True
prefs.view.show_statusbar_scene_duration = True
prefs.view.show_statusbar_memory = True
prefs.view.show_statusbar_vram = True
prefs.view.color_picker_type = 'SQUARE_SV'
# performance
prefs.system.viewport_aa = 'FXAA'
# addons
bpy.ops.preferences.addon_enable(module="node_wrangler")
bpy.ops.preferences.addon_enable(module="rigify")
bpy.ops.preferences.addon_install(filepath=os.path.expanduser("~/.config/blender/extensions/node_pie.zip"),enable_on_install=True)
bpy.ops.extensions.package_install_files(filepath=os.path.expanduser("~/.config/blender/extensions/bool_tool.zip"),repo="user_default",enable_on_install=True)

View File

@@ -0,0 +1,24 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.blender;
in {
options = {
userSettings.blender = {
enable = lib.mkEnableOption "Enable blender";
};
};
config = {
home.packages = [ pkgs.blender-hip ];
home.file.".config/blender/extensions/node_pie.zip".source = builtins.fetchurl {
url = "https://github.com/strike-digital/node_pie/releases/download/1.2.38/node_pie_1_2_38.zip";
sha256 = "sha256:00kscj7dkl80kc482jg3kcw9vhr1n64n44ld2xncr6gxil679fk2";
};
home.file.".config/blender/extensions/bool_tool.zip".source = builtins.fetchurl {
name = "bool_tool";
url = "https://extensions.blender.org/download/sha256:74ecd752ec3eda67153c74ea5a6b22709da2669a6da43264bfa291fc784306b3/add-on-bool-tool-v1.1.2.zip?repository=%2Fapi%2Fv1%2Fextensions%2F&blender_version_min=4.2.0";
sha256 = "sha256:1cq68dwgr4d2pxj3593dk9ka57bh49mmmskl7hangniyxi9dgv3l";
};
};
}

View File

@@ -0,0 +1,20 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.bluetooth;
in {
options = {
userSettings.bluetooth = {
enable = lib.mkEnableOption "Enable bluetooth";
};
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
blueman
];
services = {
blueman-applet.enable = true;
};
};
}

View File

@@ -0,0 +1,44 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.brave;
in {
options = {
userSettings.brave = {
enable = lib.mkEnableOption "Enable brave browser";
};
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.brave ];
nixpkgs.config.overlays = [
(self: super: {
brave = super.brave.override {
commandLineArgs = [
"--password-store=gnome-libsecret"
"--ignore-gpu-blocklist"
"--enable-gpu-rasterization"
"--enable-accelerated-video-decode"
"--enable-quic"
"--enable-zero-copy"
"--enable-native-gpu-memory-buffers"
"--num-raster-threads=4"
];
};
})
];
xdg.mimeApps.defaultApplications = lib.mkIf (config.userSettings.browser == "brave" ) {
"text/html" = "brave-browser.desktop";
"x-scheme-handler/http" = "brave-browser.desktop";
"x-scheme-handler/https" = "brave-browser.desktop";
"x-scheme-handler/about" = "brave-browser.desktop";
"x-scheme-handler/unknown" = "brave-browser.desktop";
};
home.sessionVariables = lib.mkIf (config.userSettings.browser == "brave") {
DEFAULT_BROWSER = "${pkgs.brave}/bin/brave";
};
};
}

View File

@@ -0,0 +1,30 @@
{ config, lib, pkgs, ... }:
let
browser = config.userSettings.browser;
in {
options = {
userSettings.browser = lib.mkOption {
default = "brave";
description = "Default browser";
type = lib.types.enum [ "brave" "qutebrowser" "librewolf" ];
};
userSettings.spawnBrowser = lib.mkOption {
default = "brave";
description = "Default browser spawn command";
type = lib.types.str;
};
};
config = {
userSettings.brave.enable = lib.mkIf (browser == "brave") true;
userSettings.librewolf.enable = lib.mkIf (browser == "librewolf") true;
userSettings.qutebrowser.enable = lib.mkIf (browser == "qutebrowser") true;
userSettings.spawnBrowser = lib.mkMerge [
(lib.mkIf ((browser == "brave") || (browser == "librewolf")) browser)
(lib.mkIf (!(config.userSettings.hyprland.hyprprofiles.enable) && (browser == "qutebrowser")) "qutebrowser --qt-flag ignore-gpu-blacklist --qt-flag enable-gpu-rasterization --qt-flag enable-native-gpu-memory-buffers --qt-flag enable-accelerated-2d-canvas --qt-flag num-raster-threads=4")
(lib.mkIf config.userSettings.hyprland.hyprprofiles.enable "qutebrowser-hyprprofile")
];
};
}

View File

@@ -0,0 +1,51 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.librewolf;
in {
options = {
userSettings.librewolf = {
enable = lib.mkEnableOption "Enable librewolf browser";
};
};
config = lib.mkIf cfg.enable {
# Module installing librewolf as default browser
home.packages = [ pkgs.librewolf ];
home.file.".librewolf/librewolf.overrides.cfg".text = ''
defaultPref("font.size.variable.x-western",20);
defaultPref("browser.toolbars.bookmarks.visibility","always");
defaultPref("privacy.resisttFingerprinting.letterboxing", true);
defaultPref("network.http.referer.XOriginPolicy",2);
defaultPref("privacy.clearOnShutdown.history",true);
defaultPref("privacy.clearOnShutdown.downloads",true);
defaultPref("privacy.clearOnShutdown.cookies",true);
defaultPref("gfx.webrender.software.opengl",false);
defaultPref("webgl.disabled",true);
pref("font.size.variable.x-western",20);
pref("browser.toolbars.bookmarks.visibility","always");
pref("privacy.resisttFingerprinting.letterboxing", true);
pref("network.http.referer.XOriginPolicy",2);
pref("privacy.clearOnShutdown.history",true);
pref("privacy.clearOnShutdown.downloads",true);
pref("privacy.clearOnShutdown.cookies",true);
pref("gfx.webrender.software.opengl",false);
pref("webgl.disabled",true);
'';
xdg.mimeApps.defaultApplications = lib.mkIf (config.userSettings.browser == "librewolf") {
"text/html" = "librewolf.desktop";
"x-scheme-handler/http" = "librewolf.desktop";
"x-scheme-handler/https" = "librewolf.desktop";
"x-scheme-handler/about" = "librewolf.desktop";
"x-scheme-handler/unknown" = "librewolf.desktop";
};
home.sessionVariables = lib.mkIf (config.userSettings.browser == "librewolf") {
DEFAULT_BROWSER = "${pkgs.librewolf}/bin/librewolf";
};
};
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

@@ -0,0 +1,450 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.qutebrowser;
font = config.stylix.fonts.monospace.name;
generateHomepage = name: font: config:
''<!DOCTYPE html>
<html>
<head>
<title>My Local Dashboard Awesome Homepage</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/*body*/
body {
background-color: #''+config.lib.stylix.colors.base00+''
}
/*paragraphs*/
a, p {
font-family:''+font+'';
font-size:24px;
text-align:center;
color: #''+config.lib.stylix.colors.base08+'';
line-height: 1.35;
margin-top: 0;
margin-bottom: 0;
text-decoration: none;
}
a:hover {
color: #''+config.lib.stylix.colors.base07+'';
}
.open {
color: #''+config.lib.stylix.colors.base09+'';
font-weight: bold;
}
.open:hover {
background-color: #''+config.lib.stylix.colors.base09+'';
}
.quickmarks {
color: #''+config.lib.stylix.colors.base0A+'';
font-weight: bold;
}
.quickmarks:hover {
background-color: #''+config.lib.stylix.colors.base0A+'';
}
.history {
color: #''+config.lib.stylix.colors.base0B+'';
font-weight: bold;
}
.history:hover {
background-color: #''+config.lib.stylix.colors.base0B+'';
}
.newtab {
color: #''+config.lib.stylix.colors.base0C+'';
font-weight: bold;
}
.newtab:hover {
background-color: #''+config.lib.stylix.colors.base0C+'';
}
.close {
color: #''+config.lib.stylix.colors.base0D+'';
font-weight: bold;
}
.close:hover {
background-color: #''+config.lib.stylix.colors.base0D+'';
}
/*div*/
div {
margin:auto;
width:50%;
text-align:center;
}
/*class made for ascii art icon*/
.icon {
line-height:10%
}
</style>
</head>
<body>
<!--start with cool qutebrowser ascii art-->
<br>
<br>
<br>
<div class="icon">
<img width="300" src="logo.png">
</div>
<br>
<br>
<br>
<!--qutebrowser title-->
<p style="color:#''+config.lib.stylix.colors.base01+''">Welcome to Qutebrowser</p>
<br>
<p><b>''+name+" "+''Profile</b></p>
<br>
<!--basic keyboard commands-->
<div>
<a class="open" href="https://www.startpage.com"> [o] [Search] </p>
<a class="quickmarks" href="./quickmarks.html" target="_blank" rel="noopener noreferrer"> [b] [Quickmarks] </p>
<a class="newtab" href="./qute-home.html" target="_blank" rel="noopener noreferrer"> [t] [New tab] </p>
<a class="close" href="#" onclick="window.close();return false;"> [x] [Close tab] </p>
</div>
</body>
</html>
'';
qute-containers = (pkgs.callPackage ({ lib, stdenv, fetchFromGitHub, dmenuCmd ? config.userSettings.dmenuScripts.dmenuCmd, ... }:
let name = "qute-containers";
version = "unstable";
dmenu = dmenuCmd;
in
stdenv.mkDerivation {
inherit name version;
src = fetchFromGitHub {
owner = "s-praveen-kumar";
repo = "qute-containers";
rev = "c6164b94104fa8565200b87bfc87a2e08ca15ac7";
sha256 = "sha256-g684sPSEJTRSk2V8LVrQsNeRIYtaQueRpZeREWtmQKw=";
};
phases = "installPhase";
postPatch = ''sed -i "s/qutebrowser/qutebrowser --qt-flag ignore-gpu-blacklist --qt-flag enable-gpu-rasterization --qt-flag enable-native-gpu-memory-buffers --qt-flag enable-accelerated-2d-canvas --qt-flag num-raster-threads=4/g" container-open'';
installPhase = ''
mkdir -p $out $out/bin
cp $src/* $out/bin
sed -i 's/DMENU=\"rofi -dmenu\"/DMENU=\"''+dmenu+''\"/g' $out/bin/containers_config
sed -i 's/DMENU_FLAGS//g' $out/bin/container-open
'';
meta = {
homepage = "https://github.com/s-praveen-kumar/qute-containers";
description = "Browser Containers for Qutebrowser";
license = lib.licenses.mit;
maintainers = [];
};
}));
in {
options = {
userSettings.qutebrowser = {
enable = lib.mkEnableOption "Enable qutebrowser with my settings";
};
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.qutebrowser
#qute-containers # TODO disabled for debugging
];
# home.file.".config/qutebrowser/userscripts/container-open".source = "${qute-containers}/bin/container-open";
# home.file.".config/qutebrowser/userscripts/containers_config".source = "${qute-containers}/bin/containers_config";
programs.qutebrowser.enable = true;
programs.qutebrowser.extraConfig = ''
import sys
import os.path
secretsExists = False
secretFile = os.path.expanduser("~/.config/qutebrowser/qutesecrets.py")
if (os.path.isfile(secretFile)):
sys.path.append(os.path.dirname(secretFile))
import qutesecrets
secretsExists = True
quickmarksFile = os.path.join(os.path.dirname(__file__),'quickmarks')
quickmarksHtmlFilePath = os.path.join(os.path.dirname(__file__),'quickmarks.html')
quickmarksHtmlFile = open(quickmarksHtmlFilePath,"w")
quickmarksHtmlFileText = '<!DOCTYPE html><html><head><title>My Local Dashboard Awesome Homepage</title><meta name="viewport" content="width=device-width, initial-scale=1"><style>/*body*/body {background-color: #''+config.lib.stylix.colors.base00+''}/*paragraphs*/a, p {font-weight: bold;font-family:''+font+'';font-size:24px;text-align:center;color: #''+config.lib.stylix.colors.base07+'';line-height: 1.35;margin-top: 0;margin-bottom: 0;text-decoration: none;}a:hover {color: #''+config.lib.stylix.colors.base07+'';background-color: #''+config.lib.stylix.colors.base0A+'';}/*div*/div {margin:auto;width:50%;text-align:center;}/*class made for ascii art icon*/.icon {line-height:10%}.title{color: #''+config.lib.stylix.colors.base0A+'';text-decoration:underline;}</style></head><body><!--start with cool qutebrowser ascii art--><br><br><div class="icon"><img width="100" src="logo.png"></div><br><br><!--qutebrowser title--><p class="title">Quickmarks</p><br><div>'
with open(quickmarksFile) as myQuickmarks:
for line in myQuickmarks:
quickmarkData = line.split()
quickmarksHtmlFileText += '<a href="'+quickmarkData[1]+'">'+quickmarkData[0]+'</a><br>'
quickmarksHtmlFileText += '</div></body></html>'
quickmarksHtmlFile.write(quickmarksHtmlFileText)
quickmarksHtmlFile.close()
config.set('content.blocking.method','both')
config.set('scrolling.smooth',True)
config.set('qt.args',['ignore-gpu-blacklist','enable-gpu-rasterization','enable-accelerated-video-decode','enable-quic','enable-zero-copy','enable-native-gpu-memory-buffers','num-raster-threads=4','allow-file-access-from-files'])
config.set('qt.workarounds.disable_accelerated_2d_canvas','never')
config.load_autoconfig(True)
base00 = "#''+config.lib.stylix.colors.base00+''"
base01 = "#''+config.lib.stylix.colors.base01+''"
base02 = "#''+config.lib.stylix.colors.base02+''"
base03 = "#''+config.lib.stylix.colors.base03+''"
base04 = "#''+config.lib.stylix.colors.base04+''"
base05 = "#''+config.lib.stylix.colors.base05+''"
base06 = "#''+config.lib.stylix.colors.base06+''"
base07 = "#''+config.lib.stylix.colors.base07+''"
base08 = "#''+config.lib.stylix.colors.base08+''"
base09 = "#''+config.lib.stylix.colors.base09+''"
base0A = "#''+config.lib.stylix.colors.base0A+''"
base0B = "#''+config.lib.stylix.colors.base0B+''"
base0C = "#''+config.lib.stylix.colors.base0C+''"
base0D = "#''+config.lib.stylix.colors.base0D+''"
base0E = "#''+config.lib.stylix.colors.base0E+''"
base0F = "#''+config.lib.stylix.colors.base0F+''"
config.set('content.cookies.accept', 'no-3rdparty', 'chrome-devtools://*')
config.set('content.cookies.accept', 'no-3rdparty', 'devtools://*')
config.set('content.headers.user_agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36', 'https://accounts.google.com/*')
config.set('content.headers.user_agent', 'Mozilla/5.0 ({os_info}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99 Safari/537.36', 'https://*.slack.com/*')
config.set('content.images', True, 'chrome-devtools://*')
config.set('content.images', True, 'devtools://*')
config.set('content.javascript.enabled', True, 'chrome-devtools://*')
config.set('content.javascript.enabled', True, 'devtools://*')
config.set('content.javascript.enabled', True, 'chrome://*/*')
config.set('content.javascript.enabled', True, 'qute://*/*')
config.set('content.javascript.enabled', True, 'qute://*/*')
c.tabs.favicons.scale = 1.0
c.tabs.last_close = 'close'
c.tabs.position = 'left'
c.tabs.width = '3%'
c.window.transparent = True
c.colors.webpage.darkmode.enabled = ''+(if (config.stylix.polarity == "dark") then "True" else "False")+''
c.colors.webpage.preferred_color_scheme = "''+config.stylix.polarity+''"
c.colors.webpage.darkmode.policy.images = 'never'
c.url.default_page = str(config.configdir)+'/qute-home.html'
c.url.start_pages = str(config.configdir)+'/qute-home.html'
c.url.searchengines = {'DEFAULT': 'https://search.brave.com/search?q={}&source=web',
'sp': 'https://startpage.com/do/search?query={}',
'd' : 'https://duckduckgo.com/?q={}&ia=web',
'az' : 'https://www.amazon.com/s?k={}',
'aw' : 'https://wiki.archlinux.org/index.php?search={}&title=Special%3ASearch&wprov=acrw1',
'nw' : 'https://nixos.wiki/index.php?search={}&go=Go',
'mn' : 'https://mynixos.com/search?q={}',
'sb' : 'https://www.serebii.net/search.shtml?q={}&sa=Search',
'bp' : 'https://bulbapedia.bulbagarden.net/wiki/index.php?title=Special%3ASearch&search={}&go=Go',
'yt' : 'https://www.youtube.com/results?search_query={}',
'od' : 'https://odysee.com/$/search?q={}',
'gd' : 'https://drive.google.com/drive/search?q={}',
'gh' : 'https://github.com/search?q={}&type=repositories',
'gl' : 'https://gitlab.com/search?search={}&nav_source=navbar',
'np' : 'https://github.com/search?q=repo%3ANixOS%2Fnixpkgs%20{}&type=code',
'wk' : 'https://en.wikipedia.org/w/index.php?fulltext=1&search={}&title=Special%3ASearch&ns0=1',
'th' : 'https://www.thingiverse.com/search?q={}&page=1',
'dh' : 'https://hub.docker.com/search?q={}'
}
config.set('completion.open_categories',["searchengines","quickmarks","bookmarks"])
config.set('downloads.location.directory', '~/Downloads')
config.set('fileselect.handler', 'external')
config.set('fileselect.single_file.command', ['kitty','-e','ranger','--choosefile={}'])
config.set('fileselect.multiple_files.command', ['kitty','-e','ranger','--choosefiles={}'])
config.set('fileselect.folder.command', ['kitty','-e','ranger','--choosedir={}'])
# bindings from doom emacs
config.bind('<Alt-x>', 'cmd-set-text :')
config.bind('<Space>.', 'cmd-set-text :')
config.bind('<Space>b', 'bookmark-list')
config.bind('<Space>h', 'history')
config.bind('<Space>gh', 'open https://github.com')
config.bind('<Space>gl', 'open https://gitlab.com')
config.bind('<Space>gc', 'open https://codeberg.org')
if (secretsExists):
config.bind('<Space>gg', 'open '+qutesecrets.mygiteadomain)
config.bind('<Ctrl-p>', 'completion-item-focus prev', mode='command')
config.bind('<Ctrl-n>', 'completion-item-focus next', mode='command')
config.bind('<Ctrl-p>', 'fake-key <Up>', mode='normal')
config.bind('<Ctrl-n>', 'fake-key <Down>', mode='normal')
config.bind('<Ctrl-p>', 'fake-key <Up>', mode='insert')
config.bind('<Ctrl-n>', 'fake-key <Down>', mode='insert')
config.bind('<Ctrl-p>', 'fake-key <Up>', mode='passthrough')
config.bind('<Ctrl-n>', 'fake-key <Down>', mode='passthrough')
# bindings from vimium
config.bind('t', 'open -t')
config.bind('x', 'tab-close')
config.bind('yf', 'hint links yank')
config.bind('<Ctrl-Tab>', 'tab-next')
config.bind('<Ctrl-Shift-Tab>', 'tab-prev')
# passthrough bindings
config.bind('<Shift-Escape>', 'mode-leave', mode='passthrough')
config.bind('<Ctrl-T>', 'open -t', mode='passthrough')
config.bind('<Ctrl-W>', 'tab-close', mode='passthrough')
config.bind('<Ctrl-Tab>', 'tab-next', mode='passthrough')
config.bind('<Ctrl-Shift-Tab>', 'tab-prev', mode='passthrough')
config.bind('<Ctrl-B>', 'cmd-set-text -s :quickmark-load -t', mode='passthrough')
config.bind('<Ctrl-O>', 'cmd-set-text -s :open -t', mode='passthrough')
config.bind('<Ctrl-F>', 'cmd-set-text /', mode='passthrough')
config.bind('<Ctrl-R>', 'reload', mode='passthrough')
config.unbind('<Ctrl-X>')
config.unbind('<Ctrl-A>')
# spawn external programs
config.bind(',m', 'hint links spawn mpv {hint-url}')
config.bind(',co', 'spawn container-open')
config.bind(',cf', 'hint links userscript container-open')
# TODO stylix user CSS
# current_stylesheet_directory = '~/.config/qutebrowser/themes/'
# current_stylesheet = base16_theme+'-all-sites.css'
# current_stylesheet_path = current_stylesheet_directory + current_stylesheet
# config.set('content.user_stylesheets', current_stylesheet_path)
#config.bind(',s', 'set content.user_stylesheets \'\' ')
#config.bind(',S', 'set content.user_stylesheets '+current_stylesheet_path)
# theming
c.colors.completion.fg = base05
c.colors.completion.odd.bg = base01
c.colors.completion.even.bg = base00
c.colors.completion.category.fg = base0A
c.colors.completion.category.bg = base00
c.colors.completion.category.border.top = base00
c.colors.completion.category.border.bottom = base00
c.colors.completion.item.selected.fg = base05
c.colors.completion.item.selected.bg = base02
c.colors.completion.item.selected.border.top = base02
c.colors.completion.item.selected.border.bottom = base02
c.colors.completion.item.selected.match.fg = base0B
c.colors.completion.match.fg = base0B
c.colors.completion.scrollbar.fg = base05
c.colors.completion.scrollbar.bg = base00
c.colors.contextmenu.disabled.bg = base01
c.colors.contextmenu.disabled.fg = base04
c.colors.contextmenu.menu.bg = base00
c.colors.contextmenu.menu.fg = base05
c.colors.contextmenu.selected.bg = base02
c.colors.contextmenu.selected.fg = base05
c.colors.downloads.bar.bg = base00
c.colors.downloads.start.fg = base00
c.colors.downloads.start.bg = base0D
c.colors.downloads.stop.fg = base00
c.colors.downloads.stop.bg = base0C
c.colors.downloads.error.fg = base08
c.colors.hints.fg = base00
c.colors.hints.bg = base0A
c.colors.hints.match.fg = base05
c.colors.keyhint.fg = base05
c.colors.keyhint.suffix.fg = base05
c.colors.keyhint.bg = base00
c.colors.messages.error.fg = base00
c.colors.messages.error.bg = base08
c.colors.messages.error.border = base08
c.colors.messages.warning.fg = base00
c.colors.messages.warning.bg = base0E
c.colors.messages.warning.border = base0E
c.colors.messages.info.fg = base05
c.colors.messages.info.bg = base00
c.colors.messages.info.border = base00
c.colors.prompts.fg = base05
c.colors.prompts.border = base00
c.colors.prompts.bg = base00
c.colors.prompts.selected.bg = base02
c.colors.prompts.selected.fg = base05
c.colors.statusbar.normal.fg = base0B
c.colors.statusbar.normal.bg = base00
c.colors.statusbar.insert.fg = base00
c.colors.statusbar.insert.bg = base0D
c.colors.statusbar.passthrough.fg = base00
c.colors.statusbar.passthrough.bg = base0C
c.colors.statusbar.private.fg = base00
c.colors.statusbar.private.bg = base01
c.colors.statusbar.command.fg = base05
c.colors.statusbar.command.bg = base00
c.colors.statusbar.command.private.fg = base05
c.colors.statusbar.command.private.bg = base00
c.colors.statusbar.caret.fg = base00
c.colors.statusbar.caret.bg = base0E
c.colors.statusbar.caret.selection.fg = base00
c.colors.statusbar.caret.selection.bg = base0D
c.colors.statusbar.progress.bg = base0D
c.colors.statusbar.url.fg = base05
c.colors.statusbar.url.error.fg = base08
c.colors.statusbar.url.hover.fg = base05
c.colors.statusbar.url.success.http.fg = base0C
c.colors.statusbar.url.success.https.fg = base0B
c.colors.statusbar.url.warn.fg = base0E
c.colors.tabs.bar.bg = base00
c.colors.tabs.indicator.start = base0D
c.colors.tabs.indicator.stop = base0C
c.colors.tabs.indicator.error = base08
c.colors.tabs.odd.fg = base05
c.colors.tabs.odd.bg = base01
c.colors.tabs.even.fg = base05
c.colors.tabs.even.bg = base00
c.colors.tabs.pinned.even.bg = base0C
c.colors.tabs.pinned.even.fg = base07
c.colors.tabs.pinned.odd.bg = base0B
c.colors.tabs.pinned.odd.fg = base07
c.colors.tabs.pinned.selected.even.bg = base02
c.colors.tabs.pinned.selected.even.fg = base05
c.colors.tabs.pinned.selected.odd.bg = base02
c.colors.tabs.pinned.selected.odd.fg = base05
c.colors.tabs.selected.odd.fg = base05
c.colors.tabs.selected.odd.bg = base02
c.colors.tabs.selected.even.fg = base05
c.colors.tabs.selected.even.bg = base02
font = "''+font+''"
c.fonts.default_family = font
c.fonts.default_size = '14pt'
c.fonts.web.family.standard = font
c.fonts.web.family.serif = font
c.fonts.web.family.sans_serif = font
c.fonts.web.family.fixed = font
c.fonts.web.family.fantasy = font
c.fonts.web.family.cursive = font
'';
home.file.".config/qutebrowser/containers".text = ''
Gamedev
Teaching
Youtube
'';
home.file.".config/qutebrowser/qute-home.html".text = generateHomepage "Default" font config;
home.file.".config/qutebrowser/logo.png".source = ./qutebrowser-logo.png;
home.file.".browser/Gamedev/config/qute-home.html".text = generateHomepage "Gamedev" font config;
home.file.".browser/Gamedev/config/logo.png".source = ./qutebrowser-logo.png;
home.file.".browser/Teaching/config/qute-home.html".text = generateHomepage "Teaching" font config;
home.file.".browser/Teaching/config/logo.png".source = ./qutebrowser-logo.png;
home.file.".browser/Youtube/config/qute-home.html".text = generateHomepage "Youtube" font config;
home.file.".browser/Youtube/config/logo.png".source = ./qutebrowser-logo.png;
xdg.mimeApps.defaultApplications = lib.mkIf (config.userSettings.browser == "qutebrowser" ) {
"text/html" = "org.qutebrowser.qutebrowser.desktop";
"x-scheme-handler/http" = "org.qutebrowser.qutebrowser.desktop";
"x-scheme-handler/https" = "org.qutebrowser.qutebrowser.desktop";
"x-scheme-handler/about" = "org.qutebrowser.qutebrowser.desktop";
"x-scheme-handler/unknown" = "org.qutebrowser.qutebrowser.desktop";
};
home.sessionVariables = lib.mkIf (config.userSettings.browser == "qutebrowser") {
DEFAULT_BROWSER = "${pkgs.qutebrowser}/bin/qutebrowser";
};
};
}

29
modules/user/default.nix Normal file
View File

@@ -0,0 +1,29 @@
{ lib, ... }:
with lib;
let
# Recursively constructs an attrset of a given folder, recursing on directories, value of attrs is the filetype
getDir = dir: mapAttrs
(file: type:
if type == "directory" then getDir "${dir}/${file}" else type
)
(builtins.readDir dir);
# Collects all files of a directory as a list of strings of paths
files = dir: collect isString (mapAttrsRecursive (path: type: concatStringsSep "/" path) (getDir dir));
# Filters out directories that don't end with .nix or are this file, also makes the strings absolute
importAll = dir: map
(file: ./. + "/${file}")
(filter
(file: hasSuffix ".nix" file && file != "default.nix" &&
! lib.hasPrefix "x/taffybar/" file &&
! lib.hasSuffix "-hm.nix" file)
(files dir));
in
{
imports = importAll ./.;
}

View File

@@ -0,0 +1,14 @@
{ config, lib, ...}:
{
options = {
userSettings.dmenuScripts = {
enable = lib.mkEnableOption "Enable collection of dmenu scripts";
dmenuCmd = lib.mkOption {
default = "rofi -show dmenu";
description = "dmenu command";
type = lib.types.str;
};
};
};
}

View File

@@ -0,0 +1,23 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.dmenuScripts;
dmenuCmd = cfg.dmenuCmd;
in {
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [ networkmanager_dmenu networkmanagerapplet ];
home.file.".config/networkmanager-dmenu/config.ini".text = ''
[dmenu]
dmenu_command = ''+dmenuCmd+''
compact = True
wifi_chars =
list_saved = True
[editor]
terminal = alacritty
# gui_if_available = <True or False> (Default: True)
'';
};
}

View File

@@ -0,0 +1,30 @@
{ config, lib, pkgs, ... }:
let
editor = config.userSettings.editor;
term = config.userSettings.terminal;
in {
options = {
userSettings.editor = lib.mkOption {
default = "emacs";
description = "Default editor";
type = lib.types.enum [ "emacs" ];
# TODO add more editors
#type = lib.types.enum [ "emacs" "vim" "nvim" "neovide" "nano" "micro" "vscodium" "kate" "pulsar" ];
};
userSettings.spawnEditor = lib.mkOption {
default = "";
description = "Command to spawn editor";
};
};
config = {
userSettings.emacs.enable = lib.mkIf (config.userSettings.editor == "emacs") true;
userSettings.spawnEditor = lib.mkMerge [
(lib.mkIf (editor == "emacs") "emacsclient -c -a 'emacs'")
(lib.mkIf (editor == "neovide") "neovide -- --listen /tmp/nvimsocket")
(lib.mkIf (builtins.elem editor [ "vim" "nvim" "nano" "micro" ]) ("exec " + term + " -e " + editor))
(lib.mkIf (!(builtins.elem editor [ "emacs" "vim" "nvim" "neovide" "nano" "micro"])) editor)
];
};
}

View File

@@ -0,0 +1,74 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.emacs;
in {
options = {
userSettings.emacs = {
enable = lib.mkEnableOption "Enable emacs";
};
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
(pkgs.emacsWithPackagesFromUsePackage {
config = ./init.el;
package = pkgs.emacs-pgtk;
alwaysEnsure = false;
extraEmacsPackages = epkgs: with epkgs; [
org-modern olivetti
command-log-mode
vertico corfu hotfuzz orderless
evil evil-collection evil-snipe evil-owl evil-vimish-fold
dashboard doom-themes doom-modeline
nerd-icons nerd-icons-dired nerd-icons-corfu
nerd-icons-ibuffer nerd-icons-completion
yasnippet shackle
projectile treemacs treemacs-projectile
treemacs-evil treemacs-nerd-icons
treesit-grammars.with-all-grammars
git-timemachine wgrep
magit magit-file-icons magit-todos
undo-fu undo-fu-session
org-roam org-node org-node-fakeroam
vterm vterm-toggle sudo-edit
direnv
gdscript-mode
nix-mode
python python-mode
lsp-mode flycheck lsp-ui lsp-treemacs
# fix ultra-scroll
(epkgs.callPackage (
{ lib, fetchurl, trivialBuild }:
trivialBuild {
pname = "ultra-scroll";
version = "0.2.0";
src = fetchGit {
url = "https://github.com/jdtsmith/ultra-scroll.git";
rev = "64ad7be02e11317576498dabb15c92cf31e2c04c";
ref = "main";
};
meta = with lib; {
description = "scroll Emacs like lightning";
homepage = "https://github.com/jdtsmith/ultra-scroll";
license = licenses.gpl3;
platforms = platforms.all;
};
}
) {})
];
})
fira-code
nerd-fonts.fira-code
nil
];
home.file.".config/emacs/init.el".source = ./init.el;
home.file.".config/emacs/themes/doom-stylix-theme.el".source = config.lib.stylix.colors {
template = builtins.readFile ./lib/doom-stylix-theme.el.mustache;
extension = ".el";
};
};
}

921
modules/user/emacs/init.el Normal file
View File

@@ -0,0 +1,921 @@
;;; init.el --- librephoenix's emacs config -*- lexical-binding: t; no-byte-compile: t; -*-
;;
;; Author: Emmet K <https://gitlab.com/librephoenix>
;; Maintainer: Emmet K <https://gitlab.com/librephoenix>
;; Source: https://github.com/librephoenix/nixos-config
;; Source: https://gitlab.com/librephoenix/nixos-config
;; Source: https://codeberg.org/librephoenix/nixos-config
;;
;;; Commentary:
;;
;; LibrePhoenix's Emacs config.
;;
;;; Code:
;; organize everything with use-package
(require 'use-package)
;; use-package-ception
(use-package use-package
:defer t
:custom
(use-package-always-ensure nil)
(usepackage-always-defer t))
(use-package emacs
:defer t
:config
;; No startup screen
(setq inhibit-startup-message t)
;; Transparent background
(set-frame-parameter nil 'alpha-background 85)
(add-to-list 'default-frame-alist '(alpha-background . 85))
(add-to-list 'default-frame-alist '(inhibit-double-buffering . t))
;; I want declarative config, no custom
(setq custom-file "/dev/null")
;; Disable the menu bar
(menu-bar-mode -1)
;; Disable visible scrollbar
(scroll-bar-mode -1)
;; Disable the toolbar
(tool-bar-mode -1)
;; Disable tooltips
(tooltip-mode -1)
;; Breathing room
(set-fringe-mode 10)
;; No blinking
(blink-cursor-mode 0)
;; Highlight current line
(global-hl-line-mode)
;; Bigger text
(set-face-attribute 'default nil :height 150)
;; Add frame borders and window dividers
(modify-all-frames-parameters
'((right-divider-width . 20)
(left-divider-width . 20)
(internal-border-width . 20)))
(set-face-background 'fringe (face-attribute 'default :background))
;; Fira and glyphs
(when (window-system)
(set-frame-font "FiraCode Nerd Font"))
(let ((alist '((33 . ".\\(?:\\(?:==\\|!!\\)\\|[!=]\\)")
(35 . ".\\(?:###\\|##\\|_(\\|[#(?[_{]\\)")
(36 . ".\\(?:>\\)")
(37 . ".\\(?:\\(?:%%\\)\\|%\\)")
(38 . ".\\(?:\\(?:&&\\)\\|&\\)")
(42 . ".\\(?:\\(?:\\*\\*/\\)\\|\\(?:\\*[*/]\\)\\|[*/>]\\)")
(43 . ".\\(?:\\(?:\\+\\+\\)\\|[+>]\\)")
(45 . ".\\(?:\\(?:-[>-]\\|<<\\|>>\\)\\|[<>}~-]\\)")
(46 . ".\\(?:\\(?:\\.[.<]\\)\\|[.=-]\\)")
(47 . ".\\(?:\\(?:\\*\\*\\|//\\|==\\)\\|[*/=>]\\)")
(48 . ".\\(?:x[a-zA-Z]\\)")
(58 . ".\\(?:::\\|[:=]\\)")
(59 . ".\\(?:;;\\|;\\)")
(60 . ".\\(?:\\(?:!--\\)\\|\\(?:~~\\|->\\|\\$>\\|\\*>\\|\\+>\\|--\\|<[<=-]\\|=[<=>]\\||>\\)\\|[*$+~/<=>|-]\\)")
(61 . ".\\(?:\\(?:/=\\|:=\\|<<\\|=[=>]\\|>>\\)\\|[<=>~]\\)")
(62 . ".\\(?:\\(?:=>\\|>[=>-]\\)\\|[=>-]\\)")
(63 . ".\\(?:\\(\\?\\?\\)\\|[:=?]\\)")
(91 . ".\\(?:]\\)")
(92 . ".\\(?:\\(?:\\\\\\\\\\)\\|\\\\\\)")
(94 . ".\\(?:=\\)")
(119 . ".\\(?:ww\\)")
(123 . ".\\(?:-\\)")
(124 . ".\\(?:\\(?:|[=|]\\)\\|[=>|]\\)")
(126 . ".\\(?:~>\\|~~\\|[>=@~-]\\)")
)))
(dolist (char-regexp alist)
(set-char-table-range composition-function-table (car char-regexp)
`([,(cdr char-regexp) 0 font-shape-gstring]))))
(dashboard-setup-startup-hook)
;; Garbage collection threshold
(setq gc-cons-threshold 120000)
(add-hook 'focus-out-hook 'garbage-collect)
;; Auto revert
(global-auto-revert-mode 1)
(setq auto-revert-use-notify t
revert-without-query t)
;; camelCase and PascalCase
(global-subword-mode 1)
;; ripgrep as grep
(setq grep-command "rg -nS --no-heading "
grep-use-null-device nil)
;; "y" or "n" instead of "yes" or "no"
(setq use-short-answers t)
;; Enable indentation+completion using TAB
(setq tab-always-indent 'complete)
;; Make ESC quit prompts
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
;; Line numbers
(setq display-line-numbers-type t
line-move-visual t)
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
;; Fix stupid backup confirmations
(setq backup-directory-alist '("." "~/.emacs.d/cache/backups"))
(setq tramp-auto-save-directory "/dev/null"))
;; Packages
(use-package line-wrapping-and-numbers
:load-path "./lib"
:after (org markdown git-timemachine))
(use-package ultra-scroll
:init
(setq scroll-step 1
scroll-margin 0
scroll-conservatively 101
scroll-preserve-screen-position nil
redisplay-skip-fontification-on-input t)
(pixel-scroll-precision-mode 1)
:config
(ultra-scroll-mode 1))
;; Magit
(use-package magit
:commands (magit magit-status)
:config
(setq magit-display-buffer-function 'magit-display-buffer-fullframe-status-v1)
(setq magit-bury-buffer-function 'magit-restore-window-configuration)
(define-key magit-mode-map (kbd "SPC") nil)
(add-hook 'git-commit-mode-hook 'evil-insert-state))
(use-package git-timemachine)
(use-package magit-file-icons
:after (magit nerd-icons)
:init
(magit-file-icons-mode 1)
:custom
(magit-file-icons-enable-diff-file-section-icons t)
(magit-file-icons-enable-untracked-icons t)
(magit-file-icons-enable-diffstat-icons t))
(use-package magit-todos
:after (magit)
:config
(setq magit-todos-keywords-list '("TODO" "FIXME" "HACK" "REVIEW" "DEPRECATED" "BUG"))
(setq magit-todos-keyword-suffix "\\(?:[([][^])]+[])]\\)?.")
(magit-todos-mode 1))
;; Projectile
(use-package projectile
:init
(projectile-mode +1))
;; Being able to undo is nice...
(use-package undo-fu
:commands (evil-undo evil-redo))
(use-package undo-fu-session
:after undo-fu
:config
(global-undo-fu-session-mode))
(use-package dired
:custom
(dired-listing-switches "-aBhl --group-directories-first")
(dired-kill-when-opening-new-dired-buffer t))
(use-package dired-x
:after (dired)
:config
(setq dired-omit-files (rx (seq bol ".")))
(setq dired-show-dotfiles nil)
(defun apply-dired-omit ()
(if (not dired-show-dotfiles)
(dired-omit-mode 1)))
(add-hook 'dired-mode-hook 'apply-dired-omit))
;; Muahahahahaha..
(use-package evil
:custom
(evil-want-keybinding nil)
(evil-respect-visual-line-mode t)
(evil-undo-system 'undo-fu)
:config
(evil-set-leader nil (kbd "C-SPC"))
(evil-set-leader 'normal (kbd "SPC"))
(evil-set-leader 'motion (kbd "SPC"))
(setq evil-respect-visual-line-mode t)
(setq evil-undo-system 'undo-fu)
(setq evil-redo-function 'undo-fu-only-redo)
(define-key evil-motion-state-map (kbd "RET") nil)
(evil-mode 1))
(use-package evil-collection
:after (evil)
:custom
(evil-want-keybinding t)
:config
(evil-collection-init)
;; Visual mode keybinds
(evil-define-key 'motion 'global (kbd "j") 'evil-next-visual-line)
(evil-define-key 'motion 'global (kbd "k") 'evil-previous-visual-line)
;; File and buffer keybinds
(evil-define-key 'motion 'global (kbd "<leader>.") 'find-file)
(evil-define-key 'motion 'global (kbd "<leader>bi") 'ibuffer)
(evil-define-key 'motion 'global (kbd "<leader>bd") 'evil-delete-buffer)
(evil-define-key 'motion 'global (kbd "<leader>bn") 'next-buffer)
(evil-define-key 'motion 'global (kbd "<leader>bp") 'previous-buffer)
;; based on http://emacsredux.com/blog/2013/04/03/delete-file-and-buffer/
(defun delete-file-and-buffer ()
"Kill the current buffer and deletes the file it is visiting."
(interactive)
(let ((filename (buffer-file-name)))
(if filename
(if (y-or-n-p (concat "Do you really want to delete file " filename " ?"))
(progn
(delete-file filename)
(message "Deleted file %s." filename)
(kill-buffer)))
(message "Not a file visiting buffer!"))))
(evil-define-key 'motion 'global (kbd "<leader>fd") 'delete-file-and-buffer)
(evil-define-key 'motion 'global (kbd "<leader>fr") 'rename-visited-file)
(evil-define-key 'motion 'global (kbd "<leader>od") 'dired-jump)
(defun toggle-dired-omit-mode ()
"Toggle dired-omit-mode."
(interactive)
(if dired-omit-mode
(progn (dired-omit-mode 0) (setq dired-show-dotfiles t))
(progn (dired-omit-mode 1) (setq dired-show-dotfiles nil))))
(evil-define-key 'normal dired-mode-map (kbd "H") 'toggle-dired-omit-mode)
;; Project keybinds
(evil-define-key 'motion 'global (kbd "<leader>pp") 'projectile-switch-project)
(evil-define-key 'motion 'global (kbd "<leader>pf") 'projectile-find-file)
(evil-define-key 'motion 'global (kbd "<leader>pa") 'projectile-add-known-project)
(evil-define-key 'motion 'global (kbd "<leader>/") 'projectile-grep)
(evil-define-key 'motion 'global (kbd "<leader>gg") 'magit-status)
(evil-define-key 'motion 'global (kbd "<leader>gt") 'git-timemachine-toggle)
;; Describe keybinds
(evil-define-key 'motion 'global (kbd "<leader>hv") 'describe-variable)
(evil-define-key 'motion 'global (kbd "<leader>hf") 'describe-function)
(evil-define-key 'motion 'global (kbd "<leader>hk") 'describe-key)
(evil-define-key 'motion 'global (kbd "<leader>hF") 'describe-face)
;; Window keybinds
(evil-define-key 'motion 'global (kbd "<leader>ws") 'evil-window-split)
(evil-define-key 'motion 'global (kbd "<leader>wv") 'evil-window-vsplit)
(defun evil-window-split-follow ()
(interactive)
(let ((evil-split-window-below t))
(evil-window-split)))
(defun evil-window-vsplit-follow ()
(interactive)
(let ((evil-vsplit-window-right t))
(evil-window-vsplit)))
(evil-define-key 'motion 'global (kbd "<leader>wS") 'evil-window-split-follow)
(evil-define-key 'motion 'global (kbd "<leader>wV") 'evil-window-vsplit-follow)
(evil-define-key 'motion 'global (kbd "<leader>wd") 'evil-window-delete)
(evil-define-key 'motion 'global (kbd "<leader>wj") 'evil-window-down)
(evil-define-key 'motion 'global (kbd "<leader>wk") 'evil-window-up)
(evil-define-key 'motion 'global (kbd "<leader>wh") 'evil-window-left)
(evil-define-key 'motion 'global (kbd "<leader>wl") 'evil-window-right)
(evil-define-key 'insert org-mode-map (kbd "<C-return>") '+org/insert-item-below)
(evil-define-key 'insert org-mode-map (kbd "<C-S-return>") '+org/insert-item-above)
(evil-define-key 'motion org-mode-map (kbd "<C-return>") '+org/insert-item-below)
(evil-define-key 'motion org-mode-map (kbd "<C-S-return>") '+org/insert-item-above)
(evil-define-key 'insert org-mode-map (kbd "<tab>") 'org-demote-subtree)
(evil-define-key 'insert org-mode-map (kbd "<backtab>") 'org-promote-subtree)
(evil-define-key 'motion org-mode-map (kbd "<leader>mll") 'org-insert-link)
(evil-define-key 'motion org-mode-map (kbd "<leader>mt") 'org-todo)
(global-set-key (kbd "C-j") 'evil-window-down)
(global-set-key (kbd "C-k") 'evil-window-up)
(global-set-key (kbd "C-h") 'evil-window-left)
(global-set-key (kbd "C-l") 'evil-window-right))
(use-package sudo-edit
:after (evil)
:custom
(sudo-edit-local-method "doas")
(auth-sources '("~/.authinfo.gpg"))
(auth-source-save-behavior "ask")
:config
(sudo-edit-indicator-mode)
(evil-define-key 'normal 'global (kbd "<leader>fU") 'sudo-edit)
(evil-define-key 'normal 'global (kbd "<leader>fu") 'sudo-edit-find-file))
(use-package flycheck
:init
(global-flycheck-mode))
(use-package treemacs
:config
(defun treemacs-display-current-project-exclusively-silently ()
"Display current project exclusively in treemacs without switching to treemacs buffer."
(let ((buffer (current-buffer)))
(treemacs-add-and-display-current-project-exclusively)
(switch-to-buffer buffer)))
(add-hook 'projectile-after-switch-project-hook 'treemacs-display-current-project-exclusively-silently))
(use-package treemacs-evil
:after (treemacs))
(use-package lsp-mode
:custom
(lsp-keymap-prefix (kbd "SPC l"))
(setq lsp-completion-provider :none)
:hook ((gdscript-mode . lsp-deferred)
(gdscript-ts-mode . lsp-deferred))
:commands lsp-deferred)
(use-package lsp-ui :commands lsp-ui-mode)
(use-package lsp-treemacs :commands lsp-treemacs-errors-list)
(use-package treesit
:config
(treesit-major-mode-setup))
;; direnv
(use-package direnv
:init
(direnv-mode))
;; command-log-mode
(use-package command-log-mode)
;; Enable corfu
(use-package corfu
:custom
(corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
;; (corfu-preview-current nil) ;; Disable current candidate preview
(corfu-preselect 'prompt) ;; Preselect the prompt
(corfu-on-exact-match 'insert) ;; Configure handling of exact matches
(corfu-auto t) ;; auto complete
(corfu-auto-delay 0.5) ;; wait half a second though
(corfu-auto-prefix 3) ;; also only for words 3 or more
(defun corfu-lsp-setup ()
(setq-local completion-styles '(orderless flex hotfuzz)
completion-category-defaults nil))
(add-hook 'lsp-mode-hook #'corfu-lsp-setup)
:init
(global-corfu-mode 1))
;; Enable vertico
(use-package vertico
:custom
(vertico-scroll-margin 0) ;; Different scroll margin
(vertico-count 20) ;; Show more candidates
(vertico-resize nil) ;; Grow and shrink the Vertico minibuffer
(vertico-cycle t) ;; Enable cycling for `vertico-next/previous'
:init
(vertico-mode))
;; I am a nerd
(use-package nerd-icons)
(use-package treemacs-nerd-icons
:after (nerd-icons treemacs)
:config
(treemacs-load-theme "nerd-icons"))
(use-package nerd-icons-dired
:after (nerd-icons dired)
:config
(add-hook 'dired-mode-hook #'nerd-icons-dired-mode))
(use-package nerd-icons-completion
:after (nerd-icons)
:config
(nerd-icons-completion-mode))
(use-package nerd-icons-corfu
:after (nerd-icons corfu)
:config
(add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))
;; Theme and modeline
(use-package doom-themes
:after (org)
:config
(setq doom-themes-enable-bold t
doom-themes-enable-italic t
custom-theme-directory "~/.config/emacs/themes")
(load-theme 'doom-stylix t)
;; Heading styles
(set-face-attribute 'outline-1 nil :height 195 :foreground (nth 1 (nth 14 doom-themes--colors)))
(set-face-attribute 'outline-2 nil :height 188 :foreground (nth 1 (nth 15 doom-themes--colors)))
(set-face-attribute 'outline-3 nil :height 180 :foreground (nth 1 (nth 19 doom-themes--colors)))
(set-face-attribute 'outline-4 nil :height 173 :foreground (nth 1 (nth 23 doom-themes--colors)))
(set-face-attribute 'outline-5 nil :height 173 :foreground (nth 1 (nth 24 doom-themes--colors)))
(set-face-attribute 'outline-6 nil :height 165 :foreground (nth 1 (nth 16 doom-themes--colors)))
(set-face-attribute 'outline-7 nil :height 160 :foreground (nth 1 (nth 18 doom-themes--colors)))
(set-face-attribute 'outline-8 nil :height 155 :foreground (nth 1 (nth 11 doom-themes--colors))))
(use-package doom-modeline
:init (doom-modeline-mode 1)
:custom ((doom-modeline-height 15)))
;; Dashboard
(use-package dashboard
:after (nerd-icons)
:config
(setq dashboard-banner-logo-title "Welcome to Nix Emacs")
(setq dashboard-startup-banner 2)
(setq dashboard-set-heading-icons t)
(setq dashboard-set-file-icons t)
(setq dashboard-set-navigator t)
(setq dashboard-items '())
(setq dashboard-center-content t)
(setq dashboard-icon-type 'nerd-icons) ;; use `nerd-icons' package
(setq dashboard-footer-messages '("Here to do customizing, or actual work?"
"M-x insert-inspiring-message"
"My software never has bugs. It just develops random features."
"Dad, what are clouds made of? Linux servers, mostly."
"There is no place like ~"
"~ sweet ~"
"sudo chown -R us ./allyourbase"
"Ill tell you a DNS joke but it could take 24 hours for everyone to get it."
"I'd tell you a UDP joke, but you might not get it."
"I'll tell you a TCP joke. Do you want to hear it?"))
(setq dashboard-footer-icon
(nerd-icons-codicon "nf-cod-vm"
:height 1.0
:v-adjust 0
:face 'font-lock-keyword-face))
(setq initial-buffer-choice (lambda () (get-buffer-create dashboard-buffer-name))))
;; Window management with shackle
;; https://github.com/wasamasa/shackle
(use-package shackle
:config
(progn
(setq shackle-lighter "")
(setq shackle-select-reused-windows nil) ; default nil
(setq shackle-default-alignment 'below) ; default below
(setq shackle-default-size 0.4) ; default 0.5
(setq shackle-rules
;; CONDITION(:regexp) :select :inhibit-window-quit :size+:align|:other :same|:popup
'((compilation-mode :select nil )
("*undo-tree*" :size 0.25 :align right)
("*eshell*" :select t :other t )
("*Shell Command Output*" :select nil )
("\\*Async Shell.*\\*" :regexp t :ignore t )
(occur-mode :select nil :align t )
("*Help*" :select t :inhibit-window-quit nil :size 0.3 :align below )
("*Completions*" :size 0.3 :align t )
("*Messages*" :select nil :inhibit-window-quit t :other t )
("\\*[Wo]*Man.*\\*" :regexp t :select t :inhibit-window-quit t :other t )
("\\*poporg.*\\*" :regexp t :select t :other t )
("\\`\\*helm.*?\\*\\'" :regexp t :size 0.3 :align t )
("*Calendar*" :select t :size 0.3 :align below)
("*info*" :select t :inhibit-window-quit t :popup t)
("*Org todo*" :select t :inhibit-window-quit t :same t :popup t)
(magit-status-mode :select t :inhibit-window-quit t :same t)
(magit-log-mode :select t :inhibit-window-quit t :same t)
))
(shackle-mode 1))
(add-to-list 'display-buffer-alist '("\\*Org todo\\*"
(display-buffer-at-bottom)
(side . bottom)
(slot . 4)
(window-height . shrink-window-if-larger-than-buffer)
(dedicated . t))))
;; Completion
(use-package hotfuzz)
(use-package orderless)
(setq completion-styles '(orderless flex hotfuzz))
(use-package org
:config
;; Better cycling
;; https://github.com/doomemacs/doomemacs/blob/master/modules/lang/org/autoload/org.el
(defun +org-cycle-only-current-subtree-h (&optional arg)
"Toggle the local fold at the point, and no deeper.
`org-cycle's standard behavior is to cycle between three levels: collapsed,
subtree and whole document. This is slow, especially in larger org buffer. Most
of the time I just want to peek into the current subtree -- at most, expand
*only* the current subtree.
All my (performant) foldings needs are met between this and `org-show-subtree'
(on zO for evil users), and `org-cycle' on shift-TAB if I need it."
(interactive "P")
(unless (or (eq this-command 'org-shifttab)
(and (bound-and-true-p org-cdlatex-mode)
(or (org-inside-LaTeX-fragment-p)
(org-inside-latex-macro-p))))
(save-excursion
(org-beginning-of-line)
(let (invisible-p)
(when (and (org-at-heading-p)
(or org-cycle-open-archived-trees
(not (member org-archive-tag (org-get-tags))))
(or (not arg)
(setq invisible-p
(memq (get-char-property (line-end-position)
'invisible)
'(outline org-fold-outline)))))
(unless invisible-p
(setq org-cycle-subtree-status 'subtree))
(org-cycle-internal-local)
t)))))
(defalias #'+org/toggle-fold #'+org-cycle-only-current-subtree-h)
(add-hook 'org-mode-hook 'org-indent-mode)
(add-hook 'org-tab-first-hook
;; Only fold the current tree, rather than recursively
#'+org-cycle-only-current-subtree-h)
(setq org-return-follows-link t)
(setf (cdr (assoc 'file org-link-frame-setup)) 'find-file)
(setq org-todo-keywords '((sequence "TODO(t)" "WAITING(w)" "|" "DONE(d)" "CANCELED(c)" "NO(n)")))
(setq org-use-fast-todo-selection 'prefix)
(setq org-M-RET-may-split-line nil
;; insert new headings after current subtree rather than inside it
org-insert-heading-respect-content t)
(defun +org--insert-item (direction)
(let ((context (org-element-lineage
(org-element-context)
'(table table-row headline inlinetask item plain-list)
t)))
(pcase (org-element-type context)
;; Add a new list item (carrying over checkboxes if necessary)
((or `item `plain-list)
(let ((orig-point (point)))
;; Position determines where org-insert-todo-heading and `org-insert-item'
;; insert the new list item.
(if (eq direction 'above)
(org-beginning-of-item)
(end-of-line))
(let* ((ctx-item? (eq 'item (org-element-type context)))
(ctx-cb (org-element-property :contents-begin context))
;; Hack to handle edge case where the point is at the
;; beginning of the first item
(beginning-of-list? (and (not ctx-item?)
(= ctx-cb orig-point)))
(item-context (if beginning-of-list?
(org-element-context)
context))
;; Horrible hack to handle edge case where the
;; line of the bullet is empty
(ictx-cb (org-element-property :contents-begin item-context))
(empty? (and (eq direction 'below)
;; in case contents-begin is nil, or contents-begin
;; equals the position end of the line, the item is
;; empty
(or (not ictx-cb)
(= ictx-cb
(1+ (point))))))
(pre-insert-point (point)))
;; Insert dummy content, so that `org-insert-item'
;; inserts content below this item
(when empty?
(insert "<EFBFBD>"))
(org-insert-item (org-element-property :checkbox context))
;; Remove dummy content
(when empty?
(delete-region pre-insert-point (1+ pre-insert-point))))))
;; Add a new table row
((or `table `table-row)
(pcase direction
('below (save-excursion (org-table-insert-row t))
(org-table-next-row))
('above (save-excursion (org-shiftmetadown))
(+org/table-previous-row))))
;; Otherwise, add a new heading, carrying over any todo state, if
;; necessary.
(_
(let ((level (or (org-current-level) 1)))
;; I intentionally avoid `org-insert-heading' and the like because they
;; impose unpredictable whitespace rules depending on the cursor
;; position. It's simpler to express this command's responsibility at a
;; lower level than work around all the quirks in org's API.
(pcase direction
(`below
(let (org-insert-heading-respect-content)
(goto-char (line-end-position))
(org-end-of-subtree)
(insert "\n" (make-string level ?*) " ")))
(`above
(org-back-to-heading)
(insert (make-string level ?*) " ")
(save-excursion (insert "\n"))))
(run-hooks 'org-insert-heading-hook)
(when-let* ((todo-keyword (org-element-property :todo-keyword context))
(todo-type (org-element-property :todo-type context)))
(org-todo
(cond ((eq todo-type 'done)
;; Doesn't make sense to create more "DONE" headings
(car (+org-get-todo-keywords-for todo-keyword)))
(todo-keyword)
('todo)))))))
(when (org-invisible-p)
(org-show-hidden-entry))
(when (and (bound-and-true-p evil-local-mode)
(not (evil-emacs-state-p)))
(evil-insert 1))))
;;; Commands
;;;###autoload
(defun +org/return ()
"Call `org-return' then indent (if `electric-indent-mode' is on)."
(interactive)
(org-return electric-indent-mode))
;;;###autoload
(defun +org/dwim-at-point (&optional arg)
"Do-what-I-mean at point.
If on a:
- checkbox list item or todo heading: toggle it.
- citation: follow it
- headline: cycle ARCHIVE subtrees, toggle latex fragments and inline images in
subtree; update statistics cookies/checkboxes and ToCs.
- clock: update its time.
- footnote reference: jump to the footnote's definition
- footnote definition: jump to the first reference of this footnote
- timestamp: open an agenda view for the time-stamp date/range at point.
- table-row or a TBLFM: recalculate the table's formulas
- table-cell: clear it and go into insert mode. If this is a formula cell,
recaluclate it instead.
- babel-call: execute the source block
- statistics-cookie: update it.
- src block: execute it
- latex fragment: toggle it.
- link: follow it
- otherwise, refresh all inline images in current tree."
(interactive "P")
(if (button-at (point))
(call-interactively #'push-button)
(let* ((context (org-element-context))
(type (org-element-type context)))
;; skip over unimportant contexts
(while (and context (memq type '(verbatim code bold italic underline strike-through subscript superscript)))
(setq context (org-element-property :parent context)
type (org-element-type context)))
(pcase type
((or `citation `citation-reference)
(org-cite-follow context arg))
(`headline
(cond ((memq (bound-and-true-p org-goto-map)
(current-active-maps))
(org-goto-ret))
((and (fboundp 'toc-org-insert-toc)
(member "TOC" (org-get-tags)))
(toc-org-insert-toc)
(message "Updating table of contents"))
((string= "ARCHIVE" (car-safe (org-get-tags)))
(org-force-cycle-archived))
((or (org-element-property :todo-type context)
(org-element-property :scheduled context))
(org-todo
(if (eq (org-element-property :todo-type context) 'done)
(or (car (+org-get-todo-keywords-for (org-element-property :todo-keyword context)))
'todo)
'done))))
;; Update any metadata or inline previews in this subtree
(org-update-checkbox-count)
(org-update-parent-todo-statistics)
(when (and (fboundp 'toc-org-insert-toc)
(member "TOC" (org-get-tags)))
(toc-org-insert-toc)
(message "Updating table of contents"))
(let* ((beg (if (org-before-first-heading-p)
(line-beginning-position)
(save-excursion (org-back-to-heading) (point))))
(end (if (org-before-first-heading-p)
(line-end-position)
(save-excursion (org-end-of-subtree) (point))))
(overlays (ignore-errors (overlays-in beg end)))
(latex-overlays
(cl-find-if (lambda (o) (eq (overlay-get o 'org-overlay-type) 'org-latex-overlay))
overlays))
(image-overlays
(cl-find-if (lambda (o) (overlay-get o 'org-image-overlay))
overlays)))
(+org--toggle-inline-images-in-subtree beg end)
(if (or image-overlays latex-overlays)
(org-clear-latex-preview beg end)
(org--latex-preview-region beg end))))
(`clock (org-clock-update-time-maybe))
(`footnote-reference
(org-footnote-goto-definition (org-element-property :label context)))
(`footnote-definition
(org-footnote-goto-previous-reference (org-element-property :label context)))
((or `planning `timestamp)
(org-follow-timestamp-link))
((or `table `table-row)
(if (org-at-TBLFM-p)
(org-table-calc-current-TBLFM)
(ignore-errors
(save-excursion
(goto-char (org-element-property :contents-begin context))
(org-call-with-arg 'org-table-recalculate (or arg t))))))
(`table-cell
(org-table-blank-field)
(org-table-recalculate arg)
(when (and (string-empty-p (string-trim (org-table-get-field)))
(bound-and-true-p evil-local-mode))
(evil-change-state 'insert)))
(`babel-call
(org-babel-lob-execute-maybe))
(`statistics-cookie
(save-excursion (org-update-statistics-cookies arg)))
((or `src-block `inline-src-block)
(org-babel-execute-src-block arg))
((or `latex-fragment `latex-environment)
(org-latex-preview arg))
(`link
(let* ((lineage (org-element-lineage context '(link) t))
(path (org-element-property :path lineage)))
(if (or (equal (org-element-property :type lineage) "img")
(and path (image-type-from-file-name path)))
(+org--toggle-inline-images-in-subtree
(org-element-property :begin lineage)
(org-element-property :end lineage))
(org-open-at-point arg))))
((guard (org-element-property :checkbox (org-element-lineage context '(item) t)))
(org-toggle-checkbox))
(`paragraph
(+org--toggle-inline-images-in-subtree))
(_
(if (or (org-in-regexp org-ts-regexp-both nil t)
(org-in-regexp org-tsr-regexp-both nil t)
(org-in-regexp org-link-any-re nil t))
(call-interactively #'org-open-at-point)
(+org--toggle-inline-images-in-subtree
(org-element-property :begin context)
(org-element-property :end context))))))))
;;;###autoload
(defun +org/shift-return (&optional arg)
"Insert a literal newline, or dwim in tables.
Executes `org-table-copy-down' if in table."
(interactive "p")
(if (org-at-table-p)
(org-table-copy-down arg)
(org-return nil arg)))
;;;###autoload
(defun +org/insert-item-below (count)
"Inserts a new heading, table cell or item below the current one."
(interactive "p")
(dotimes (_ count) (+org--insert-item 'below)))
;;;###autoload
(defun +org/insert-item-above (count)
"Inserts a new heading, table cell or item above the current one."
(interactive "p")
(dotimes (_ count) (+org--insert-item 'above))))
(use-package org-roam
:after (org)
:config
(setq org-roam-directory (file-truename "~/Notes"))
(setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag)))
(org-roam-db-autosync-mode -1)
(setq org-roam-capture-templates '(("d" "default" plain "%?" :unnarrowed t :target (file+head
"${slug}-%<%Y%m%d%H%M%S>.org" "#+title: ${title}"))))
(evil-define-key 'motion 'global (kbd "<leader>N.") 'org-roam-node-find)
(evil-define-key 'motion 'global (kbd "<leader>Nr") 'org-roam-refile)
(evil-define-key 'motion 'global (kbd "<leader>Nb") 'org-roam-buffer-toggle)
(evil-define-key 'motion 'global (kbd "<leader>nrdd") 'org-roam-dailies-goto-date)
(evil-define-key 'motion 'global (kbd "<leader>nrdt") 'org-roam-dailies-goto-today)
(evil-define-key 'motion 'global (kbd "<leader>nrdn") 'org-roam-dailies-goto-next-note)
(evil-define-key 'motion 'global (kbd "<leader>nrdp") 'org-roam-dailies-goto-previous-note))
(use-package org-node
:after (org org-roam)
:config
(setq org-node-extra-id-dirs '("~/Notes/"))
(setq org-id-locations-file "~/Notes/.org-id-locations")
(org-node-cache-mode)
(org-node-complete-at-point-mode)
(setq org-roam-completion-everywhere nil)
(evil-define-key 'motion 'global (kbd "<leader>Ni") 'org-node-insert-link)
(evil-define-key 'motion 'global (kbd "<leader>NR") 'org-node-rewrite-links-ask))
(use-package org-node-fakeroam
:after (org org-node org-roam)
:defer t
:config
(setq org-node-creation-fn #'org-node-fakeroam-new-via-roam-capture)
(setq org-node-slug-fn #'org-node-fakeroam-slugify-via-roam)
(setq org-node-datestamp-format "%Y%m%d%H%M%S-")
(setq org-roam-db-update-on-save nil)
(setq org-roam-link-auto-replace nil)
(org-node-fakeroam-fast-render-mode)
(setq org-node-fakeroam-fast-render-persist t)
(org-node-fakeroam-redisplay-mode)
(org-node-fakeroam-jit-backlinks-mode)
(org-node-fakeroam-db-feed-mode))
(use-package wgrep
:after (org-node))
(use-package org-modern
:mode ("\\.org\\'" . org-mode)
:custom
(org-auto-align-tags nil)
(org-tags-column 0)
(org-catch-invisible-edits 'show-and-error)
(org-special-ctrl-a/e t)
(org-insert-heading-respect-content t)
(org-hide-emphasis-markers t)
(org-pretty-entities t)
(org-ellipsis "...")
(org-modern-star 'replace)
:config
(set-face-attribute 'org-ellipsis nil :inherit 'default :box nil)
:init
(global-org-modern-mode))
;; Olivetti
(use-package olivetti
:commands (org-mode markdown-mode)
:custom
(olivetti-style 'fancy)
(olivetti-margin-width 100)
:config
(setq-default olivetti-body-width 100)
(add-hook 'org-mode-hook 'olivetti-mode))
(evil-collection-define-key 'normal 'dired-mode-map
"h" 'dired-up-directory
"l" 'dired-find-file
" " 'nil)
(use-package vterm
:after evil)
(use-package vterm-toggle
:after vterm
:config
(setq vterm-toggle-fullscreen-p nil)
(setq vterm-toggle-cd-auto-create-buffer nil)
(add-to-list 'display-buffer-alist
'((lambda (buffer-or-name _)
(let ((buffer (get-buffer buffer-or-name)))
(with-current-buffer buffer
(or (equal major-mode 'vterm-mode)
(string-prefix-p vterm-buffer-name (buffer-name buffer))))))
(display-buffer-reuse-window display-buffer-at-bottom)
;;(display-buffer-reuse-window display-buffer-in-direction)
;;display-buffer-in-direction/direction/dedicated is added in emacs27
;;(direction . bottom)
;;(dedicated . t) ;dedicated is supported in emacs27
(reusable-frames . visible)
(window-height . 0.4)))
(defun vterm-toggle-cd-force ()
(interactive)
(vterm-toggle-cd-show)
(vterm-toggle-insert-cd)
)
(evil-define-key 'motion 'global (kbd "M-z") 'vterm-toggle-cd-force)
(evil-define-key 'insert 'global (kbd "M-z") 'vterm-toggle-cd-force)
(evil-define-key 'motion vterm-mode-map (kbd "M-z") 'vterm-toggle-hide)
(evil-define-key 'insert vterm-mode-map (kbd "M-z") 'vterm-toggle-hide)
)
(provide 'init)
;;; init.el ends here

View File

@@ -0,0 +1,177 @@
;;; doom-stylix-theme.el --- stylix template created from doom-one -*- lexical-binding: t; no-byte-compile: t; -*-
;;
;; Author: Emmet K <https://gitlab.com/librephoenix>
;; Maintainer: Emmet K <https://gitlab.com/librephoenix>
;; Source: https://github.com/doomemacs/themes
;;
;;; Commentary:
;;
;; Stylix template for Doom Emacs.
;;
;;; Code:
(require 'doom-themes)
;;
;;; Variables
(defgroup doom-stylix-theme nil
"Options for the `doom-one' theme."
:group 'doom-themes)
(defcustom doom-stylix-brighter-modeline nil
"If non-nil, more vivid colors will be used to style the mode-line."
:group 'doom-stylix-theme
:type 'boolean)
(defcustom doom-stylix-brighter-comments nil
"If non-nil, comments will be highlighted in more vivid colors."
:group 'doom-stylix-theme
:type 'boolean)
(defcustom doom-stylix-padded-modeline doom-themes-padded-modeline
"If non-nil, adds a 4px padding to the mode-line.
Can be an integer to determine the exact padding."
:group 'doom-stylix-theme
:type '(choice integer boolean))
;;
;;; Theme definition
(def-doom-theme doom-stylix
"A theme generated from current stylix theme."
;; name default 256 16
((bg '("#{{base00-hex}}" "black" "black" ))
(fg '("#{{base05-hex}}" "#bfbfbf" "brightwhite" ))
;; These are off-color variants of bg/fg, used primarily for `solaire-mode',
;; but can also be useful as a basis for subtle highlights (e.g. for hl-line
;; or region), especially when paired with the `doom-darken', `doom-lighten',
;; and `doom-blend' helper functions.
(bg-alt '("#{{base01-hex}}" "black" "black" ))
(fg-alt '("#{{base07-hex}}" "#2d2d2d" "white" ))
;; These should represent a spectrum from bg to fg, where base0 is a starker
;; bg and base8 is a starker fg. For example, if bg is light grey and fg is
;; dark grey, base0 should be white and base8 should be black.
(base0 '("#{{base00-hex}}" "black" "black" ))
(base1 '("#{{base01-hex}}" "#1e1e1e" "brightblack" ))
(base2 '("#{{base01-hex}}" "#2e2e2e" "brightblack" ))
(base3 '("#{{base02-hex}}" "#262626" "brightblack" ))
(base4 '("#{{base03-hex}}" "#3f3f3f" "brightblack" ))
(base5 '("#{{base04-hex}}" "#525252" "brightblack" ))
(base6 '("#{{base05-hex}}" "#6b6b6b" "brightblack" ))
(base7 '("#{{base06-hex}}" "#979797" "brightblack" ))
(base8 '("#{{base07-hex}}" "#dfdfdf" "white" ))
(grey base4)
(red '("#{{base08-hex}}" "#ff6655" "red" ))
(orange '("#{{base09-hex}}" "#dd8844" "brightred" ))
(green '("#{{base0B-hex}}" "#99bb66" "green" ))
(teal '("#{{base0C-hex}}" "#44b9b1" "brightgreen" ))
(yellow '("#{{base0A-hex}}" "#ECBE7B" "yellow" ))
(blue '("#{{base0E-hex}}" "#51afef" "brightblue" ))
(dark-blue '("#{{base0E-hex}}" "#2257A0" "blue" ))
(magenta '("#{{base0F-hex}}" "#c678dd" "brightmagenta"))
(violet '("#{{base0F-hex}}" "#a9a1e1" "magenta" ))
(cyan '("#{{base0D-hex}}" "#46D9FF" "brightcyan" ))
(dark-cyan '("#{{base0C-hex}}" "#5699AF" "cyan" ))
;; These are the "universal syntax classes" that doom-themes establishes.
;; These *must* be included in every doom themes, or your theme will throw an
;; error, as they are used in the base theme defined in doom-themes-base.
(highlight blue)
(vertical-bar (doom-darken base1 0.1))
(selection dark-blue)
(builtin magenta)
(comments (if doom-stylix-brighter-comments dark-cyan base5))
(doc-comments (doom-lighten (if doom-stylix-brighter-comments dark-cyan base5) 0.25))
(constants violet)
(functions magenta)
(keywords blue)
(methods cyan)
(operators blue)
(type yellow)
(strings green)
(variables (doom-lighten magenta 0.4))
(numbers orange)
(region `(,(doom-lighten (car bg-alt) 0.15) ,@(doom-lighten (cdr base1) 0.35)))
(error red)
(warning yellow)
(success green)
(vc-modified orange)
(vc-added green)
(vc-deleted red)
;; These are extra color variables used only in this theme; i.e. they aren't
;; mandatory for derived themes.
(modeline-fg fg)
(modeline-fg-alt base5)
(modeline-bg (if doom-stylix-brighter-modeline
(doom-darken blue 0.45)
(doom-darken bg-alt 0.1)))
(modeline-bg-alt (if doom-stylix-brighter-modeline
(doom-darken blue 0.475)
`(,(doom-darken (car bg-alt) 0.15) ,@(cdr bg))))
(modeline-bg-inactive `(,(car bg-alt) ,@(cdr base1)))
(modeline-bg-inactive-alt `(,(doom-darken (car bg-alt) 0.1) ,@(cdr bg)))
(-modeline-pad
(when doom-stylix-padded-modeline
(if (integerp doom-stylix-padded-modeline) doom-stylix-padded-modeline 4))))
;;;; Base theme face overrides
(((line-number &override) :foreground base4)
((line-number-current-line &override) :foreground fg)
((font-lock-comment-face &override)
:background (if doom-stylix-brighter-comments (doom-lighten bg 0.05)))
(mode-line
:background modeline-bg :foreground modeline-fg
:box (if -modeline-pad `(:line-width ,-modeline-pad :color ,modeline-bg)))
(mode-line-inactive
:background modeline-bg-inactive :foreground modeline-fg-alt
:box (if -modeline-pad `(:line-width ,-modeline-pad :color ,modeline-bg-inactive)))
(mode-line-emphasis :foreground (if doom-stylix-brighter-modeline base8 highlight))
;;;; css-mode <built-in> / scss-mode
(css-proprietary-property :foreground orange)
(css-property :foreground green)
(css-selector :foreground blue)
;;;; doom-modeline
(doom-modeline-bar :background (if doom-stylix-brighter-modeline modeline-bg highlight))
(doom-modeline-buffer-file :inherit 'mode-line-buffer-id :weight 'bold)
(doom-modeline-buffer-path :inherit 'mode-line-emphasis :weight 'bold)
(doom-modeline-buffer-project-root :foreground green :weight 'bold)
;;;; elscreen
(elscreen-tab-other-screen-face :background "#{{base01-hex}}" :foreground "#{{base06-hex}}")
;;;; ivy
(ivy-current-match :background dark-blue :distant-foreground base0 :weight 'normal)
;;;; LaTeX-mode
(font-latex-math-face :foreground green)
;;;; markdown-mode
(markdown-markup-face :foreground base5)
(markdown-header-face :inherit 'bold :foreground red)
((markdown-code-face &override) :background (doom-lighten base3 0.05))
;;;; org-mode
(org-block :background (doom-darken bg 0.05 ) :extend t)
(org-code :background (doom-darken bg 0.05 ) :extend t)
;;;; rjsx-mode
(rjsx-tag :foreground red)
(rjsx-attr :foreground orange)
;;;; solaire-mode
(solaire-mode-line-face
:inherit 'mode-line
:background modeline-bg-alt
:box (if -modeline-pad `(:line-width ,-modeline-pad :color ,modeline-bg-alt)))
(solaire-mode-line-inactive-face
:inherit 'mode-line-inactive
:background modeline-bg-inactive-alt
:box (if -modeline-pad `(:line-width ,-modeline-pad :color ,modeline-bg-inactive-alt))))
;;;; Base theme variable overrides-
())
;;; doom-stylix-theme.el ends here

View File

@@ -0,0 +1,55 @@
;;; line-wrapping-and-numbers.el --- basic line wrapping management library -*- lexical-binding: t; no-byte-compile: t; -*-
;;
;; Author: Emmet K <https://gitlab.com/librephoenix>
;; Maintainer: Emmet K <https://gitlab.com/librephoenix>
;; Source: https://github.com/librephoenix/nixos-config
;; Source: https://gitlab.com/librephoenix/nixos-config
;; Source: https://codeberg.org/librephoenix/nixos-config
;;
;;; Commentary:
;;
;; A basic line wrapping management library.
;; Turns on line wrapping for programming modes,
;; and turns it off for thinks like markdown and org.
;;
;;; Code:
;; Line wrapping management
(defun truncate-lines-off ()
"Stop truncating lines in current buffer."
(interactive)
(toggle-truncate-lines 0))
(defun truncate-lines-on ()
"Truncate lines in current buffer."
(interactive)
(toggle-truncate-lines 1))
(defun visual-line-mode-off ()
"Disable `visual-line-mode` in current buffer."
(interactive)
(visual-line-mode 0))
(add-hook 'org-mode-hook 'truncate-lines-off)
(add-hook 'markdown-mode-hook 'truncate-lines-off)
(add-hook 'org-mode-hook 'visual-line-mode)
(add-hook 'markdown-mode-hook 'visual-line-mode)
(add-hook 'prog-mode-hook 'truncate-lines-on)
(add-hook 'prog-mode-hook 'visual-line-mode-off)
(defun apply-proper-line-wrapping ()
"Apply proper line wrapping and visual line mode settings according to whether or not the current mode derives from `prog-mode`."
(if (derived-mode-p 'prog-mode)
(progn
(display-line-numbers-mode)
(truncate-lines-on)
(visual-line-mode-off)
(display-line-numbers-mode 1))
(progn
(truncate-lines-off)
(visual-line-mode)
(display-line-numbers-mode 0))))
(add-hook 'prog-mode-hook 'apply-proper-line-wrapping)
(add-hook 'org-mode-hook 'apply-proper-line-wrapping)
(if (featurep 'markdown-mode)
(add-hook 'markdown-mode-hook 'apply-proper-line-wrapping))
(if (featurep 'git-timemachine)
(add-hook 'git-timemachine-mode-hook 'apply-proper-line-wrapping))
;;; line-wrapping.el ends here

View File

@@ -0,0 +1,20 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.engineering;
in {
options = {
userSettings.engineering = {
enable = lib.mkEnableOption "Enable engineering programs";
};
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
freecad
openscad
kicad
cura-appimage
];
};
}

View File

@@ -0,0 +1,22 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.flatpak;
in {
options = {
userSettings.flatpak = {
enable = lib.mkEnableOption "Enable flatpak support";
};
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.flatpak ];
home.sessionVariables = {
XDG_DATA_DIRS = "$XDG_DATA_DIRS:/usr/share:/var/lib/flatpak/exports/share:$HOME/.local/share/flatpak/exports/share"; # lets flatpak work
};
#services.flatpak.enable = true;
#services.flatpak.packages = [ { appId = "com.kde.kdenlive"; origin = "flathub"; } ];
#services.flatpak.update.onActivation = true;
};
}

22
modules/user/git/git.nix Normal file
View File

@@ -0,0 +1,22 @@
{ config, lib, pkgs, osConfig, ... }:
let
cfg = config.userSettings.git;
in {
options = {
userSettings.git = {
enable = lib.mkEnableOption "Enable git";
};
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.git ];
programs.git.enable = true;
programs.git.userName = config.userSettings.name;
programs.git.userEmail = config.userSettings.email;
programs.git.extraConfig = {
init.defaultBranch = "main";
safe.directory = [ osConfig.systemSettings.dotfilesDir (config.home.homeDirectory + "/.cache/nix/tarball-cache") ];
};
};
}

View File

@@ -0,0 +1,197 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.godot;
in {
options = {
userSettings.godot = {
enable = lib.mkEnableOption "Enable godot";
};
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
godot_4
];
# ~/.config/godot must be owned by another user in order for this to work
# does not need to be recursively owned, however
# TODO fix other colors
home.file.".config/godot/editor_settings-4.3.tres".text = ''
[gd_resource type="EditorSettings" format=3]
[resource]
interface/editor/separate_distraction_mode = true
interface/theme/preset = "Custom"
interface/theme/spacing_preset = "Custom"
interface/theme/base_color = Color(''+config.lib.stylix.colors.base00-dec-r+'',''+config.lib.stylix.colors.base00-dec-g+'', ''+config.lib.stylix.colors.base00-dec-b+'', 0.8)
interface/theme/accent_color = Color(''+config.lib.stylix.colors.base08-dec-r+'',''+config.lib.stylix.colors.base08-dec-g+'', ''+config.lib.stylix.colors.base08-dec-b+'', 1)
interface/theme/contrast = 0.3
interface/theme/icon_saturation = 1.55
interface/theme/relationship_line_opacity = 0.35
interface/theme/border_size = 1
interface/theme/corner_radius = 6
interface/theme/additional_spacing = 1
interface/touchscreen/enable_pan_and_scale_gestures = true
interface/touchscreen/scale_gizmo_handles = 2.0
interface/multi_window/enable = false
interface/multi_window/restore_windows_on_load = false
filesystem/external_programs/raster_image_editor = "krita"
filesystem/external_programs/vector_image_editor = "inkscape"
filesystem/external_programs/3d_model_editor = "blender"
filesystem/external_programs/terminal_emulator = "''+config.userSettings.terminal+''"
filesystem/directories/default_project_path = "/home/''+config.home.username+''/Projects"
text_editor/theme/highlighting/symbol_color = Color(0.67, 0.79, 1, 1)
text_editor/theme/highlighting/keyword_color = Color(1, 0.44, 0.52, 1)
text_editor/theme/highlighting/control_flow_keyword_color = Color(1, 0.55, 0.8, 1)
text_editor/theme/highlighting/base_type_color = Color(0.26, 1, 0.76, 1)
text_editor/theme/highlighting/engine_type_color = Color(0.56, 1, 0.86, 1)
text_editor/theme/highlighting/user_type_color = Color(0.78, 1, 0.93, 1)
text_editor/theme/highlighting/comment_color = Color(0.764706, 0.769608, 0.77451, 0.5)
text_editor/theme/highlighting/doc_comment_color = Color(0.6, 0.7, 0.8, 0.8)
text_editor/theme/highlighting/string_color = Color(1, 0.93, 0.63, 1)
text_editor/theme/highlighting/background_color = Color(0.0323529, 0.0431373, 0.0539216, 1)
text_editor/theme/highlighting/completion_background_color = Color(0.0588235, 0.0784314, 0.0980392, 1)
text_editor/theme/highlighting/completion_selected_color = Color(1, 1, 1, 0.07)
text_editor/theme/highlighting/completion_existing_color = Color(1, 1, 1, 0.14)
text_editor/theme/highlighting/completion_font_color = Color(0.764706, 0.769608, 0.77451, 1)
text_editor/theme/highlighting/text_color = Color(0.764706, 0.769608, 0.77451, 1)
text_editor/theme/highlighting/line_number_color = Color(0.764706, 0.769608, 0.77451, 0.5)
text_editor/theme/highlighting/safe_line_number_color = Color(0.764706, 0.923529, 0.77451, 0.75)
text_editor/theme/highlighting/caret_color = Color(1, 1, 1, 1)
text_editor/theme/highlighting/selection_color = Color(0.941176, 0.443137, 0.470588, 0.4)
text_editor/theme/highlighting/brace_mismatch_color = Color(1, 0.47, 0.42, 1)
text_editor/theme/highlighting/current_line_color = Color(1, 1, 1, 0.07)
text_editor/theme/highlighting/line_length_guideline_color = Color(0.0588235, 0.0784314, 0.0980392, 1)
text_editor/theme/highlighting/word_highlighted_color = Color(1, 1, 1, 0.07)
text_editor/theme/highlighting/number_color = Color(0.63, 1, 0.88, 1)
text_editor/theme/highlighting/function_color = Color(0.34, 0.7, 1, 1)
text_editor/theme/highlighting/member_variable_color = Color(0.736, 0.88, 1, 1)
text_editor/theme/highlighting/mark_color = Color(1, 0.47, 0.42, 0.3)
text_editor/theme/highlighting/breakpoint_color = Color(1, 0.47, 0.42, 1)
text_editor/theme/highlighting/code_folding_color = Color(1, 1, 1, 0.27)
text_editor/theme/highlighting/search_result_color = Color(1, 1, 1, 0.07)
text_editor/appearance/whitespace/draw_tabs = false
text_editor/behavior/indent/type = 1
text_editor/behavior/indent/size = 2
text_editor/behavior/files/trim_trailing_whitespace_on_save = true
editors/panning/2d_editor_panning_scheme = 1
editors/panning/sub_editors_panning_scheme = 1
editors/panning/simple_panning = true
project_manager/directory_naming_convention = 3
asset_library/available_urls = {
"godotengine.org (Official)": "https://godotengine.org/asset-library/api"
}
asset_library/use_threads = true
export/android/java_sdk_path = ""
export/android/android_sdk_path = ""
export/android/debug_keystore = "/home/emmet/.local/share/godot/keystores/debug.keystore"
export/android/debug_keystore_user = "androiddebugkey"
export/android/debug_keystore_pass = "android"
export/android/force_system_user = false
export/android/shutdown_adb_on_exit = true
export/android/one_click_deploy_clear_previous_install = false
export/android/use_wifi_for_remote_debug = false
export/android/wifi_remote_debug_host = "localhost"
export/macos/rcodesign = ""
export/web/http_host = "localhost"
export/web/http_port = 8060
export/web/use_tls = false
export/web/tls_key = ""
export/web/tls_certificate = ""
export/windows/rcedit = ""
export/windows/osslsigncode = ""
export/windows/wine = "/home/emmet/.nix-profile/bin/wine64"
_default_feature_profile = ""
interface/editors/show_scene_tree_root_selection = true
interface/editors/derive_script_globals_by_name = true
docks/scene_tree/ask_before_deleting_related_animation_tracks = true
_use_favorites_root_selection = false
filesystem/file_server/port = 6010
filesystem/file_server/password = ""
editors/3d/manipulator_gizmo_size = 80
editors/3d/manipulator_gizmo_opacity = 0.9
editors/3d/navigation/show_viewport_rotation_gizmo = true
editors/3d/navigation/show_viewport_navigation_gizmo = false
text_editor/behavior/files/auto_reload_and_parse_scripts_on_save = true
text_editor/behavior/files/open_dominant_script_on_scene_change = false
text_editor/external/use_external_editor = false
text_editor/external/exec_path = ""
text_editor/script_list/script_temperature_enabled = true
text_editor/script_list/script_temperature_history_size = 15
text_editor/script_list/group_help_pages = true
text_editor/script_list/sort_scripts_by = 0
text_editor/script_list/list_script_names_as = 0
text_editor/external/exec_flags = "{file}"
version_control/username = ""
version_control/ssh_public_key_path = ""
version_control/ssh_private_key_path = ""
editors/bone_mapper/handle_colors/unset = Color(0.3, 0.3, 0.3, 1)
editors/bone_mapper/handle_colors/set = Color(0.1, 0.6, 0.25, 1)
editors/bone_mapper/handle_colors/missing = Color(0.8, 0.2, 0.8, 1)
editors/bone_mapper/handle_colors/error = Color(0.8, 0.2, 0.2, 1)
network/debug_adapter/remote_port = 6006
network/debug_adapter/request_timeout = 1000
network/debug_adapter/sync_breakpoints = false
editors/3d_gizmos/gizmo_settings/path3d_tilt_disk_size = 0.8
editors/3d_gizmos/gizmo_colors/path_tilt = Color(1, 1, 0.4, 0.9)
editors/3d_gizmos/gizmo_colors/skeleton = Color(1, 0.8, 0.4, 1)
editors/3d_gizmos/gizmo_colors/selected_bone = Color(0.8, 0.3, 0, 1)
editors/3d_gizmos/gizmo_settings/bone_axis_length = 0.1
editors/3d_gizmos/gizmo_settings/bone_shape = 1
editors/3d_gizmos/gizmo_colors/csg = Color(0, 0.4, 1, 0.15)
editors/grid_map/editor_side = 1
editors/grid_map/palette_min_width = 230
editors/grid_map/preview_size = 64
export/ssh/ssh = ""
export/ssh/scp = ""
network/language_server/remote_host = "127.0.0.1"
network/language_server/remote_port = 6005
network/language_server/enable_smart_resolve = true
network/language_server/show_native_symbols_in_editor = false
network/language_server/use_thread = false
network/language_server/poll_limit_usec = 100000
text_editor/theme/highlighting/gdscript/function_definition_color = Color(0.4, 0.9, 1, 1)
text_editor/theme/highlighting/gdscript/global_function_color = Color(0.64, 0.64, 0.96, 1)
text_editor/theme/highlighting/gdscript/node_path_color = Color(0.72, 0.77, 0.49, 1)
text_editor/theme/highlighting/gdscript/node_reference_color = Color(0.39, 0.76, 0.35, 1)
text_editor/theme/highlighting/gdscript/annotation_color = Color(1, 0.7, 0.45, 1)
text_editor/theme/highlighting/gdscript/string_name_color = Color(1, 0.76, 0.65, 1)
text_editor/theme/highlighting/comment_markers/critical_color = Color(0.77, 0.35, 0.35, 1)
text_editor/theme/highlighting/comment_markers/warning_color = Color(0.72, 0.61, 0.48, 1)
text_editor/theme/highlighting/comment_markers/notice_color = Color(0.56, 0.67, 0.51, 1)
text_editor/theme/highlighting/comment_markers/critical_list = "ALERT,ATTENTION,CAUTION,CRITICAL,DANGER,SECURITY"
text_editor/theme/highlighting/comment_markers/warning_list = "BUG,DEPRECATED,FIXME,HACK,TASK,TBD,TODO,WARNING"
text_editor/theme/highlighting/comment_markers/notice_list = "INFO,NOTE,NOTICE,TEST,TESTING"
editors/3d_gizmos/gizmo_colors/camera = Color(0.8, 0.4, 0.8, 1)
editors/3d_gizmos/gizmo_colors/stream_player_3d = Color(0.4, 0.8, 1, 1)
editors/3d_gizmos/gizmo_colors/occluder = Color(0.8, 0.5, 1, 1)
editors/3d_gizmos/gizmo_colors/visibility_notifier = Color(0.8, 0.5, 0.7, 1)
editors/3d_gizmos/gizmo_colors/particles = Color(0.8, 0.7, 0.4, 1)
editors/3d_gizmos/gizmo_colors/particle_attractor = Color(1, 0.7, 0.5, 1)
editors/3d_gizmos/gizmo_colors/particle_collision = Color(0.5, 0.7, 1, 1)
editors/3d_gizmos/gizmo_colors/reflection_probe = Color(0.6, 1, 0.5, 1)
editors/3d_gizmos/gizmo_colors/decal = Color(0.6, 0.5, 1, 1)
editors/3d_gizmos/gizmo_colors/voxel_gi = Color(0.5, 1, 0.6, 1)
editors/3d_gizmos/gizmo_colors/lightmap_lines = Color(0.5, 0.6, 1, 1)
editors/3d_gizmos/gizmo_colors/lightprobe_lines = Color(0.5, 0.6, 1, 1)
editors/3d_gizmos/gizmo_colors/joint_body_a = Color(0.6, 0.8, 1, 1)
editors/3d_gizmos/gizmo_colors/joint_body_b = Color(0.6, 0.9, 1, 1)
editors/3d_gizmos/gizmo_colors/fog_volume = Color(0.5, 0.7, 1, 1)
text_editor/help/sort_functions_alphabetically = true
metadata/script_setup_templates_dictionary = {
"AnimatedSprite2D": "0NodeDefault",
"Area2D": "0NodeDefault",
"CanvasLayer": "0NodeDefault",
"Node": "0NodeDefault",
"Node2D": "0NodeDefault"
}
metadata/export_template_download_directory = "/home/emmet/.cache/godot"
'';
};
}

6
modules/user/home.nix Normal file
View File

@@ -0,0 +1,6 @@
{ config, lib, pkgs, inputs, ... }:
{
imports = [ inputs.chaotic.homeManagerModules.default ];
}

View File

@@ -0,0 +1,786 @@
{ config, lib, pkgs, inputs, ... }:
let
cfg = config.userSettings.hyprland;
font = config.stylix.fonts.monospace.name;
term = config.userSettings.terminal;
spawnEditor = config.userSettings.spawnEditor;
spawnBrowser = config.userSettings.spawnBrowser;
in
{
options = {
userSettings.hyprland = {
enable = lib.mkEnableOption "Enable hyprland";
};
};
config = {
userSettings.alacritty.enable = true;
userSettings.kitty.enable = true;
userSettings.japanese.enable = true;
userSettings.dmenuScripts = {
enable = true;
dmenuCmd = "fuzzel -d";
};
userSettings.hyprland.hyprprofiles.enable = lib.mkDefault true;
userSettings.stylix.enable = true;
home.sessionVariables = {
NIXOS_OZONE_WL = 1;
XDG_CURRENT_DESKTOP = "Hyprland";
XDG_SESSION_DESKTOP = "Hyprland";
XDG_SESSION_TYPE = "wayland";
WLR_DRM_DEVICES = "/dev/dri/card2:/dev/dri/card1";
GDK_BACKEND = "wayland,x11,*";
QT_QPA_PLATFORM = "wayland;xcb";
QT_QPA_PLATFORMTHEME = lib.mkForce "qt5ct";
QT_AUTO_SCREEN_SCALE_FACTOR = 1;
QT_WAYLAND_DISABLE_WINDOWDECORATION = 1;
CLUTTER_BACKEND = "wayland";
GDK_PIXBUF_MODULE_FILE = "${pkgs.librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache";
GSK_RENDERER = "gl";
};
gtk.cursorTheme = {
package = pkgs.quintom-cursor-theme;
name = if (config.stylix.polarity == "light") then "Quintom_Ink" else "Quintom_Snow";
size = 36;
};
wayland.windowManager.hyprland = {
enable = true;
package = inputs.hyprland.packages.${pkgs.system}.hyprland;
plugins = [ ];
settings = { };
systemd.variables = ["--all"];
extraConfig = ''
exec-once = hyprctl setcursor ${config.gtk.cursorTheme.name} ${builtins.toString config.gtk.cursorTheme.size}
exec-once = sleep 10 && nextcloud
exec-once = iio-hyprland
exec-once = hyprprofile Default
exec-once = ydotoold
exec-once = sleep 10 && caffeine
#exec-once = STEAM_FRAME_FORCE_CLOSE=1 steam -silent
exec-once = nm-applet
exec-once = blueman-applet
exec-once = GOMAXPROCS=1 syncthing --no-browser
exec-once = protonmail-bridge --noninteractive
exec-once = eww open-many bar:first bar:second bar:third --arg first:monitor=0 --arg second:monitor=1 --arg third:monitor=2
exec-once = hyprland-monitor-attached ~/.local/bin/eww-reload-bars.sh
exec-once = emacs --daemon
exec-once = hypridle
exec-once = sleep 5 && libinput-gestures
exec-once = obs-notification-mute-daemon
exec-once = hyprpaper
bezier = wind, 0.05, 0.9, 0.1, 1.05
bezier = winIn, 0.1, 1.1, 0.1, 1.0
bezier = winOut, 0.3, -0.3, 0, 1
bezier = liner, 1, 1, 1, 1
bezier = linear, 0.0, 0.0, 1.0, 1.0
animations {
enabled = yes
animation = windowsIn, 1, 6, winIn, popin
animation = windowsOut, 1, 5, winOut, popin
animation = windowsMove, 1, 5, wind, slide
animation = border, 1, 10, default
animation = borderangle, 1, 100, linear, loop
animation = fade, 1, 10, default
animation = workspaces, 1, 5, wind
animation = windows, 1, 6, wind, slide
animation = specialWorkspace, 1, 6, default, slidefadevert -50%
}
general {
layout = master
border_size = 5
col.active_border = 0xff'' + config.lib.stylix.colors.base08 + " " + ''0xff'' + config.lib.stylix.colors.base09 + " " + ''0xff'' + config.lib.stylix.colors.base0A + " " + ''0xff'' + config.lib.stylix.colors.base0B + " " + ''0xff'' + config.lib.stylix.colors.base0C + " " + ''0xff'' + config.lib.stylix.colors.base0D + " " + ''0xff'' + config.lib.stylix.colors.base0E + " " + ''0xff'' + config.lib.stylix.colors.base0F + " " + ''270deg
col.inactive_border = 0xff'' + config.lib.stylix.colors.base02 + ''
resize_on_border = true
gaps_in = 7
gaps_out = 7
}
cursor {
no_warps = false
inactive_timeout = 30
}
bind=SUPER,code:9,exec,nwggrid-wrapper
bind=SUPER,code:66,exec,nwggrid-wrapper
bind=SUPER,SPACE,fullscreen,1
bind=SUPERSHIFT,F,fullscreen,0
bind=SUPER,Y,workspaceopt,allfloat
bind=ALT,TAB,cyclenext
bind=ALT,TAB,bringactivetotop
bind=ALTSHIFT,TAB,cyclenext,prev
bind=ALTSHIFT,TAB,bringactivetotop
bind=SUPER,V,exec,wl-copy $(wl-paste | tr '\n' ' ')
bind=SUPERSHIFT,T,exec,screenshot-ocr
bind=CTRLALT,Delete,exec,hyprctl kill
bind=SUPERSHIFT,K,exec,hyprctl kill
bind=,code:172,exec,mpc toggle
bind=,code:208,exec,mpc toggle
bind=,code:209,exec,mpc toggle
bind=,code:174,exec,mpc stop
bind=,code:171,exec,mpc next
bind=,code:173,exec,mpc prev
bind = SUPER,R,pass,^(com\.obsproject\.Studio)$
bind = SUPERSHIFT,R,pass,^(com\.obsproject\.Studio)$
bind=SUPER,RETURN,exec,'' + term + ''
bind=SUPERSHIFT,RETURN,exec,'' + term + " " + '' --class float_term
bind=SUPER,A,exec,'' + spawnEditor + ''
bind=SUPER,S,exec,'' + spawnBrowser + ''
bind=SUPERCTRL,S,exec,container-open # qutebrowser only
bind=SUPERCTRL,P,pin
bind=SUPER,code:47,exec,fuzzel
bind=SUPER,X,exec,fnottctl dismiss
bind=SUPERSHIFT,X,exec,fnottctl dismiss all
bind=SUPER,Q,killactive
bind=SUPERSHIFT,Q,exit
bindm=SUPER,mouse:272,movewindow
bindm=SUPER,mouse:273,resizewindow
bind=SUPER,T,togglefloating
bind=,code:148,exec,''+ term + " "+''-e numbat
bind=,code:107,exec,grim -g "$(slurp)"
bind=SHIFT,code:107,exec,grim -g "$(slurp -o)"
bind=SUPER,code:107,exec,grim
bind=CTRL,code:107,exec,grim -g "$(slurp)" - | wl-copy
bind=SHIFTCTRL,code:107,exec,grim -g "$(slurp -o)" - | wl-copy
bind=SUPERCTRL,code:107,exec,grim - | wl-copy
bind=,code:122,exec,swayosd-client --output-volume lower
bind=,code:123,exec,swayosd-client --output-volume raise
bind=,code:121,exec,swayosd-client --output-volume mute-toggle
bind=,code:256,exec,swayosd-client --output-volume mute-toggle
bind=SHIFT,code:122,exec,swayosd-client --output-volume lower
bind=SHIFT,code:123,exec,swayosd-client --output-volume raise
bind=,code:232,exec,swayosd-client --brightness lower
bind=,code:233,exec,swayosd-client --brightness raise
bind=,code:237,exec,brightnessctl --device='asus::kbd_backlight' set 1-
bind=,code:238,exec,brightnessctl --device='asus::kbd_backlight' set +1
bind=,code:255,exec,airplane-mode
bind=SUPER,C,exec,wl-copy $(hyprpicker)
bind=SUPERSHIFT,S,exec,systemctl suspend
bindl=,switch:on:Lid Switch,exec,loginctl lock-session
bind=SUPERCTRL,L,exec,loginctl lock-session
bind=SUPER,H,movefocus,l
bind=SUPER,J,movefocus,d
bind=SUPER,K,movefocus,u
bind=SUPER,L,movefocus,r
bind=SUPERSHIFT,H,movewindow,l
bind=SUPERSHIFT,J,movewindow,d
bind=SUPERSHIFT,K,movewindow,u
bind=SUPERSHIFT,L,movewindow,r
bind=SUPER,1,focusworkspaceoncurrentmonitor,1
bind=SUPER,2,focusworkspaceoncurrentmonitor,2
bind=SUPER,3,focusworkspaceoncurrentmonitor,3
bind=SUPER,4,focusworkspaceoncurrentmonitor,4
bind=SUPER,5,focusworkspaceoncurrentmonitor,5
bind=SUPER,6,focusworkspaceoncurrentmonitor,6
bind=SUPER,7,focusworkspaceoncurrentmonitor,7
bind=SUPER,8,focusworkspaceoncurrentmonitor,8
bind=SUPER,9,focusworkspaceoncurrentmonitor,9
bind=SUPERCTRL,right,exec,hyprnome
bind=SUPERCTRL,left,exec,hyprnome --previous
bind=SUPERSHIFT,right,exec,hyprnome --move
bind=SUPERSHIFT,left,exec,hyprnome --previous --move
bind=SUPERSHIFT,1,movetoworkspace,1
bind=SUPERSHIFT,2,movetoworkspace,2
bind=SUPERSHIFT,3,movetoworkspace,3
bind=SUPERSHIFT,4,movetoworkspace,4
bind=SUPERSHIFT,5,movetoworkspace,5
bind=SUPERSHIFT,6,movetoworkspace,6
bind=SUPERSHIFT,7,movetoworkspace,7
bind=SUPERSHIFT,8,movetoworkspace,8
bind=SUPERSHIFT,9,movetoworkspace,9
exec-once = alacritty --class scratch_term
exec-once = kitty --class scratch_ranger -e ranger
exec-once = alacritty --class scratch_numbat -e numbat
exec-once = kitty --class scratch_music -e ncmpcpp
exec-once = alacritty --class scratch_btm -e btm
exec-once = element-desktop
exec-once = pavucontrol
bind=SUPER,Z,exec,if hyprctl clients | grep scratch_term; then echo "scratch_term respawn not needed"; else alacritty --class scratch_term; fi
bind=SUPER,Z,togglespecialworkspace,scratch_term
bind=SUPER,F,exec,if hyprctl clients | grep scratch_ranger; then echo "scratch_ranger respawn not needed"; else kitty --class scratch_ranger -e ranger; fi
bind=SUPER,F,togglespecialworkspace,scratch_ranger
bind=SUPER,N,exec,if hyprctl clients | grep scratch_numbat; then echo "scratch_ranger respawn not needed"; else alacritty --class scratch_numbat -e numbat; fi
bind=SUPER,N,togglespecialworkspace,scratch_numbat
bind=SUPER,M,exec,if hyprctl clients | grep scratch_music; then echo "scratch_music respawn not needed"; else kitty --class scratch_music -e ncmpcpp; fi
bind=SUPER,M,togglespecialworkspace,scratch_music
bind=SUPER,B,exec,if hyprctl clients | grep scratch_btm; then echo "scratch_ranger respawn not needed"; else alacritty --class scratch_btm -e btm; fi
bind=SUPER,B,togglespecialworkspace,scratch_btm
bind=SUPER,D,exec,if hyprctl clients | grep Element; then echo "scratch_ranger respawn not needed"; else element-desktop; fi
bind=SUPER,D,togglespecialworkspace,scratch_element
bind=SUPER,code:172,exec,togglespecialworkspace,scratch_pavucontrol
bind=SUPER,code:172,exec,if hyprctl clients | grep pavucontrol; then echo "scratch_ranger respawn not needed"; else pavucontrol; fi
$scratchpadsize = size 80% 85%
$scratch_term = class:^(scratch_term)$
windowrulev2 = float,$scratch_term
windowrulev2 = $scratchpadsize,$scratch_term
windowrulev2 = workspace special:scratch_term silent ,$scratch_term
windowrulev2 = center,$scratch_term
$float_term = class:^(float_term)$
windowrulev2 = float,$float_term
windowrulev2 = center,$float_term
$scratch_ranger = class:^(scratch_ranger)$
windowrulev2 = float,$scratch_ranger
windowrulev2 = $scratchpadsize,$scratch_ranger
windowrulev2 = workspace special:scratch_ranger silent,$scratch_ranger
windowrulev2 = center,$scratch_ranger
$scratch_numbat = class:^(scratch_numbat)$
windowrulev2 = float,$scratch_numbat
windowrulev2 = $scratchpadsize,$scratch_numbat
windowrulev2 = workspace special:scratch_numbat silent,$scratch_numbat
windowrulev2 = center,$scratch_numbat
$scratch_btm = class:^(scratch_btm)$
windowrulev2 = float,$scratch_btm
windowrulev2 = $scratchpadsize,$scratch_btm
windowrulev2 = workspace special:scratch_btm silent,$scratch_btm
windowrulev2 = center,$scratch_btm
windowrulev2 = float,class:^(Element)$
windowrulev2 = size 85% 90%,class:^(Element)$
windowrulev2 = workspace special:scratch_element silent,class:^(Element)$
windowrulev2 = center,class:^(Element)$
$scratch_music = class:^(scratch_music)$
windowrulev2 = float,$scratch_music
windowrulev2 = $scratchpadsize,$scratch_music
windowrulev2 = workspace special:scratch_music silent,$scratch_music
windowrulev2 = center,$scratch_music
$savetodisk = title:^(Save to Disk)$
windowrulev2 = float,$savetodisk
windowrulev2 = size 70% 75%,$savetodisk
windowrulev2 = center,$savetodisk
$pavucontrol = class:^(org.pulseaudio.pavucontrol)$
windowrulev2 = float,$pavucontrol
windowrulev2 = size 86% 40%,$pavucontrol
windowrulev2 = move 50% 6%,$pavucontrol
windowrulev2 = workspace special silent,$pavucontrol
windowrulev2 = opacity 0.80,$pavucontrol
$miniframe = title:\*Minibuf.*
windowrulev2 = float,$miniframe
windowrulev2 = size 64% 50%,$miniframe
windowrulev2 = move 18% 25%,$miniframe
windowrulev2 = animation popin 1 20,$miniframe
windowrulev2 = float,class:^(pokefinder)$
windowrulev2 = float,class:^(Waydroid)$
windowrulev2 = float,title:(Blender Render)
windowrulev2 = size 86% 85%,title:(Blender Render)
windowrulev2 = center,title:(Blender Render)
windowrulev2 = float,class:^(org.inkscape.Inkscape)$
windowrulev2 = float,class:^(pinta)$
windowrulev2 = float,class:^(krita)$
windowrulev2 = float,class:^(Gimp)
windowrulev2 = float,class:^(Gimp)
windowrulev2 = float,class:^(libresprite)$
windowrulev2 = float,title:(Open Images)
windowrulev2 = size 86% 85%,title:(Open Images)
windowrulev2 = center,title:(Open Images)
windowrulev2 = float,title:(Create new document)
windowrulev2 = size 86% 85%,title:(Create new document)
windowrulev2 = center,title:(Create new document)
windowrulev2 = size 86% 85%,title:(Create new document)
windowrulev2 = float,title:(Create New Node)
windowrulev2 = size 70% 70%,title:(Create New Node)
windowrulev2 = center,title:(Create New Node)
windowrulev2 = float,title:(Resource)
windowrulev2 = size 70% 70%,title:(Resource)
windowrulev2 = center,title:(Resource)
windowrulev2 = tile,title:(Godot)
windowrulev2 = opacity 0.80,title:ORUI
windowrulev2 = opacity 1.0,class:^(org.qutebrowser.qutebrowser),fullscreen:1
windowrulev2 = opacity 0.85,class:^(Element)$
windowrulev2 = opacity 0.85,class:^(Logseq)$
windowrulev2 = opacity 1.0,class:^(Brave-browser),fullscreen:1
windowrulev2 = opacity 1.0,class:^(librewolf),fullscreen:1
windowrulev2 = opacity 0.85,title:^(My Local Dashboard Awesome Homepage - qutebrowser)$
windowrulev2 = opacity 0.85,title:\[.*\] - My Local Dashboard Awesome Homepage
windowrulev2 = opacity 0.85,class:^(org.keepassxc.KeePassXC)$
windowrulev2 = opacity 0.85,class:^(org.gnome.Nautilus)$
windowrulev2 = opacity 0.85,class:^(org.gnome.Nautilus)$
windowrulev2 = opacity 0.85,initialTitle:^(Notes)$,initialClass:^(Brave-browser)$
layerrule = blur,waybar
layerrule = xray 1,waybar
blurls = waybar
layerrule = ignorezero, eww
layerrule = xray 1,eww
layerrule = blur,launcher # fuzzel
blurls = launcher # fuzzel
layerrule = blur,gtk-layer-shell
layerrule = xray 1,gtk-layer-shell
layerrule = ignorezero, gtk-layer-shell
layerrule = blur,eww
layerrule = xray 1,eww
layerrule = ignorezero, eww
layerrule = animation popin 80%, eww
blurls = gtk-layer-shell
layerrule = blur,~nwggrid
layerrule = xray 1,~nwggrid
layerrule = animation fade,~nwggrid
blurls = ~nwggrid
bind=SUPER,equal, exec, hyprctl keyword cursor:zoom_factor "$(hyprctl getoption cursor:zoom_factor | grep float | awk '{print $2 + 0.5}')"
bind=SUPER,minus, exec, hyprctl keyword cursor:zoom_factor "$(hyprctl getoption cursor:zoom_factor | grep float | awk '{print $2 - 0.5}')"
bind=SUPER,I,exec,networkmanager_dmenu
bind=SUPER,P,exec,keepmenu
bind=SUPERSHIFT,P,exec,hyprprofile-dmenu
bind=SUPERCTRL,R,exec,phoenix refresh
# 3 monitor setup
monitor=eDP-1,1920x1080@300,900x1080,1
monitor=HDMI-A-1,1920x1080,1920x0,1
monitor=DP-1,1920x1080,0x0,1
# hdmi tv
#monitor=eDP-1,1920x1080,1920x0,1
#monitor=HDMI-A-1,1920x1080,0x0,1
# hdmi work projector
#monitor=eDP-1,1920x1080,1920x0,1
#monitor=HDMI-A-1,1920x1200,0x0,1
xwayland {
force_zero_scaling = true
}
binds {
movefocus_cycles_fullscreen = false
}
input {
kb_layout = us
kb_options = caps:escape
repeat_delay = 450
repeat_rate = 50
accel_profile = adaptive
follow_mouse = 2
float_switch_override_focus = 0
}
misc {
disable_hyprland_logo = true
mouse_move_enables_dpms = true
enable_swallow = true
swallow_regex = (scratch_term)|(Alacritty)|(kitty)
font_family = '' + font + ''
}
decoration {
rounding = 8
dim_special = 0.0
blur {
enabled = true
size = 5
passes = 2
ignore_opacity = true
contrast = 1.17
brightness = '' + (if (config.stylix.polarity == "dark") then "0.65" else "1.45") + ''
xray = true
special = true
popups = true
}
}
'';
xwayland = { enable = true; };
systemd.enable = true;
};
home.packages = (with pkgs; [
hyprland-monitor-attached
caffeine-ng
alacritty
kitty
killall
polkit_gnome
eww
nwg-launchers
papirus-icon-theme
(pkgs.writeScriptBin "nwggrid-wrapper" ''
#!/bin/sh
if pgrep -x "nwggrid-server" > /dev/null
then
nwggrid -client
else
GDK_PIXBUF_MODULE_FILE=${pkgs.librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache nwggrid-server -layer-shell-exclusive-zone -1 -g adw-gtk3 -o 0.55 -b ${config.lib.stylix.colors.base00}
fi
'')
libva-utils
libinput-gestures
gsettings-desktop-schemas
(pkgs.makeDesktopItem {
name = "nwggrid";
desktopName = "Application Launcher";
exec = "nwggrid-wrapper";
terminal = false;
type = "Application";
noDisplay = true;
icon = "${config.home.homeDirectory}/.local/share/pixmaps/hyprland-logo-stylix.svg";
})
hyprnome
wlr-randr
wtype
ydotool
wl-clipboard
hyprland-protocols
hyprpicker
inputs.hyprlock.packages.${pkgs.system}.default
hypridle
hyprpaper
fnott
keepmenu
pinentry-gnome3
wev
grim
slurp
libsForQt5.qt5.qtwayland
qt6.qtwayland
xdg-utils
wlsunset
pavucontrol
pamixer
tesseract4
(pkgs.writeScriptBin "workspace-on-monitor" ''
#!/bin/sh
hyprctl monitors -j | jq ".[$1] | .activeWorkspace.id"
'')
(pkgs.writeScriptBin "open-under-ranger" ''
#!/bin/sh
command="$1"
echo $command
file="''${*:2}"
file=''${file// /\\ }
echo $file
workspace=$(hyprctl monitors -j | jq ".[] | select(.specialWorkspace.name == \"special:scratch_ranger\") | .activeWorkspace.id")
if [ -z "''${workspace}" ]; then
hyprctl dispatch exec -- "$command";
else
hyprctl dispatch exec "[workspace $workspace]" -- "$command" "$file";
fi
hyprctl dispatch togglespecialworkspace scratch_ranger
'')
(pkgs.writeScriptBin "screenshot-ocr" ''
#!/bin/sh
imgname="/tmp/screenshot-ocr-$(date +%Y%m%d%H%M%S).png"
txtname="/tmp/screenshot-ocr-$(date +%Y%m%d%H%M%S)"
txtfname=$txtname.txt
grim -g "$(slurp)" $imgname;
tesseract $imgname $txtname;
wl-copy -n < $txtfname
'')
(pkgs.writeScriptBin "sct" ''
#!/bin/sh
killall wlsunset &> /dev/null;
if [ $# -eq 1 ]; then
temphigh=$(( $1 + 1 ))
templow=$1
wlsunset -t $templow -T $temphigh &> /dev/null &
else
killall wlsunset &> /dev/null;
fi
'')
(pkgs.writeScriptBin "obs-notification-mute-daemon" ''
#!/bin/sh
while true; do
if pgrep -x .obs-wrapped > /dev/null;
then
pkill -STOP fnott;
else
pkill -CONT fnott;
fi
sleep 10;
done
'')
(pkgs.writeScriptBin "suspend-unless-render" ''
#!/bin/sh
if pgrep -x nixos-rebuild > /dev/null || pgrep -x home-manager > /dev/null || pgrep -x kdenlive > /dev/null || pgrep -x FL64.exe > /dev/null || pgrep -x blender > /dev/null || pgrep -x flatpak > /dev/null;
then echo "Shouldn't suspend"; sleep 10; else echo "Should suspend"; systemctl suspend; fi
'')
]);
home.file.".local/bin/eww-reload-bars.sh" = {
text = ''#!/bin/sh
eww open-many bar:first bar:second bar:third --arg first:monitor=0 --arg second:monitor=1 --arg third:monitor=2;'';
executable = true;
};
home.file.".config/hypr/hypridle.conf".text = ''
general {
lock_cmd = pgrep hyprlock || hyprlock
before_sleep_cmd = loginctl lock-session
ignore_dbus_inhibit = false
}
#listener {
# timeout = 150 # in seconds
# on-timeout = hyprctl dispatch dpms off
# on-resume = hyprctl dispatch dpms on
#}
listener {
timeout = 165 # in seconds
on-timeout = loginctl lock-session
}
listener {
timeout = 180 # in seconds
#timeout = 5400 # in seconds
on-timeout = systemctl suspend
on-resume = hyprctl dispatch dpms on
}
'';
home.file.".config/hypr/hyprlock.conf".text = ''
background {
monitor =
path = screenshot
# all these options are taken from hyprland, see https://wiki.hyprland.org/Configuring/Variables/#blur for explanations
blur_passes = 4
blur_size = 5
noise = 0.0117
contrast = 0.8916
brightness = 0.8172
vibrancy = 0.1696
vibrancy_darkness = 0.0
}
input-field {
monitor =
size = 200, 50
outline_thickness = 3
dots_size = 0.33 # Scale of input-field height, 0.2 - 0.8
dots_spacing = 0.15 # Scale of dots' absolute size, 0.0 - 1.0
dots_center = false
dots_rounding = -1 # -1 default circle, -2 follow input-field rounding
outer_color = rgb(${config.lib.stylix.colors.base07-rgb-r},${config.lib.stylix.colors.base07-rgb-g},${config.lib.stylix.colors.base07-rgb-b})
inner_color = rgb(${config.lib.stylix.colors.base00-rgb-r},${config.lib.stylix.colors.base00-rgb-g},${config.lib.stylix.colors.base00-rgb-b})
font_color = rgb(${config.lib.stylix.colors.base07-rgb-r},${config.lib.stylix.colors.base07-rgb-g},${config.lib.stylix.colors.base07-rgb-b})
fade_on_empty = true
fade_timeout = 1000 # Milliseconds before fade_on_empty is triggered.
placeholder_text = <i>Input Password...</i> # Text rendered in the input box when it's empty.
hide_input = false
rounding = -1 # -1 means complete rounding (circle/oval)
check_color = rgb(${config.lib.stylix.colors.base0A-rgb-r},${config.lib.stylix.colors.base0A-rgb-g},${config.lib.stylix.colors.base0A-rgb-b})
fail_color = rgb(${config.lib.stylix.colors.base08-rgb-r},${config.lib.stylix.colors.base08-rgb-g},${config.lib.stylix.colors.base08-rgb-b})
fail_text = <i>$FAIL <b>($ATTEMPTS)</b></i> # can be set to empty
fail_transition = 300 # transition time in ms between normal outer_color and fail_color
capslock_color = -1
numlock_color = -1
bothlock_color = -1 # when both locks are active. -1 means don't change outer color (same for above)
invert_numlock = false # change color if numlock is off
swap_font_color = false # see below
position = 0, -20
halign = center
valign = center
}
label {
monitor =
text = Screen Locked
color = rgb(${config.lib.stylix.colors.base07-rgb-r},${config.lib.stylix.colors.base07-rgb-g},${config.lib.stylix.colors.base07-rgb-b})
font_size = 25
font_family = ${font}
rotate = 0 # degrees, counter-clockwise
position = 0, 160
halign = center
valign = center
}
label {
monitor =
text = $TIME12
color = rgb(${config.lib.stylix.colors.base07-rgb-r},${config.lib.stylix.colors.base07-rgb-g},${config.lib.stylix.colors.base07-rgb-b})
font_size = 20
font_family = ${font}
rotate = 0 # degrees, counter-clockwise
position = 0, 80
halign = center
valign = center
}
'';
services.swayosd.enable = true;
services.swayosd.topMargin = 0.5;
services.cbatticon = {
enable = true;
iconType = "symbolic";
};
home.file.".config/eww/eww.yuck".source = ./eww/eww.yuck;
home.file = {
".config/eww/eww.scss".source = config.lib.stylix.colors {
template = builtins.readFile ./eww/eww.scss.mustache;
extension = ".scss";
};
};
home.file.".config/nwg-launchers/nwggrid/style.css".text = ''
button, label, image {
background: none;
border-style: none;
box-shadow: none;
color: #'' + config.lib.stylix.colors.base07 + '';
font-size: 20px;
}
button {
padding: 5px;
margin: 5px;
text-shadow: none;
}
button:hover {
background-color: rgba('' + config.lib.stylix.colors.base07-rgb-r + "," + config.lib.stylix.colors.base07-rgb-g + "," + config.lib.stylix.colors.base07-rgb-b + "," + ''0.15);
}
button:focus {
box-shadow: 0 0 10px;
}
button:checked {
background-color: rgba('' + config.lib.stylix.colors.base07-rgb-r + "," + config.lib.stylix.colors.base07-rgb-g + "," + config.lib.stylix.colors.base07-rgb-b + "," + ''0.15);
}
#searchbox {
background: none;
border-color: #'' + config.lib.stylix.colors.base07 + '';
color: #'' + config.lib.stylix.colors.base07 + '';
margin-top: 20px;
margin-bottom: 20px;
font-size: 20px;
}
#separator {
background-color: rgba('' + config.lib.stylix.colors.base00-rgb-r + "," + config.lib.stylix.colors.base00-rgb-g + "," + config.lib.stylix.colors.base00-rgb-b + "," + ''0.55);
color: #'' + config.lib.stylix.colors.base07 + '';
margin-left: 500px;
margin-right: 500px;
margin-top: 10px;
margin-bottom: 10px
}
#description {
margin-bottom: 20px
}
'';
home.file.".config/nwg-launchers/nwggrid/terminal".text = "alacritty -e";
services.udiskie.enable = true;
services.udiskie.tray = "always";
programs.fuzzel.enable = true;
programs.fuzzel.package = pkgs.fuzzel;
programs.fuzzel.settings = {
main = {
font = font + ":size=20";
dpi-aware = "no";
show-actions = "yes";
terminal = "${pkgs.alacritty}/bin/alacritty";
};
colors = {
background = config.lib.stylix.colors.base00 + "bf";
text = config.lib.stylix.colors.base07 + "ff";
match = config.lib.stylix.colors.base05 + "ff";
selection = config.lib.stylix.colors.base08 + "ff";
selection-text = config.lib.stylix.colors.base00 + "ff";
selection-match = config.lib.stylix.colors.base05 + "ff";
border = config.lib.stylix.colors.base08 + "ff";
};
border = {
width = 3;
radius = 7;
};
};
services.fnott.enable = true;
services.fnott.settings = {
main = {
anchor = "bottom-right";
stacking-order = "top-down";
min-width = 400;
title-font = font + ":size=14";
summary-font = font + ":size=12";
body-font = font + ":size=11";
border-size = 0;
};
low = {
background = config.lib.stylix.colors.base00 + "e6";
title-color = config.lib.stylix.colors.base03 + "ff";
summary-color = config.lib.stylix.colors.base03 + "ff";
body-color = config.lib.stylix.colors.base03 + "ff";
idle-timeout = 150;
max-timeout = 30;
default-timeout = 8;
};
normal = {
background = config.lib.stylix.colors.base00 + "e6";
title-color = config.lib.stylix.colors.base07 + "ff";
summary-color = config.lib.stylix.colors.base07 + "ff";
body-color = config.lib.stylix.colors.base07 + "ff";
idle-timeout = 150;
max-timeout = 30;
default-timeout = 8;
};
critical = {
background = config.lib.stylix.colors.base00 + "e6";
title-color = config.lib.stylix.colors.base08 + "ff";
summary-color = config.lib.stylix.colors.base08 + "ff";
body-color = config.lib.stylix.colors.base08 + "ff";
idle-timeout = 0;
max-timeout = 0;
default-timeout = 0;
};
};
home.file.".config/hypr/hyprpaper.conf".text = ''
preload = ''+config.stylix.image+''
wallpaper = ,''+config.stylix.image+''
'';
};
}

View File

@@ -0,0 +1,78 @@
.bar {
border-radius: 10px;
background: rgba({{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}},0.35);
font-size: 18px;
}
.button {
background: rgba(0,0,0,0.0);
}
.active-workspace {
color: #{{base07-hex}};
background: rgba(0,0,0,0.0);
margin-right: -30px;
margin-left: -30px;
}
.inactive-workspace {
color: #{{base03-hex}};
background: rgba(0,0,0,0.0);
}
.inactive-workspace:hover {
color: #{{base0A-hex}};
}
.calendar_window {
background: rgba({{base01-rgb-r}},{{base01-rgb-g}},{{base01-rgb-b}},0.65);
font-size: 1.2em;
padding: 12px;
border-radius: 10px;
border-width: 0px;
}
.calendar_window:selected {
background: #{{base08-hex}};
}
.calendar_window.header {
background: rgba(0,0,0,0.0);
}
.time-box {
background: rgba(0,0,0,0.0);
margin-right: 5px;
}
.time-box:hover {
}
progressbar trough {
min-width: 30px;
background: #{{base05-hex}};
}
progressbar trough progress {
background: #{{base07-hex}};
}
.battery-text-normal {
color: #{{base07-hex}};
font-size: 10px;
}
.battery-text-danger {
color: #{{base08-hex}};
font-size: 10px;
}
.battery-icon-normal {
color: #{{base07-hex}};
font-size: 20px;
}
.battery-icon-danger {
color: #{{base08-hex}};
font-size: 20px;
}

View File

@@ -0,0 +1,72 @@
(defwindow bar [?monitor]
:monitor monitor
:geometry (geometry :x "0%"
:y "1%"
:width "99%"
:height "30px"
:anchor "top center")
:stacking "fg"
:reserve (struts :distance "5px" :side "top")
:windowtype "dock"
:wm-ignore false
:exclusive true
(bar-widget :monitor monitor))
(defvar workspaces "[1, 2, 3, 4, 5, 6, 7, 8, 9]")
(defvar workspacesreplace "[\"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\"]")
(defpoll workspaces-monitor-0 :interval "1s" "workspace-on-monitor 0")
(defpoll workspaces-monitor-1 :interval "1s" "workspace-on-monitor 1")
(defpoll workspaces-monitor-2 :interval "1s" "workspace-on-monitor 2")
(defvar maxbattery 80)
(defvar batteryicons "[\"\", \"\", \"\", \"\", \"\"]")
(defwidget bar-widget [?monitor]
(box :halign "expand"
(box :orientation "horizontal"
:halign "start"
:class "center-box"
(box :orientation "horizontal"
:spacing "10"
:halign "center"
:valign "center"
(label :text "")
(label :halign "center" :valign "center" :text {EWW_BATTERY.total_avg / maxbattery > 0.8 ? batteryicons[4] : EWW_BATTERY.total_avg / maxbattery > 0.6 ? batteryicons[3] : EWW_BATTERY.total_avg / maxbattery > 0.4 ? batteryicons[2] : EWW_BATTERY.total_avg / maxbattery > 0.2 ? batteryicons[1] : batteryicons[0]} :class {EWW_BATTERY.total_avg / maxbattery > 0.2 ? "battery-icon-normal" : "battery-icon-danger"})
(label :halign "center" :valign "center" :text "${round(EWW_BATTERY.total_avg,0)}%" :class {EWW_BATTERY.total_avg / maxbattery > 0.2 ? "battery-text-normal" : "battery-text-danger"})
)
)
(box :orientation "horizontal"
:spacing "-8"
:halign "center"
:class "center-box"
(for workspace in workspaces
(box :orientation "horizontal"
:halign "center"
:class "center-box"
(button :class {
monitor == 0 ? workspace == workspaces-monitor-0 ? "active-workspace" : "inactive-workspace" :
monitor == 1 ? workspace == workspaces-monitor-1 ? "active-workspace" : "inactive-workspace" : monitor == 2 ? workspace == workspaces-monitor-2 ? "active-workspace" : "inactive-workspace" : "inactive-workspace"} :onclick "hyprctl dispatch focusworkspaceoncurrentmonitor ${workspace}" {workspacesreplace[workspace - 1]})
)))
(box :orientation "horizontal"
:halign "end"
:class "center-box"
:spacing "5"
(button :onclick "eww open --toggle calendar_window --arg monitor=${monitor}" :class "time-box" :halign "end" time)
(systray :class "time-box" :icon-size "20" :spacing "2" :halign "end")
)))
(defvar time-visible false)
(defpoll time :interval "1s"
:initial "initial-value"
:run-while time-visible
`date +%H:%M:%S`)
(defwindow calendar_window [?monitor]
:monitor monitor
:geometry (geometry :width "500px" :height "500px" :x "1410" :y "1%")
:stacking "overlay"
:focusable false
:hexpand true
:vexpand true
:namespace "eww"
(calendar :show-details true))

View File

@@ -0,0 +1,76 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.hyprland.hyprprofiles;
dmenuCmd = config.userSettings.dmenuScripts.dmenuCmd;
qutebrowserEnabled = config.userSettings.qutebrowser.enable;
qutebrowserDefault = (config.userSettings.browser == "qutebrowser");
in
{
options = {
userSettings.hyprland.hyprprofiles = {
enable = lib.mkEnableOption "Enable hyprprofile profile switcher";
# TODO make option for list of profiles
};
};
config = lib.mkIf cfg.enable {
home.packages = [
(pkgs.writeScriptBin "hyprprofile" ''
#!/bin/sh
prevprofile="$(cat ~/.hyprprofile)"
newprofile="$1"
if [ $# -eq 1 ]; then
if [ $newprofile = "Default" ]; then
echo "" > ~/.hyprprofile;
else
echo $newprofile > ~/.hyprprofile;
fi
if [ -f ~/.config/hyprprofiles/$prevprofile/exit-hook.sh ]; then
~/.config/hyprprofiles/$prevprofile/exit-hook.sh;
fi
if [ -f ~/.config/hyprprofiles/$newprofile/start-hook.sh ]; then
~/.config/hyprprofiles/$newprofile/start-hook.sh;
fi
fi
'')
(pkgs.writeScriptBin "hyprprofile-dmenu" ''
#!/bin/sh
choice="$(\ls ~/.config/hyprprofiles | ''+dmenuCmd+'')";
hyprprofile $choice;
'')] ++
lib.optionals qutebrowserEnabled [
(pkgs.writeScriptBin "qutebrowser-hyprprofile" ''
#!/bin/sh
profile="$(cat ~/.hyprprofile)"
if [[ $profile ]]; then
container-open $profile $1;
else
qutebrowser --qt-flag ignore-gpu-blacklist --qt-flag enable-gpu-rasterization --qt-flag enable-native-gpu-memory-buffers --qt-flag enable-accelerated-2d-canvas --qt-flag num-raster-threads=4 $1;
fi
'')
(pkgs.makeDesktopItem {
name = "qutebrowser-hyprprofile";
desktopName = "Qutebrowser Hyprprofile";
exec = "qutebrowser-hyprprofile %u";
categories = ["Network" "WebBrowser"];
keywords = ["Browser"];
terminal = false;
type = "Application";
noDisplay = false;
icon = "qutebrowser";
})
];
xdg.mimeApps.defaultApplications = lib.optionals qutebrowserDefault (lib.mkForce {
"text/html" = "qutebrowser-hyprprofile.desktop";
"x-scheme-handler/http" = "qutebrowser-hyprprofile.desktop";
"x-scheme-handler/https" = "qutebrowser-hyprprofile.desktop";
"x-scheme-handler/about" = "qutebrowser-hyprprofile.desktop";
"x-scheme-handler/unknown" = "qutebrowser-hyprprofile.desktop";
});
home.file.".config/hyprprofiles/" = {
source = ./profiles;
recursive = true;
executable = true;
};
};
}

View File

@@ -0,0 +1,5 @@
#!/bin/sh
hyprctl keyword unbind SUPER,S;
hyprctl keyword bind SUPER,S,exec,qutebrowser-hyprprofile;
emacsclient --eval '(org-roam-switch-db "Personal.p" t)'

View File

@@ -0,0 +1,5 @@
#!/bin/sh
hyprctl keyword unbind SUPER,S;
hyprctl keyword bind SUPER,S,exec,qutebrowser-hyprprofile;
emacsclient --eval '(org-roam-switch-db "Gamedev.s" t)'

View File

@@ -0,0 +1,5 @@
#!/bin/sh
hyprctl keyword unbind SUPER,S;
hyprctl keyword bind SUPER,S,exec,qutebrowser-hyprprofile;
emacsclient --eval '(org-roam-switch-db "Teaching.p" t)'

View File

@@ -0,0 +1,5 @@
#!/bin/sh
hyprctl keyword unbind SUPER,S;
hyprctl keyword bind SUPER,S,exec,qutebrowser-hyprprofile;
emacsclient --eval '(org-roam-switch-db "Producer.p\/LibrePhoenix.p" t)'

View File

@@ -0,0 +1,121 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.japanese;
in {
options = {
userSettings.japanese = {
enable = lib.mkEnableOption "Enable Japanese input";
};
};
config = lib.mkIf cfg.enable {
i18n.inputMethod = {
enabled = "fcitx5";
fcitx5.addons = with pkgs; [
fcitx5-mozc
fcitx5-gtk
];
};
home.file.".config/fcitx5/config".text = ''
[Hotkey]
# Enumerate when press trigger key repeatedly
EnumerateWithTriggerKeys=True
# Temporally switch between first and current Input Method
AltTriggerKeys=
# Enumerate Input Method Forward
EnumerateForwardKeys=
# Enumerate Input Method Backward
EnumerateBackwardKeys=
# Skip first input method while enumerating
EnumerateSkipFirst=False
# Toggle embedded preedit
TogglePreedit=
[Hotkey/TriggerKeys]
0=Super+comma
[Hotkey/EnumerateGroupForwardKeys]
0=Super+space
[Hotkey/EnumerateGroupBackwardKeys]
0=Shift+Super+space
[Hotkey/ActivateKeys]
0=Hangul_Hanja
[Hotkey/DeactivateKeys]
0=Hangul_Romaja
[Hotkey/PrevPage]
0=Up
[Hotkey/NextPage]
0=Down
[Hotkey/PrevCandidate]
0=Shift+Tab
[Hotkey/NextCandidate]
0=Tab
[Behavior]
# Active By Default
ActiveByDefault=False
# Share Input State
ShareInputState=No
# Show preedit in application
PreeditEnabledByDefault=True
# Show Input Method Information when switch input method
ShowInputMethodInformation=True
# Show Input Method Information when changing focus
showInputMethodInformationWhenFocusIn=False
# Show compact input method information
CompactInputMethodInformation=True
# Show first input method information
ShowFirstInputMethodInformation=True
# Default page size
DefaultPageSize=5
# Override Xkb Option
OverrideXkbOption=False
# Custom Xkb Option
CustomXkbOption=
# Force Enabled Addons
EnabledAddons=
# Force Disabled Addons
DisabledAddons=
# Preload input method to be used by default
PreloadInputMethod=True
# Allow input method in the password field
AllowInputMethodForPassword=False
# Show preedit text when typing password
ShowPreeditForPassword=False
# Interval of saving user data in minutes
AutoSavePeriod=30
'';
# home.file.".config/fcitx5/profile".text = ''
# [Groups/0]
# # Group Name
# Name=Default
# # Layout
# Default Layout=us
# # Default Input Method
# DefaultIM=mozc
#
# [Groups/0/Items/0]
# # Name
# Name=keyboard-us
# # Layout
# Layout=
#
# [Groups/0/Items/1]
# # Name
# Name=mozc
# # Layout
# Layout=
#
# [GroupOrder]
# 0=Default
# '';
};
}

View File

@@ -0,0 +1,18 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.keepass;
in {
options = {
userSettings.keepass = {
enable = lib.mkEnableOption "Enable keepass password manager";
};
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
keepassxc
keepmenu
];
};
}

View File

@@ -0,0 +1,42 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.media;
in {
options = {
userSettings.media = {
enable = lib.mkEnableOption "Enable media playback apps";
};
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
vlc
#yt-dlp_git # TODO disabled for debugging
mpv mpc
ncmpcpp
ffmpeg
];
services.mpd = rec {
enable = true;
musicDirectory = config.xdg.userDirs.music+"/Songs";
playlistDirectory = config.xdg.userDirs.music+"/Playlists";
dbFile = musicDirectory+"/mpd.db";
extraConfig = ''
audio_output {
type "pipewire"
name "PipeWire Sound Server"
}
'';
};
programs.ncmpcpp.bindings = [
{ key = "j"; command = "scroll_down"; }
{ key = "k"; command = "scroll_up"; }
{ key = "J"; command = [ "select_item" "scroll_down" ]; }
{ key = "K"; command = [ "select_item" "scroll_up" ]; }
];
};
}

View File

@@ -0,0 +1,69 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.music;
in {
options = {
userSettings.music = {
enable = lib.mkEnableOption "Enable apps for making music";
};
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
ardour
rosegarden
tenacity
mediainfo
easytag
bottles
# The following requires 64-bit FL Studio (FL64) to be installed to a bottle
# With a bottle name of "FL Studio"
(pkgs.writeShellScriptBin "flstudio" ''
#!/bin/sh
if [ -z "$1" ]
then
bottles-cli run -b "FL Studio" -p FL64
#flatpak run --command=bottles-cli com.usebottles.bottles run -b FL\ Studio -p FL64
else
filepath=$(winepath --windows "$1")
echo \'"$filepath"\'
bottles-cli run -b "FL Studio" -p "FL64" --args \'"$filepath"\'
#flatpak run --command=bottles-cli com.usebottles.bottles run -b FL\ Studio -p FL64 -args "$filepath"
fi
'')
(pkgs.makeDesktopItem {
name = "flstudio";
desktopName = "FL Studio 64";
exec = "flstudio %U";
terminal = false;
type = "Application";
icon = "flstudio";
mimeTypes = ["application/octet-stream"];
})
(stdenv.mkDerivation {
name = "flstudio-icon";
# icon from https://www.reddit.com/r/MacOS/comments/jtmp7z/i_made_icons_for_discord_spotify_and_fl_studio_in/
src = [ ./flstudio.png ];
unpackPhase = ''
for srcFile in $src; do
# Copy file into build dir
cp $srcFile ./
done
'';
installPhase = ''
mkdir -p $out $out/share $out/share/pixmaps
ls $src
ls
cp $src $out/share/pixmaps/flstudio.png
'';
})
];
xdg.mimeApps.associations.added = {
"application/octet-stream" = "flstudio.desktop;";
};
};
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

View File

@@ -0,0 +1,31 @@
{ config, lib, pkgs, inputs, ... }:
let
caches = import inputs.secrets.caches;
in {
config = {
nix = {
package = lib.mkForce pkgs.nix;
settings = {
substituters =
(lib.optionals (caches ? urls) caches.urls) ++
[
"https://cache.nixos.org"
"https://hyprland.cachix.org"
"https://nix-community.cachix.org"
];
trusted-public-keys =
(lib.optionals (caches ? publicKeys) caches.publicKeys) ++
[
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
trusted-users = [ "@wheel" ];
auto-optimise-store = true;
download-buffer-size = 500000000;
};
};
home.stateVersion = "22.11";
};
}

View File

@@ -0,0 +1,33 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.office;
in {
options = {
userSettings.office = {
enable = lib.mkEnableOption "Enable my office programs";
};
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
shared-mime-info
nautilus
libreoffice-still
mate.atril
xournalpp
adwaita-icon-theme
newsflash
foliate
gnome-maps
seahorse
element-desktop
openvpn
];
services.syncthing.enable = true;
services.nextcloud-client = {
enable = true;
startInBackground = true;
};
};
}

View File

@@ -0,0 +1,25 @@
#+title: Ranger File Manager
#+author: Emmet
* What is Ranger?
[[https://ranger.github.io/][Ranger]] is a minimalistic TUI file manager controlled with vim keybindings (making it /extremely/ efficient).
[[https://raw.githubusercontent.com/librephoenix/nixos-config-screenshots/main/app/ranger.png]]
If you've never tried a terminal file manager, I suggest you try it out. Here's a quick overview of how to work with it:
- =j= and =k= - Move up and down
- =l= - Move into a directory or open file at point
- =h= - Move up a directory
- =g g= - Move to top
- =G= - Move to bottom
- =SPC= - Mark a file
- =y y= - Copy (yank) file(s)
- =d d= - Cut file(s)
- =p p= - Paste file(s)
- =d T= - Trash file(s)
- =d D= - /Delete/ a file (no undo!)
- =!= - Run a shell command in current directory
- =@= - Run a shell command on file(s)
- =Ctrl-r= - Refresh view
Just like in vim, commands can be given by typing a colon =:= (semicolons =;= also work in ranger!) and typing the command, i.e =:rename newfilename=.

View File

@@ -0,0 +1,183 @@
#!/usr/bin/env python3
# This file is part of ranger, the console file manager.
# License: GNU GPL version 3, see the file "AUTHORS" for details.
from __future__ import (absolute_import, division, print_function)
from ranger.gui.colorscheme import ColorScheme
from ranger.gui.color import (
black, blue, cyan, green, magenta, red, white, yellow, default,
normal, bold, reverse, dim, BRIGHT,
default_colors,
)
class Default(ColorScheme):
progress_bar_color = blue
def use(self, context): # pylint: disable=too-many-branches,too-many-statements
fg, bg, attr = default_colors
if context.reset:
return default_colors
elif context.in_browser:
if context.selected:
attr = reverse
else:
attr = normal
if context.empty or context.error:
bg = red
if context.border:
fg = default
if context.media:
if context.image:
fg = yellow
else:
fg = magenta
if context.container:
fg = red
if context.directory:
attr |= bold
fg = red
fg += BRIGHT
elif context.executable:
attr |= bold
fg = red
fg += BRIGHT
if context.socket:
attr |= bold
fg = magenta
fg += BRIGHT
if context.fifo or context.device:
fg = yellow
if context.device:
attr |= bold
fg += BRIGHT
if context.link:
fg = cyan if context.good else magenta
if context.tag_marker and not context.selected:
attr |= bold
if fg in (red, magenta):
fg = white
else:
fg = red
fg += BRIGHT
if not context.selected and (context.cut or context.copied):
attr |= bold
fg = black
fg += BRIGHT
# If the terminal doesn't support bright colors, use dim white
# instead of black.
if BRIGHT == 0:
attr |= dim
fg = white
if context.main_column:
# Doubling up with BRIGHT here causes issues because it's
# additive not idempotent.
if context.selected:
attr |= bold
if context.marked:
attr |= bold
fg = yellow
if context.badinfo:
if attr & reverse:
bg = magenta
else:
fg = magenta
if context.inactive_pane:
fg = cyan
elif context.in_titlebar:
if context.hostname:
fg = red if context.bad else green
elif context.directory:
fg = red
elif context.tab:
if context.good:
bg = green
elif context.link:
fg = cyan
attr |= bold
elif context.in_statusbar:
if context.permissions:
if context.good:
fg = cyan
elif context.bad:
fg = magenta
if context.marked:
attr |= bold | reverse
fg = yellow
fg += BRIGHT
if context.frozen:
attr |= bold | reverse
fg = cyan
fg += BRIGHT
if context.message:
if context.bad:
attr |= bold
fg = red
fg += BRIGHT
if context.loaded:
bg = self.progress_bar_color
if context.vcsinfo:
fg = blue
attr &= ~bold
if context.vcscommit:
fg = yellow
attr &= ~bold
if context.vcsdate:
fg = cyan
attr &= ~bold
if context.text:
if context.highlight:
attr |= reverse
if context.in_taskview:
if context.title:
fg = blue
if context.selected:
attr |= reverse
if context.loaded:
if context.selected:
fg = self.progress_bar_color
else:
bg = self.progress_bar_color
if context.vcsfile and not context.selected:
attr &= ~bold
if context.vcsconflict:
fg = magenta
elif context.vcsuntracked:
fg = cyan
elif context.vcschanged:
fg = red
elif context.vcsunknown:
fg = red
elif context.vcsstaged:
fg = green
elif context.vcssync:
fg = green
elif context.vcsignored:
fg = default
elif context.vcsremote and not context.selected:
attr &= ~bold
if context.vcssync or context.vcsnone:
fg = green
elif context.vcsbehind:
fg = red
elif context.vcsahead:
fg = blue
elif context.vcsdiverged:
fg = magenta
elif context.vcsunknown:
fg = red
return fg, bg, attr

View File

@@ -0,0 +1,62 @@
# This is a sample commands.py. You can add your own commands here.
#
# Please refer to commands_full.py for all the default commands and a complete
# documentation. Do NOT add them all here, or you may end up with defunct
# commands when upgrading ranger.
# A simple command for demonstration purposes follows.
# -----------------------------------------------------------------------------
from __future__ import (absolute_import, division, print_function)
# You can import any python module as needed.
import os
# You always need to import ranger.api.commands here to get the Command class:
from ranger.api.commands import Command
# Any class that is a subclass of "Command" will be integrated into ranger as a
# command. Try typing ":my_edit<ENTER>" in ranger!
class my_edit(Command):
# The so-called doc-string of the class will be visible in the built-in
# help that is accessible by typing "?c" inside ranger.
""":my_edit <filename>
A sample command for demonstration purposes that opens a file in an editor.
"""
# The execute method is called when you run this command in ranger.
def execute(self):
# self.arg(1) is the first (space-separated) argument to the function.
# This way you can write ":my_edit somefilename<ENTER>".
if self.arg(1):
# self.rest(1) contains self.arg(1) and everything that follows
target_filename = self.rest(1)
else:
# self.fm is a ranger.core.filemanager.FileManager object and gives
# you access to internals of ranger.
# self.fm.thisfile is a ranger.container.file.File object and is a
# reference to the currently selected file.
target_filename = self.fm.thisfile.path
# This is a generic function to print text in ranger.
self.fm.notify("Let's edit the file " + target_filename + "!")
# Using bad=True in fm.notify allows you to print error messages:
if not os.path.exists(target_filename):
self.fm.notify("The given file does not exist!", bad=True)
return
# This executes a function from ranger.core.acitons, a module with a
# variety of subroutines that can help you construct commands.
# Check out the source, or run "pydoc ranger.core.actions" for a list.
self.fm.edit_file(target_filename)
# The tab method is called when you press tab, and should return a list of
# suggestions that the user will tab through.
# tabnum is 1 for <TAB> and -1 for <S-TAB> by default
def tab(self, tabnum):
# This is a generic tab-completion function that iterates through the
# content of the current directory.
return self._tab_directory_content()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,88 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.ranger;
in {
options = {
userSettings.ranger = {
enable = lib.mkEnableOption "Enable ranger file manager";
};
};
config = lib.mkIf cfg.enable {
nixpkgs.overlays = [
(self: super:
{
ranger = super.ranger.overrideAttrs (oldAttrs: rec {
preConfigure = ''
substituteInPlace ranger/__init__.py \
--replace "DEFAULT_PAGER = 'less'" "DEFAULT_PAGER = '${lib.getBin pkgs.bat}/bin/bat'"
# give image previews out of the box when building with w3m
substituteInPlace ranger/config/rc.conf \
--replace "set preview_images false" "set preview_images true"
# adds this patch: https://github.com/ranger/ranger/pull/1758
# fixes a bug for kitty users that use image previews
substituteInPlace ranger/ext/img_display.py \
--replace "self.image_id -= 1" "self.image_id = max(0, self.image_id - 1)"
# fixes the .desktop file
substituteInPlace doc/ranger.desktop \
--replace "Icon=utilities-terminal" "Icon=user-desktop"
substituteInPlace doc/ranger.desktop \
--replace "Terminal=true" "Terminal=false"
substituteInPlace doc/ranger.desktop \
--replace "Exec=ranger" "Exec=kitty -e ranger %U"
'';
});
}
)
];
home.packages = with pkgs; [
ranger
ripdrag
highlight
poppler_utils
librsvg
ffmpegthumbnailer
# TODO fix cbx script
(pkgs.writeScriptBin "cbx" ''
# this lets my copy and paste images and/or plaintext of files directly out of ranger
if [ "$#" -le "2" ]; then
if [ "$1" = "copy" -o "$1" = "cut" ]; then
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
wl-copy < $2;
else
# xclip -selection clipboard -t $(file -b --mime-type $2) -i $2;
xclip -selection clipboard -t image/png -i $2;
fi
fi
fi
'')
];
xdg.mimeApps.associations.added = {
"inode/directory" = "ranger.desktop";
};
home.file.".config/ranger/rc.conf".source = ./rc.conf;
home.file.".config/ranger/rifle.conf".source = ./rifle.conf;
home.file.".config/ranger/scope.sh" = {
source = ./scope.sh;
executable = true;
};
home.file.".config/ranger/commands.py" = {
source = ./commands.py;
executable = true;
};
home.file.".config/ranger/commands_full.py" = {
source = ./commands_full.py;
executable = true;
};
home.file.".config/ranger/colorschemes/hail.py" = {
source = ./colorschemes/hail.py;
executable = true;
};
};
}

764
modules/user/ranger/rc.conf Normal file
View File

@@ -0,0 +1,764 @@
# ===================================================================
# This file contains the default startup commands for ranger.
# To change them, it is recommended to create either /etc/ranger/rc.conf
# (system-wide) or ~/.config/ranger/rc.conf (per user) and add your custom
# commands there.
#
# If you copy this whole file there, you may want to set the environment
# variable RANGER_LOAD_DEFAULT_RC to FALSE to avoid loading it twice.
#
# The purpose of this file is mainly to define keybindings and settings.
# For running more complex python code, please create a plugin in "plugins/" or
# a command in "commands.py".
#
# Each line is a command that will be run before the user interface
# is initialized. As a result, you can not use commands which rely
# on the UI such as :delete or :mark.
# ===================================================================
# ===================================================================
# == Options
# ===================================================================
# Which viewmode should be used? Possible values are:
# miller: Use miller columns which show multiple levels of the hierarchy
# multipane: Midnight-commander like multipane view showing all tabs next
# to each other
set viewmode miller
#set viewmode multipane
# How many columns are there, and what are their relative widths?
set column_ratios 1,3,4
# Which files should be hidden? (regular expression)
set hidden_filter ^\.|\.(?:pyc|pyo|bak|swp)$|^lost\+found$|^__(py)?cache__$
# Show hidden files? You can toggle this by typing 'zh'
set show_hidden false
# Ask for a confirmation when running the "delete" command?
# Valid values are "always", "never", "multiple" (default)
# With "multiple", ranger will ask only if you delete multiple files at once.
set confirm_on_delete multiple
# Use non-default path for file preview script?
# ranger ships with scope.sh, a script that calls external programs (see
# README.md for dependencies) to preview images, archives, etc.
set preview_script ~/.config/ranger/scope.sh
# Use the external preview script or display simple plain text or image previews?
set use_preview_script true
# Automatically count files in the directory, even before entering them?
set automatically_count_files true
# Open all images in this directory when running certain image viewers
# like feh or sxiv? You can still open selected files by marking them.
set open_all_images true
# Be aware of version control systems and display information.
set vcs_aware false
# State of the four backends git, hg, bzr, svn. The possible states are
# disabled, local (only show local info), enabled (show local and remote
# information).
set vcs_backend_git enabled
set vcs_backend_hg disabled
set vcs_backend_bzr disabled
set vcs_backend_svn disabled
# Truncate the long commit messages to this length when shown in the statusbar.
set vcs_msg_length 50
# Use one of the supported image preview protocols
set preview_images true
# Set the preview image method. Supported methods:
#
# * w3m (default):
# Preview images in full color with the external command "w3mimgpreview"?
# This requires the console web browser "w3m" and a supported terminal.
# It has been successfully tested with "xterm" and "urxvt" without tmux.
#
# * iterm2:
# Preview images in full color using iTerm2 image previews
# (http://iterm2.com/images.html). This requires using iTerm2 compiled
# with image preview support.
#
# This feature relies on the dimensions of the terminal's font. By default, a
# width of 8 and height of 11 are used. To use other values, set the options
# iterm2_font_width and iterm2_font_height to the desired values.
#
# * terminology:
# Previews images in full color in the terminology terminal emulator.
# Supports a wide variety of formats, even vector graphics like svg.
#
# * urxvt:
# Preview images in full color using urxvt image backgrounds. This
# requires using urxvt compiled with pixbuf support.
#
# * urxvt-full:
# The same as urxvt but utilizing not only the preview pane but the
# whole terminal window.
#
# * kitty:
# Preview images in full color using kitty image protocol.
# Requires python PIL or pillow library.
# If ranger does not share the local filesystem with kitty
# the transfer method is changed to encode the whole image;
# while slower, this allows remote previews,
# for example during an ssh session.
# Tmux is unsupported.
#
# * ueberzug:
# Preview images in full color with the external command "ueberzug".
# Images are shown by using a child window.
# Only for users who run X11 in GNU/Linux.
set preview_images_method kitty
# Delay in seconds before displaying an image with the w3m method.
# Increase it in case of experiencing display corruption.
set w3m_delay 0.02
# Manually adjust the w3mimg offset when using a terminal which needs this
set w3m_offset 0
# Default iTerm2 font size (see: preview_images_method: iterm2)
set iterm2_font_width 8
set iterm2_font_height 11
# Use a unicode "..." character to mark cut-off filenames?
set unicode_ellipsis false
# BIDI support - try to properly display file names in RTL languages (Hebrew, Arabic).
# Requires the python-bidi pip package
set bidi_support false
# Show dotfiles in the bookmark preview box?
set show_hidden_bookmarks true
# Which colorscheme to use? These colorschemes are available by default:
# default, jungle, snow, solarized
set colorscheme hail
# Preview files on the rightmost column?
# And collapse (shrink) the last column if there is nothing to preview?
set preview_files true
set preview_directories false
set collapse_preview true
# Wrap long lines in plain text previews?
set wrap_plaintext_previews false
# Save the console history on exit?
set save_console_history true
# Draw the status bar on top of the browser window (default: bottom)
set status_bar_on_top false
# Draw a progress bar in the status bar which displays the average state of all
# currently running tasks which support progress bars?
set draw_progress_bar_in_status_bar true
# Draw borders around columns? (separators, outline, both, or none)
# Separators are vertical lines between columns.
# Outline draws a box around all the columns.
# Both combines the two.
set draw_borders none
# Display the directory name in tabs?
set dirname_in_tabs false
# Enable the mouse support?
set mouse_enabled true
# Display the file size in the main column or status bar?
set display_size_in_main_column true
set display_size_in_status_bar true
# Display the free disk space in the status bar?
set display_free_space_in_status_bar true
# Display files tags in all columns or only in main column?
set display_tags_in_all_columns true
# Set a title for the window? Updates both `WM_NAME` and `WM_ICON_NAME`
set update_title false
# Set the tmux/screen window-name to "ranger"?
set update_tmux_title true
# Shorten the title if it gets long? The number defines how many
# directories are displayed at once, 0 turns off this feature.
set shorten_title 3
# Show hostname in titlebar?
set hostname_in_titlebar true
# Abbreviate $HOME with ~ in the titlebar (first line) of ranger?
set tilde_in_titlebar false
# How many directory-changes or console-commands should be kept in history?
set max_history_size 20
set max_console_history_size 50
# Try to keep so much space between the top/bottom border when scrolling:
set scroll_offset 8
# Flush the input after each key hit? (Noticeable when ranger lags)
set flushinput true
# Padding on the right when there's no preview?
# This allows you to click into the space to run the file.
set padding_right true
# Save bookmarks (used with mX and `X) instantly?
# This helps to synchronize bookmarks between multiple ranger
# instances but leads to *slight* performance loss.
# When false, bookmarks are saved when ranger is exited.
set autosave_bookmarks true
# Save the "`" bookmark to disk. This can be used to switch to the last
# directory by typing "``".
set save_backtick_bookmark true
# You can display the "real" cumulative size of directories by using the
# command :get_cumulative_size or typing "dc". The size is expensive to
# calculate and will not be updated automatically. You can choose
# to update it automatically though by turning on this option:
set autoupdate_cumulative_size false
# Turning this on makes sense for screen readers:
set show_cursor false
# One of: size, natural, basename, atime, ctime, mtime, type, random
set sort basename
# Additional sorting options
set sort_reverse false
set sort_case_insensitive true
set sort_directories_first true
set sort_unicode false
# Enable this if key combinations with the Alt Key don't work for you.
# (Especially on xterm)
set xterm_alt_key false
# Whether to include bookmarks in cd command
set cd_bookmarks true
# Changes case sensitivity for the cd command tab completion
set cd_tab_case sensitive
# Use fuzzy tab completion with the "cd" command. For example,
# ":cd /u/lo/b<tab>" expands to ":cd /usr/local/bin".
set cd_tab_fuzzy false
# Avoid previewing files larger than this size, in bytes. Use a value of 0 to
# disable this feature.
set preview_max_size 0
# The key hint lists up to this size have their sublists expanded.
# Otherwise the submaps are replaced with "...".
set hint_collapse_threshold 10
# Add the highlighted file to the path in the titlebar
set show_selection_in_titlebar true
# The delay that ranger idly waits for user input, in milliseconds, with a
# resolution of 100ms. Lower delay reduces lag between directory updates but
# increases CPU load.
set idle_delay 2000
# When the metadata manager module looks for metadata, should it only look for
# a ".metadata.json" file in the current directory, or do a deep search and
# check all directories above the current one as well?
set metadata_deep_search false
# Clear all existing filters when leaving a directory
set clear_filters_on_dir_change false
# Disable displaying line numbers in main column.
# Possible values: false, absolute, relative.
set line_numbers false
# When line_numbers=relative show the absolute line number in the
# current line.
set relative_current_zero false
# Start line numbers from 1 instead of 0
set one_indexed false
# Save tabs on exit
set save_tabs_on_exit false
# Enable scroll wrapping - moving down while on the last item will wrap around to
# the top and vice versa.
set wrap_scroll true
# Set the global_inode_type_filter to nothing. Possible options: d, f and l for
# directories, files and symlinks respectively.
set global_inode_type_filter
# This setting allows to freeze the list of files to save I/O bandwidth. It
# should be 'false' during start-up, but you can toggle it by pressing F.
set freeze_files false
# Print file sizes in bytes instead of the default human-readable format.
set size_in_bytes false
# Warn at startup if RANGER_LEVEL env var is greater than 0, in other words
# give a warning when you nest ranger in a subshell started by ranger.
# Special value "error" makes the warning more visible.
set nested_ranger_warning true
# ===================================================================
# == Local Options
# ===================================================================
# You can set local options that only affect a single directory.
# Examples:
# setlocal path=~/downloads sort mtime
# ===================================================================
# == Command Aliases in the Console
# ===================================================================
alias e edit
alias q quit
alias q! quit!
alias qa quitall
alias qa! quitall!
alias qall quitall
alias qall! quitall!
alias setl setlocal
alias filter scout -prts
alias find scout -aets
alias mark scout -mr
alias unmark scout -Mr
alias search scout -rs
alias search_inc scout -rts
alias travel scout -aefklst
# ===================================================================
# == Define keys for the browser
# ===================================================================
# Basic
map Q quitall
map q quit
copymap q ZZ ZQ
map R reload_cwd
map F set freeze_files!
map <C-r> reset
map <C-l> redraw_window
map <C-c> abort
map <esc> change_mode normal
map ~ set viewmode!
map i display_file
map <A-j> scroll_preview 1
map <A-k> scroll_preview -1
map ? help
map W display_log
map w taskview_open
map S shell $SHELL
map : console
map ; console
map ! console shell%space
map @ console -p6 shell %%s
map # console shell -p%space
map s console shell%space
map r chain draw_possible_programs; console open_with%space
map f console find%space
map cd console cd%space
map <C-p> chain console; eval fm.ui.console.history_move(-1)
# Change the line mode
map Mf linemode filename
map Mi linemode fileinfo
map Mm linemode mtime
map Mh linemode humanreadablemtime
map Mp linemode permissions
map Ms linemode sizemtime
map MH linemode sizehumanreadablemtime
map Mt linemode metatitle
# Tagging / Marking
map t tag_toggle
map ut tag_remove
map "<any> tag_toggle tag=%any
map <Space> mark_files toggle=True
map v mark_files all=True toggle=True
map uv mark_files all=True val=False
map V toggle_visual_mode
map uV toggle_visual_mode reverse=True
# For the nostalgics: Midnight Commander bindings
map <F1> help
map <F2> rename_append
map <F3> display_file
map <F4> edit
map <F5> copy
map <F6> cut
map <F7> console mkdir%space
map <F8> console delete
#map <F8> console trash
map <F10> exit
# In case you work on a keyboard with dvorak layout
map <UP> move up=1
map <DOWN> move down=1
map <LEFT> move left=1
map <RIGHT> move right=1
map <HOME> move to=0
map <END> move to=-1
map <PAGEDOWN> move down=1 pages=True
map <PAGEUP> move up=1 pages=True
map <CR> move right=1
#map <DELETE> console delete
map <INSERT> console touch%space
# VIM-like
copymap <UP> k
copymap <DOWN> j
copymap <LEFT> h
copymap <RIGHT> l
copymap <HOME> gg
copymap <END> G
copymap <PAGEDOWN> <C-F>
copymap <PAGEUP> <C-B>
map J move down=0.5 pages=True
map K move up=0.5 pages=True
copymap J <C-D>
copymap K <C-U>
# Jumping around
map H history_go -1
map L history_go 1
map ] move_parent 1
map [ move_parent -1
map } traverse
map { traverse_backwards
map ) jump_non
map gh chain set sort=basename; set sort_reverse=False; cd ~
map ga cd ~/Archive
map gd cd ~/Downloads
map gm cd ~/Media
map go cd ~/Org
map gp cd ~/Projects
map gD cd ~/.dotfiles
map ge cd /etc
map gv cd /var
map gi chain reset; cd ~/External
map gM cd /mnt
map gs cd /srv
map gP cd /tmp
map g/ cd /
map g? cd /usr/share/doc/ranger
map glr chain set sort=mtime; set sort_reverse=False; cd ~/Org/Producer.p/LibrePhoenix.p/Notes/recordings
map glp chain set sort=mtime; set sort_reverse=False; cd ~/Org/Producer.p/LibrePhoenix.p/Notes/projects
map glf cd ~/Org/Producer.p/LibrePhoenix.p/Notes/files
# External Programs
map E edit
map du shell -p du --max-depth=1 -h --apparent-size
map dU shell -p du --max-depth=1 -h --apparent-size | sort -rh
map do shell cp %s ~/.discord_launchpad/ && dragon-drop ~/.discord_launchpad/%s && rm ~/.discord_launchpad/%s &
map yp yank path
map yd yank dir
map yn yank name
map y. yank name_without_extension
# Filesystem Operations
map = chmod
map cw console rename%space
map a rename_append
map A eval fm.open_console('rename ' + fm.thisfile.relative_path.replace("%", "%%"))
map I eval fm.open_console('rename ' + fm.thisfile.relative_path.replace("%", "%%"), position=7)
map pp paste
map po paste overwrite=True
map pP paste append=True
map pO paste overwrite=True append=True
map pl paste_symlink relative=False
map pL paste_symlink relative=True
map phl paste_hardlink
map pht paste_hardlinked_subtree
map pd console paste dest=
map p`<any> paste dest=%any_path
map p'<any> paste dest=%any_path
map dD console delete
map dT console trash
map dd cut
map ud uncut
map da cut mode=add
map dr cut mode=remove
map dt cut mode=toggle
map do shell -w ripdrag -n -b -a %s
map dO shell -w ripdrag -n -b %s
map yy chain copy; shell cbx copy %s
map uy uncut
map ya copy mode=add
map yr copy mode=remove
map yt copy mode=toggle
# Temporary workarounds
map dgg eval fm.cut(dirarg=dict(to=0), narg=quantifier)
map dG eval fm.cut(dirarg=dict(to=-1), narg=quantifier)
map dj eval fm.cut(dirarg=dict(down=1), narg=quantifier)
map dk eval fm.cut(dirarg=dict(up=1), narg=quantifier)
map ygg eval fm.copy(dirarg=dict(to=0), narg=quantifier)
map yG eval fm.copy(dirarg=dict(to=-1), narg=quantifier)
map yj eval fm.copy(dirarg=dict(down=1), narg=quantifier)
map yk eval fm.copy(dirarg=dict(up=1), narg=quantifier)
# Searching
map / console search%space
map n search_next
map N search_next forward=False
map ct search_next order=tag
map cs search_next order=size
map ci search_next order=mimetype
map cc search_next order=ctime
map cm search_next order=mtime
map ca search_next order=atime
# Tabs
map <C-n> tab_new
map <C-w> tab_close
map <TAB> tab_move 1
map <S-TAB> tab_move -1
map <A-Right> tab_move 1
map <A-Left> tab_move -1
map gt tab_move 1
map gT tab_move -1
map gn tab_new
map gc tab_close
map uq tab_restore
map <a-1> tab_open 1
map <a-2> tab_open 2
map <a-3> tab_open 3
map <a-4> tab_open 4
map <a-5> tab_open 5
map <a-6> tab_open 6
map <a-7> tab_open 7
map <a-8> tab_open 8
map <a-9> tab_open 9
map <a-r> tab_shift 1
map <a-l> tab_shift -1
# Sorting
map or set sort_reverse!
map oz set sort=random
map os chain set sort=size; set sort_reverse=False
map ob chain set sort=basename; set sort_reverse=False
map on chain set sort=natural; set sort_reverse=False
map om chain set sort=mtime; set sort_reverse=False
map oc chain set sort=ctime; set sort_reverse=False
map oa chain set sort=atime; set sort_reverse=False
map ot chain set sort=type; set sort_reverse=False
map oe chain set sort=extension; set sort_reverse=False
map oS chain set sort=size; set sort_reverse=True
map oB chain set sort=basename; set sort_reverse=True
map oN chain set sort=natural; set sort_reverse=True
map oM chain set sort=mtime; set sort_reverse=True
map oC chain set sort=ctime; set sort_reverse=True
map oA chain set sort=atime; set sort_reverse=True
map oT chain set sort=type; set sort_reverse=True
map oE chain set sort=extension; set sort_reverse=True
map dc get_cumulative_size
# Settings
map zc set collapse_preview!
map zd set sort_directories_first!
map zh set show_hidden!
map <C-h> set show_hidden!
copymap <C-h> <backspace>
copymap <backspace> <backspace2>
map zI set flushinput!
map zi set preview_images!
map zm set mouse_enabled!
map zp set preview_files!
map zP set preview_directories!
map zs set sort_case_insensitive!
map zu set autoupdate_cumulative_size!
map zv set use_preview_script!
map zf console filter%space
copymap zf zz
# Filter stack
map .d filter_stack add type d
map .f filter_stack add type f
map .l filter_stack add type l
map .m console filter_stack add mime%space
map .n console filter_stack add name%space
map .# console filter_stack add hash%space
map ." filter_stack add duplicate
map .' filter_stack add unique
map .| filter_stack add or
map .& filter_stack add and
map .! filter_stack add not
map .r filter_stack rotate
map .c filter_stack clear
map .* filter_stack decompose
map .p filter_stack pop
map .. filter_stack show
# Bookmarks
map `<any> enter_bookmark %any
map '<any> enter_bookmark %any
map m<any> set_bookmark %any
map um<any> unset_bookmark %any
map m<bg> draw_bookmarks
copymap m<bg> um<bg> `<bg> '<bg>
# Generate all the chmod bindings with some python help:
eval for arg in "rwxXst": cmd("map +u{0} shell -f chmod u+{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map +g{0} shell -f chmod g+{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map +o{0} shell -f chmod o+{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map +a{0} shell -f chmod a+{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map +{0} shell -f chmod u+{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map -u{0} shell -f chmod u-{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map -g{0} shell -f chmod g-{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map -o{0} shell -f chmod o-{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map -a{0} shell -f chmod a-{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map -{0} shell -f chmod u-{0} %s".format(arg))
# ===================================================================
# == Define keys for the console
# ===================================================================
# Note: Unmapped keys are passed directly to the console.
# Basic
cmap <tab> eval fm.ui.console.tab()
cmap <s-tab> eval fm.ui.console.tab(-1)
cmap <ESC> eval fm.ui.console.close()
cmap <CR> eval fm.ui.console.execute()
cmap <C-l> redraw_window
copycmap <ESC> <C-c>
copycmap <CR> <C-j>
# Move around
cmap <up> eval fm.ui.console.history_move(-1)
cmap <down> eval fm.ui.console.history_move(1)
cmap <left> eval fm.ui.console.move(left=1)
cmap <right> eval fm.ui.console.move(right=1)
cmap <home> eval fm.ui.console.move(right=0, absolute=True)
cmap <end> eval fm.ui.console.move(right=-1, absolute=True)
cmap <a-b> eval fm.ui.console.move_word(left=1)
cmap <a-f> eval fm.ui.console.move_word(right=1)
copycmap <a-b> <a-left>
copycmap <a-f> <a-right>
# Line Editing
cmap <backspace> eval fm.ui.console.delete(-1)
cmap <delete> eval fm.ui.console.delete(0)
cmap <C-w> eval fm.ui.console.delete_word()
cmap <A-d> eval fm.ui.console.delete_word(backward=False)
cmap <C-k> eval fm.ui.console.delete_rest(1)
cmap <C-u> eval fm.ui.console.delete_rest(-1)
cmap <C-y> eval fm.ui.console.paste()
# And of course the emacs way
copycmap <ESC> <C-g>
copycmap <up> <C-p>
copycmap <down> <C-n>
copycmap <left> <C-b>
copycmap <right> <C-f>
copycmap <home> <C-a>
copycmap <end> <C-e>
copycmap <delete> <C-d>
copycmap <backspace> <C-h>
# Note: There are multiple ways to express backspaces. <backspace> (code 263)
# and <backspace2> (code 127). To be sure, use both.
copycmap <backspace> <backspace2>
# This special expression allows typing in numerals:
cmap <allow_quantifiers> false
# ===================================================================
# == Pager Keybindings
# ===================================================================
# Movement
pmap <down> pager_move down=1
pmap <up> pager_move up=1
pmap <left> pager_move left=4
pmap <right> pager_move right=4
pmap <home> pager_move to=0
pmap <end> pager_move to=-1
pmap <pagedown> pager_move down=1.0 pages=True
pmap <pageup> pager_move up=1.0 pages=True
pmap <C-d> pager_move down=0.5 pages=True
pmap <C-u> pager_move up=0.5 pages=True
copypmap <UP> k <C-p>
copypmap <DOWN> j <C-n> <CR>
copypmap <LEFT> h
copypmap <RIGHT> l
copypmap <HOME> g
copypmap <END> G
copypmap <C-d> d
copypmap <C-u> u
copypmap <PAGEDOWN> n f <C-F> <Space>
copypmap <PAGEUP> p b <C-B>
# Basic
pmap <C-l> redraw_window
pmap <ESC> pager_close
copypmap <ESC> q Q i <F3>
pmap E edit_file
# ===================================================================
# == Taskview Keybindings
# ===================================================================
# Movement
tmap <up> taskview_move up=1
tmap <down> taskview_move down=1
tmap <home> taskview_move to=0
tmap <end> taskview_move to=-1
tmap <pagedown> taskview_move down=1.0 pages=True
tmap <pageup> taskview_move up=1.0 pages=True
tmap <C-d> taskview_move down=0.5 pages=True
tmap <C-u> taskview_move up=0.5 pages=True
copytmap <UP> k <C-p>
copytmap <DOWN> j <C-n> <CR>
copytmap <HOME> g
copytmap <END> G
copytmap <C-u> u
copytmap <PAGEDOWN> n f <C-F> <Space>
copytmap <PAGEUP> p b <C-B>
# Changing priority and deleting tasks
tmap J eval -q fm.ui.taskview.task_move(-1)
tmap K eval -q fm.ui.taskview.task_move(0)
tmap dd eval -q fm.ui.taskview.task_remove()
tmap <pagedown> eval -q fm.ui.taskview.task_move(-1)
tmap <pageup> eval -q fm.ui.taskview.task_move(0)
tmap <delete> eval -q fm.ui.taskview.task_remove()
# Basic
tmap <C-l> redraw_window
tmap <ESC> taskview_close
copytmap <ESC> q Q w <C-c>

View File

@@ -0,0 +1,233 @@
# vim: ft=cfg
#
# This is the configuration file of "rifle", ranger's file executor/opener.
# Each line consists of conditions and a command. For each line the conditions
# are checked and if they are met, the respective command is run.
#
# Syntax:
# <condition1> , <condition2> , ... = command
#
# The command can contain these environment variables:
# $1-$9 | The n-th selected file
# $@ | All selected files
#
# If you use the special command "ask", rifle will ask you what program to run.
#
# Prefixing a condition with "!" will negate its result.
# These conditions are currently supported:
# match <regexp> | The regexp matches $1
# ext <regexp> | The regexp matches the extension of $1
# mime <regexp> | The regexp matches the mime type of $1
# name <regexp> | The regexp matches the basename of $1
# path <regexp> | The regexp matches the absolute path of $1
# has <program> | The program is installed (i.e. located in $PATH)
# env <variable> | The environment variable "variable" is non-empty
# file | $1 is a file
# directory | $1 is a directory
# number <n> | change the number of this command to n
# terminal | stdin, stderr and stdout are connected to a terminal
# X | A graphical environment is available (darwin, Xorg, or Wayland)
#
# There are also pseudo-conditions which have a "side effect":
# flag <flags> | Change how the program is run. See below.
# label <label> | Assign a label or name to the command so it can
# | be started with :open_with <label> in ranger
# | or `rifle -p <label>` in the standalone executable.
# else | Always true.
#
# Flags are single characters which slightly transform the command:
# f | Fork the program, make it run in the background.
# | New command = setsid $command >& /dev/null &
# r | Execute the command with root permissions
# | New command = sudo $command
# t | Run the program in a new terminal. If $TERMCMD is not defined,
# | rifle will attempt to extract it from $TERM.
# | New command = $TERMCMD -e $command
# Note: The "New command" serves only as an illustration, the exact
# implementation may differ.
# Note: When using rifle in ranger, there is an additional flag "c" for
# only running the current file even if you have marked multiple files.
#-------------------------------------------
# Websites
#-------------------------------------------
# Rarely installed browsers get higher priority; It is assumed that if you
# install a rare browser, you probably use it. Firefox/konqueror/w3m on the
# other hand are often only installed as fallback browsers.
ext x?html?, has librewolf, X, flag f = open-under-ranger librewolf "$@"
ext x?html?, has qutebrowser, X, flag f = open-under-ranger qutebrowser "$@"
ext x?html?, has firefox, X, flag f = open-under-ranger firefox "$@"
ext x?html?, has chromium-browser, X, flag f = open-under-ranger chromium-browser "$@"
ext x?html?, has chromium, X, flag f = open-under-ranger chromium "$@"
ext x?html?, has w3m, terminal = w3m "$@"
#-------------------------------------------
# Misc
#-------------------------------------------
# Define the "editor" for text files as first action
mime ^text, has neovide, X, flag f = open-under-ranger neovide "$@"
ext org, has emacsclient, X, flag f = open-under-ranger "emacsclient -c" "$@"
mime ^text, has emacsclient, X, flag f = open-under-ranger "emacsclient -c" "$@"
ext 1 = man "$1"
ext s[wmf]c, has zsnes, X = zsnes "$1"
ext s[wmf]c, has snes9x-gtk,X = snes9x-gtk "$1"
ext nes, has fceux, X = fceux "$1"
#ext exe = wine "$1"
name ^[mM]akefile$ = make
#------------------------------------------
# My applications
#------------------------------------------
ext kra, has krita, X, flag f = open-under-ranger krita "$@" &>/dev/null
ext kra~, has krita, X, flag f = open-under-ranger krita "$@" &>/dev/null
ext blend, has blender, X, flag f = open-under-ranger blender "$@" &>/dev/null
ext blend~, has blender, X, flag f = open-under-ranger blender "$@" &>/dev/null
ext xopp, has xournalpp, X, flag f = open-under-ranger xournalpp "$@" &>/dev/null
ext xopp~, has blender, X, flag f = open-under-ranger xournalpp "$@" &>/dev/null
ext helio, has helio, X, flag f = open-under-ranger helio "$@" &>/dev/null
ext kdenlive, has kdenlive, X, flag f = open-under-ranger kdenlive "$@" &>/dev/null
ext flp, has flstudio, X, flag f = open-under-ranger flstudio "$@" &>/dev/null
ext 3mf, has Cura, X, flag f = open-under-ranger Cura "$@" &>/dev/null
ext 3mf, has curax, X, flag f = open-under-ranger curax "$@" &>/dev/null
ext 3mf, has cura, X flag f = open-under-ranger cura "$@" &>/dev/null
#--------------------------------------------
# Scripts
#-------------------------------------------
ext py = python -- "$1"
ext pl = perl -- "$1"
ext rb = ruby -- "$1"
ext js = node -- "$1"
ext sh = sh -- "$1"
ext php = php -- "$1"
#--------------------------------------------
# Audio without X
#-------------------------------------------
mime ^audio|ogg$, terminal, has mpv = mpv -- "$@"
mime ^audio|ogg$, terminal, has mplayer2 = mplayer2 -- "$@"
mime ^audio|ogg$, terminal, has mplayer = mplayer -- "$@"
ext midi?, terminal, has wildmidi = wildmidi -- "$@"
#--------------------------------------------
# Video/Audio with a GUI
#-------------------------------------------
mime ^video, has mpv, X, flag f = open-under-ranger mpv "$@"
mime ^video, has mplayer2, X, flag f = open-under-ranger mplayer2 "$@"
mime ^video, has mplayer, X, flag f = open-under-ranger mplayer "$@"
mime ^video|audio, has vlc, X, flag f = open-under-ranger vlc "$@"
#--------------------------------------------
# Video without X
#-------------------------------------------
mime ^video, terminal, !X, has mpv = mpv -- "$@"
mime ^video, terminal, !X, has mplayer2 = mplayer2 -- "$@"
mime ^video, terminal, !X, has mplayer = mplayer -- "$@"
#-------------------------------------------
# Documents
#-------------------------------------------
ext pdf, has atril, X, flag f = open-under-ranger atril "$@"
ext djvu, has atril, X, flag f = open-under-ranger atril "$@"
ext epub, has foliate, X, flag f = open-under-ranger foliate "$@"
ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has libreoffice, X, flag f = soffice "$@"
ext cbr, has zathura, X, flag f = open-under-ranger zathura "$@"
ext cbz, has zathura, X, flag f = open-under-ranger zathura "$@"
#-------------------------------------------
# Images
#-------------------------------------------
mime ^image/svg, has inkscape, X, flag f = open-under-ranger inkscape "$@"
mime ^image, has pinta, X, flag f = open-under-ranger pinta "$@"
mime ^image, has krita, X, flag f = open-under-ranger krita "$@"
#-------------------------------------------
# Archives
#-------------------------------------------
# avoid password prompt by providing empty password
ext 7z, has 7z = 7z -p l "$@" | "$PAGER"
# This requires atool
ext ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --list --each -- "$@" | "$PAGER"
ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --list --each -- "$@" | "$PAGER"
ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --extract --each -- "$@"
ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --extract --each -- "$@"
# Listing and extracting archives without atool:
ext tar|gz|bz2|xz, has tar = tar vvtf "$1" | "$PAGER"
ext tar|gz|bz2|xz, has tar = for file in "$@"; do tar vvxf "$file"; done
ext bz2, has bzip2 = for file in "$@"; do bzip2 -dk "$file"; done
ext zip, has unzip = unzip -l "$1" | less
ext zip, has unzip = for file in "$@"; do unzip -d "${file%.*}" "$file"; done
ext ace, has unace = unace l "$1" | less
ext ace, has unace = for file in "$@"; do unace e "$file"; done
ext rar, has unrar = unrar l "$1" | less
ext rar, has unrar = for file in "$@"; do unrar x "$file"; done
#-------------------------------------------
# Fonts
#-------------------------------------------
mime ^font, has fontforge, X, flag f = open-under-ranger fontforge "$@"
#-------------------------------------------
# Flag t fallback terminals
#-------------------------------------------
# Rarely installed terminal emulators get higher priority; It is assumed that
# if you install a rare terminal emulator, you probably use it.
# gnome-terminal/konsole/xterm on the other hand are often installed as part of
# a desktop environment or as fallback terminal emulators.
mime ^ranger/x-terminal-emulator, has alacritty = open-under-ranger alacritty -e "$@"
mime ^ranger/x-terminal-emulator, has sakura = open-under-ranger sakura -e "$@"
mime ^ranger/x-terminal-emulator, has lilyterm = open-under-ranger lilyterm -e "$@"
#mime ^ranger/x-terminal-emulator, has cool-retro-term = cool-retro-term -e "$@"
mime ^ranger/x-terminal-emulator, has termite = open-under-ranger termite -x '"$@"'
#mime ^ranger/x-terminal-emulator, has yakuake = yakuake -e "$@"
mime ^ranger/x-terminal-emulator, has guake = open-under-ranger guake -ne "$@"
mime ^ranger/x-terminal-emulator, has tilda = open-under-ranger tilda -c "$@"
mime ^ranger/x-terminal-emulator, has st = open-under-ranger st -e "$@"
mime ^ranger/x-terminal-emulator, has terminator = open-under-ranger terminator -x "$@"
mime ^ranger/x-terminal-emulator, has urxvt = open-under-ranger urxvt -e "$@"
mime ^ranger/x-terminal-emulator, has pantheon-terminal = open-under-ranger pantheon-terminal -e "$@"
mime ^ranger/x-terminal-emulator, has lxterminal = open-under-ranger lxterminal -e "$@"
mime ^ranger/x-terminal-emulator, has mate-terminal = open-under-ranger mate-terminal -x "$@"
mime ^ranger/x-terminal-emulator, has xfce4-terminal = open-under-ranger xfce4-terminal -x "$@"
mime ^ranger/x-terminal-emulator, has konsole = open-under-ranger konsole -e "$@"
mime ^ranger/x-terminal-emulator, has gnome-terminal = open-under-ranger gnome-terminal -- "$@"
mime ^ranger/x-terminal-emulator, has xterm = open-under-ranger xterm -e "$@"
#-------------------------------------------
# Misc
#-------------------------------------------
label wallpaper, number 11, mime ^image, has feh, X = open-under-ranger feh --bg-scale "$1"
label wallpaper, number 12, mime ^image, has feh, X = open-under-ranger feh --bg-tile "$1"
label wallpaper, number 13, mime ^image, has feh, X = open-under-ranger feh --bg-center "$1"
label wallpaper, number 14, mime ^image, has feh, X = open-under-ranger feh --bg-fill "$1"
#-------------------------------------------
# Generic file openers
#-------------------------------------------
label open, has xdg-open = open-under-ranger xdg-open -- "$@"
label open, has open = open-under-ranger open -- "$@"
# Define the editor for non-text files + pager as last action
!mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ask
label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ${VISUAL:-$EDITOR} -- "$@"
label pager, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
######################################################################
# The actions below are left so low down in this file on purpose, so #
# they are never triggered accidentally. #
######################################################################
# Execute a file as program/script.
mime application/x-executable = "$1"
# Move the file to trash using trash-cli.
label trash, has trash-put = trash-put -- "$@"
label trash = mkdir -p -- ${XDG_DATA_DIR:-$HOME/.ranger}/ranger-trash; mv -- "$@" ${XDG_DATA_DIR:-$HOME/.ranger}/ranger-trash

490
modules/user/ranger/scope.sh Executable file
View File

@@ -0,0 +1,490 @@
#!/usr/bin/env sh
set -o noclobber -o noglob -o nounset -o pipefail
IFS=$'\n'
## If the option `use_preview_script` is set to `true`,
## then this script will be called and its output will be displayed in ranger.
## ANSI color codes are supported.
## STDIN is disabled, so interactive scripts won't work properly
## This script is considered a configuration file and must be updated manually.
## It will be left untouched if you upgrade ranger.
## Because of some automated testing we do on the script #'s for comments need
## to be doubled up. Code that is commented out, because it's an alternative for
## example, gets only one #.
## Meanings of exit codes:
## code | meaning | action of ranger
## -----+------------+-------------------------------------------
## 0 | success | Display stdout as preview
## 1 | no preview | Display no preview at all
## 2 | plain text | Display the plain content of the file
## 3 | fix width | Don't reload when width changes
## 4 | fix height | Don't reload when height changes
## 5 | fix both | Don't ever reload
## 6 | image | Display the image `$IMAGE_CACHE_PATH` points to as an image preview
## 7 | image | Display the file directly as an image
## Script arguments
FILE_PATH="${1}" # Full path of the highlighted file
PV_WIDTH="${2}" # Width of the preview pane (number of fitting characters)
## shellcheck disable=SC2034 # PV_HEIGHT is provided for convenience and unused
PV_HEIGHT="${3}" # Height of the preview pane (number of fitting characters)
IMAGE_CACHE_PATH="${4}" # Full path that should be used to cache image preview
PV_IMAGE_ENABLED="${5}" # 'True' if image previews are enabled, 'False' otherwise.
FILE_EXTENSION="${FILE_PATH##*.}"
FILE_EXTENSION_LOWER="$(printf "%s" "${FILE_EXTENSION}" | tr '[:upper:]' '[:lower:]')"
## Settings
HIGHLIGHT_SIZE_MAX=262143 # 256KiB
HIGHLIGHT_TABWIDTH="${HIGHLIGHT_TABWIDTH:-8}"
HIGHLIGHT_STYLE="${HIGHLIGHT_STYLE:-pablo}"
HIGHLIGHT_OPTIONS="--replace-tabs=${HIGHLIGHT_TABWIDTH} --style=${HIGHLIGHT_STYLE} ${HIGHLIGHT_OPTIONS:-}"
PYGMENTIZE_STYLE="${PYGMENTIZE_STYLE:-autumn}"
BAT_STYLE="${BAT_STYLE:-plain}"
OPENSCAD_IMGSIZE="${RNGR_OPENSCAD_IMGSIZE:-1000,1000}"
OPENSCAD_COLORSCHEME="${RNGR_OPENSCAD_COLORSCHEME:-Tomorrow Night}"
SQLITE_TABLE_LIMIT=20 # Display only the top <limit> tables in database, set to 0 for no exhaustive preview (only the sqlite_master table is displayed).
SQLITE_ROW_LIMIT=5 # Display only the first and the last (<limit> - 1) records in each table, set to 0 for no limits.
handle_extension() {
case "${FILE_EXTENSION_LOWER}" in
## Archive
a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\
rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)
atool --list -- "${FILE_PATH}" && exit 5
bsdtar --list --file "${FILE_PATH}" && exit 5
exit 1;;
rar)
## Avoid password prompt by providing empty password
unrar lt -p- -- "${FILE_PATH}" && exit 5
exit 1;;
7z)
## Avoid password prompt by providing empty password
7z l -p -- "${FILE_PATH}" && exit 5
exit 1;;
## PDF
pdf)
## Preview as text conversion
pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - | \
fmt -w "${PV_WIDTH}" && exit 5
mutool draw -F txt -i -- "${FILE_PATH}" 1-10 | \
fmt -w "${PV_WIDTH}" && exit 5
exiftool "${FILE_PATH}" && exit 5
exit 1;;
## BitTorrent
torrent)
transmission-show -- "${FILE_PATH}" && exit 5
exit 1;;
## OpenDocument
odt|sxw)
## Preview as text conversion
odt2txt "${FILE_PATH}" && exit 5
## Preview as markdown conversion
pandoc -s -t markdown -- "${FILE_PATH}" && exit 5
exit 1;;
ods|odp)
## Preview as text conversion (unsupported by pandoc for markdown)
odt2txt "${FILE_PATH}" && exit 5
exit 1;;
## XLSX
xlsx)
## Preview as csv conversion
## Uses: https://github.com/dilshod/xlsx2csv
xlsx2csv -- "${FILE_PATH}" && exit 5
exit 1;;
## HTML
htm|html|xhtml)
## Preview as text conversion
w3m -dump "${FILE_PATH}" && exit 5
lynx -dump -- "${FILE_PATH}" && exit 5
elinks -dump "${FILE_PATH}" && exit 5
pandoc -s -t markdown -- "${FILE_PATH}" && exit 5
;;
## JSON
json)
jq --color-output . "${FILE_PATH}" && exit 5
python -m json.tool -- "${FILE_PATH}" && exit 5
;;
## Jupyter Notebooks
ipynb)
jupyter nbconvert --to markdown "${FILE_PATH}" --stdout | env COLORTERM=8bit bat --color=always --style=plain --language=markdown && exit 5
jupyter nbconvert --to markdown "${FILE_PATH}" --stdout && exit 5
jq --color-output . "${FILE_PATH}" && exit 5
python -m json.tool -- "${FILE_PATH}" && exit 5
;;
## Direct Stream Digital/Transfer (DSDIFF) and wavpack aren't detected
## by file(1).
dff|dsf|wv|wvc)
mediainfo "${FILE_PATH}" && exit 5
exiftool "${FILE_PATH}" && exit 5
;; # Continue with next handler on failure
esac
}
handle_image() {
## Size of the preview if there are multiple options or it has to be
## rendered from vector graphics. If the conversion program allows
## specifying only one dimension while keeping the aspect ratio, the width
## will be used.
local DEFAULT_SIZE="1920x1080"
local mimetype="${1}"
case "${mimetype}" in
## SVG
image/svg+xml|image/svg)
rsvg-convert --keep-aspect-ratio --width "${DEFAULT_SIZE%x*}" "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}.png" \
&& mv "${IMAGE_CACHE_PATH}.png" "${IMAGE_CACHE_PATH}" \
&& exit 6
exit 1;;
## DjVu
image/vnd.djvu)
ddjvu -format=tiff -quality=90 -page=1 -size="${DEFAULT_SIZE}" \
- "${IMAGE_CACHE_PATH}" < "${FILE_PATH}" \
&& exit 6 || exit 1;;
## Image
image/*)
local orientation
orientation="$( identify -format '%[EXIF:Orientation]\n' -- "${FILE_PATH}" )"
## If orientation data is present and the image actually
## needs rotating ("1" means no rotation)...
if [[ -n "$orientation" && "$orientation" != 1 ]]; then
## ...auto-rotate the image according to the EXIF data.
convert -- "${FILE_PATH}" -auto-orient "${IMAGE_CACHE_PATH}" && exit 6
fi
## `w3mimgdisplay` will be called for all images (unless overridden
## as above), but might fail for unsupported types.
exit 7;;
# Video
video/*)
# Get frame 10% into video
ffmpegthumbnailer -i "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" -s 0 && exit 6
# Get embedded thumbnail
ffmpeg -i "${FILE_PATH}" -map 0:v -map -0:V -c copy "${IMAGE_CACHE_PATH}" && exit 6
exit 1;;
# Audio
audio/*)
# Get embedded thumbnail
ffmpeg -i "${FILE_PATH}" -map 0:v -map -0:V -c copy \
"${IMAGE_CACHE_PATH}" && exit 6;;
# PDF
application/pdf)
pdftoppm -f 1 -l 1 \
-scale-to-x "${DEFAULT_SIZE%x*}" \
-scale-to-y -1 \
-singlefile \
-jpeg -tiffcompression jpeg \
-- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \
&& exit 6 || exit 1;;
## ePub, MOBI, FB2 (using Calibre)
# application/epub+zip|application/x-mobipocket-ebook|\
# application/x-fictionbook+xml)
# # ePub (using https://github.com/marianosimone/epub-thumbnailer)
# epub-thumbnailer "${FILE_PATH}" "${IMAGE_CACHE_PATH}" \
# "${DEFAULT_SIZE%x*}" && exit 6
# ebook-meta --get-cover="${IMAGE_CACHE_PATH}" -- "${FILE_PATH}" \
# >/dev/null && exit 6
# exit 1;;
# Font
application/font*|application/*opentype)
preview_png="/tmp/$(basename "${IMAGE_CACHE_PATH%.*}").png"
if fontimage -o "${preview_png}" \
--pixelsize "120" \
--fontname \
--pixelsize "80" \
--text " ABCDEFGHIJKLMNOPQRSTUVWXYZ " \
--text " abcdefghijklmnopqrstuvwxyz " \
--text " 0123456789.:,;(*!?') ff fl fi ffi ffl " \
--text " The quick brown fox jumps over the lazy dog. " \
"${FILE_PATH}";
then
convert -- "${preview_png}" "${IMAGE_CACHE_PATH}" \
&& rm "${preview_png}" \
&& exit 6
else
exit 1
fi
;;
## Preview archives using the first image inside.
## (Very useful for comic book collections for example.)
# application/zip|application/x-rar|application/x-7z-compressed|\
# application/x-xz|application/x-bzip2|application/x-gzip|application/x-tar)
# local fn=""; local fe=""
# local zip=""; local rar=""; local tar=""; local bsd=""
# case "${mimetype}" in
# application/zip) zip=1 ;;
# application/x-rar) rar=1 ;;
# application/x-7z-compressed) ;;
# *) tar=1 ;;
# esac
# { [ "$tar" ] && fn=$(tar --list --file "${FILE_PATH}"); } || \
# { fn=$(bsdtar --list --file "${FILE_PATH}") && bsd=1 && tar=""; } || \
# { [ "$rar" ] && fn=$(unrar lb -p- -- "${FILE_PATH}"); } || \
# { [ "$zip" ] && fn=$(zipinfo -1 -- "${FILE_PATH}"); } || return
#
# fn=$(echo "$fn" | python -c "from __future__ import print_function; \
# import sys; import mimetypes as m; \
# [ print(l, end='') for l in sys.stdin if \
# (m.guess_type(l[:-1])[0] or '').startswith('image/') ]" |\
# sort -V | head -n 1)
# [ "$fn" = "" ] && return
# [ "$bsd" ] && fn=$(printf '%b' "$fn")
#
# [ "$tar" ] && tar --extract --to-stdout \
# --file "${FILE_PATH}" -- "$fn" > "${IMAGE_CACHE_PATH}" && exit 6
# fe=$(echo -n "$fn" | sed 's/[][*?\]/\\\0/g')
# [ "$bsd" ] && bsdtar --extract --to-stdout \
# --file "${FILE_PATH}" -- "$fe" > "${IMAGE_CACHE_PATH}" && exit 6
# [ "$bsd" ] || [ "$tar" ] && rm -- "${IMAGE_CACHE_PATH}"
# [ "$rar" ] && unrar p -p- -inul -- "${FILE_PATH}" "$fn" > \
# "${IMAGE_CACHE_PATH}" && exit 6
# [ "$zip" ] && unzip -pP "" -- "${FILE_PATH}" "$fe" > \
# "${IMAGE_CACHE_PATH}" && exit 6
# [ "$rar" ] || [ "$zip" ] && rm -- "${IMAGE_CACHE_PATH}"
# ;;
esac
openscad_image() {
TMPPNG="$(mktemp -t XXXXXXXXXX --suffix '.png')"
openscad --colorscheme="${OPENSCAD_COLORSCHEME}" \
--imgsize="${OPENSCAD_IMGSIZE/x/,}" \
-o "${TMPPNG}" "${1}"
mv "${TMPPNG}" "${IMAGE_CACHE_PATH}"
}
FULL_FILE_PATH=$(readlink -f $FILE_PATH);
case "${FILE_EXTENSION_LOWER}" in
# 3D models
# OpenSCAD only supports png image output, and ${IMAGE_CACHE_PATH}
# is hardcoded as jpeg. So we make a tempfile.png and just
# move/rename it to jpg. This works because image libraries are
# smart enough to handle it.
csg|scad)
openscad_image "${FILE_PATH}" && exit 6
;;
stl)
openscad_image <(echo "import(\"${FULL_FILE_PATH}\");") && exit 6
;;
3mf|amf|dxf|off|stl)
openscad_image <(echo "import(\"${FULL_FILE_PATH}\");") && exit 6
;;
drawio)
draw.io -x "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" \
--width "${DEFAULT_SIZE%x*}" && exit 6
;;
blend|blend~)
blender-thumbnailer "${FILE_PATH}" "${IMAGE_CACHE_PATH}" && exit 6
;;
kra|kra~)
unzip -pP "" -- "${FILE_PATH}" "mergedimage.png" > "${IMAGE_CACHE_PATH}" && exit 6
;;
xopp|xopp~)
xournalpp "${FILE_PATH}" --create-img "${IMAGE_CACHE_PATH}" && exit 6
exit 1;;
esac
}
handle_mime() {
local mimetype="${1}"
case "${mimetype}" in
## RTF and DOC
text/rtf|*msword)
## Preview as text conversion
## note: catdoc does not always work for .doc files
## catdoc: http://www.wagner.pp.ru/~vitus/software/catdoc/
catdoc -- "${FILE_PATH}" && exit 5
exit 1;;
## DOCX, ePub, FB2 (using markdown)
## You might want to remove "|epub" and/or "|fb2" below if you have
## uncommented other methods to preview those formats
*wordprocessingml.document|*/epub+zip|*/x-fictionbook+xml)
## Preview as markdown conversion
pandoc -s -t markdown -- "${FILE_PATH}" && exit 5
exit 1;;
## E-mails
message/rfc822)
## Parsing performed by mu: https://github.com/djcb/mu
mu view -- "${FILE_PATH}" && exit 5
exit 1;;
## XLS
*ms-excel)
## Preview as csv conversion
## xls2csv comes with catdoc:
## http://www.wagner.pp.ru/~vitus/software/catdoc/
xls2csv -- "${FILE_PATH}" && exit 5
exit 1;;
## SQLite
*sqlite3)
## Preview as text conversion
sqlite_tables="$( sqlite3 "file:${FILE_PATH}?mode=ro" '.tables' )" \
|| exit 1
[ -z "${sqlite_tables}" ] &&
{ echo "Empty SQLite database." && exit 5; }
sqlite_show_query() {
sqlite-utils query "${FILE_PATH}" "${1}" --table --fmt fancy_grid \
|| sqlite3 "file:${FILE_PATH}?mode=ro" "${1}" -header -column
}
## Display basic table information
sqlite_rowcount_query="$(
sqlite3 "file:${FILE_PATH}?mode=ro" -noheader \
'SELECT group_concat(
"SELECT """ || name || """ AS tblname,
count(*) AS rowcount
FROM " || name,
" UNION ALL "
)
FROM sqlite_master
WHERE type="table" AND name NOT LIKE "sqlite_%";'
)"
sqlite_show_query \
"SELECT tblname AS 'table', rowcount AS 'count',
(
SELECT '(' || group_concat(name, ', ') || ')'
FROM pragma_table_info(tblname)
) AS 'columns',
(
SELECT '(' || group_concat(
upper(type) || (
CASE WHEN pk > 0 THEN ' PRIMARY KEY' ELSE '' END
),
', '
) || ')'
FROM pragma_table_info(tblname)
) AS 'types'
FROM (${sqlite_rowcount_query});"
if [ "${SQLITE_TABLE_LIMIT}" -gt 0 ] &&
[ "${SQLITE_ROW_LIMIT}" -ge 0 ]; then
## Do exhaustive preview
echo && printf '>%.0s' $( seq "${PV_WIDTH}" ) && echo
sqlite3 "file:${FILE_PATH}?mode=ro" -noheader \
"SELECT name FROM sqlite_master
WHERE type='table' AND name NOT LIKE 'sqlite_%'
LIMIT ${SQLITE_TABLE_LIMIT};" |
while read -r sqlite_table; do
sqlite_rowcount="$(
sqlite3 "file:${FILE_PATH}?mode=ro" -noheader \
"SELECT count(*) FROM ${sqlite_table}"
)"
echo
if [ "${SQLITE_ROW_LIMIT}" -gt 0 ] &&
[ "${SQLITE_ROW_LIMIT}" \
-lt "${sqlite_rowcount}" ]; then
echo "${sqlite_table} [${SQLITE_ROW_LIMIT} of ${sqlite_rowcount}]:"
sqlite_ellipsis_query="$(
sqlite3 "file:${FILE_PATH}?mode=ro" -noheader \
"SELECT 'SELECT ' || group_concat(
'''...''', ', '
)
FROM pragma_table_info(
'${sqlite_table}'
);"
)"
sqlite_show_query \
"SELECT * FROM (
SELECT * FROM ${sqlite_table} LIMIT 1
)
UNION ALL ${sqlite_ellipsis_query} UNION ALL
SELECT * FROM (
SELECT * FROM ${sqlite_table}
LIMIT (${SQLITE_ROW_LIMIT} - 1)
OFFSET (
${sqlite_rowcount}
- (${SQLITE_ROW_LIMIT} - 1)
)
);"
else
echo "${sqlite_table} [${sqlite_rowcount}]:"
sqlite_show_query "SELECT * FROM ${sqlite_table};"
fi
done
fi
exit 5;;
## Text
text/* | */xml)
## Syntax highlight
if [[ "$( stat --printf='%s' -- "${FILE_PATH}" )" -gt "${HIGHLIGHT_SIZE_MAX}" ]]; then
exit 2
fi
if [[ "$( tput colors )" -ge 256 ]]; then
local pygmentize_format='terminal256'
local highlight_format='xterm256'
else
local pygmentize_format='terminal'
local highlight_format='ansi'
fi
env HIGHLIGHT_OPTIONS="${HIGHLIGHT_OPTIONS}" highlight \
--out-format="${highlight_format}" \
--force -- "${FILE_PATH}" && exit 5
env COLORTERM=8bit bat --color=always --style="${BAT_STYLE}" \
-- "${FILE_PATH}" && exit 5
pygmentize -f "${pygmentize_format}" -O "style=${PYGMENTIZE_STYLE}"\
-- "${FILE_PATH}" && exit 5
exit 2;;
## DjVu
image/vnd.djvu)
## Preview as text conversion (requires djvulibre)
djvutxt "${FILE_PATH}" | fmt -w "${PV_WIDTH}" && exit 5
exiftool "${FILE_PATH}" && exit 5
exit 1;;
## Image
image/*)
## Preview as text conversion
# img2txt --gamma=0.6 --width="${PV_WIDTH}" -- "${FILE_PATH}" && exit 4
exiftool "${FILE_PATH}" && exit 5
exit 1;;
## Video and audio
video/* | audio/*)
mediainfo "${FILE_PATH}" && exit 5
exiftool "${FILE_PATH}" && exit 5
exit 1;;
## ELF files (executables and shared objects)
application/x-executable | application/x-pie-executable | application/x-sharedlib)
readelf -WCa "${FILE_PATH}" && exit 5
exit 1;;
esac
}
handle_fallback() {
echo '----- File Type Classification -----' && file --dereference --brief -- "${FILE_PATH}" && exit 5
}
MIMETYPE="$( file --dereference --brief --mime-type -- "${FILE_PATH}" )"
if [[ "${PV_IMAGE_ENABLED}" == 'True' ]]; then
handle_image "${MIMETYPE}"
fi
handle_extension
handle_mime "${MIMETYPE}"
handle_fallback
exit 1

View File

@@ -0,0 +1,20 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.recording;
in {
options = {
userSettings.recording = {
enable = lib.mkEnableOption "Enable studio recording and editing programs";
};
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
obs-studio
kdenlive
tenacity
ardour
];
};
}

View File

@@ -0,0 +1,18 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.remote;
in {
options = {
userSettings.remote = {
enable = lib.mkEnableOption "Enable programs for controlling remote machines";
};
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
remmina
sshfs
];
};
}

View File

@@ -0,0 +1,63 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.shell;
in {
options = {
userSettings.shell = {
enable = lib.mkEnableOption "Enable fancy zsh with some necessary CLI utilities";
};
};
config = lib.mkIf cfg.enable {
programs.zsh = {
enable = true;
enableAutosuggestions = true;
syntaxHighlighting.enable = true;
enableCompletion = true;
shellAliases = {
ls = "eza --icons -l -T -L=1";
cat = "bat";
htop = "btm";
fd = "fd -Lu";
w3m = "w3m -no-cookie -v";
neofetch = "disfetch";
fetch = "disfetch";
gitfetch = "onefetch";
"," = "comma";
",," = "comma-shell";
};
initExtra = ''
PROMPT=" %U%F{magenta}%n%f%u@%U%F{blue}%m%f%u:%F{yellow}%~%f
%F{green}%f "
RPROMPT="%F{red}%f%F{yellow}%f%F{green}%f%F{cyan}%f%F{blue}%f%F{magenta}%f%F{white}%f"
[ $TERM = "dumb" ] && unsetopt zle && PS1='$ '
bindkey '^P' history-beginning-search-backward
bindkey '^N' history-beginning-search-forward
'';
};
programs.bash = {
enable = true;
enableCompletion = true;
shellAliases = config.programs.zsh.shellAliases;
};
home.packages = with pkgs; [
gnugrep gnused w3m
bat eza bottom fd bc
direnv nix-direnv
];
programs.neovim = {
enable = true;
viAlias = true;
vimAlias = true;
};
programs.direnv.enable = true;
programs.direnv.enableZshIntegration = true;
programs.direnv.nix-direnv.enable = true;
programs.direnv.nix-direnv.package = pkgs.nix-direnv-flakes;
};
}

View File

@@ -0,0 +1,46 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.shell.extraApps;
in {
options = {
userSettings.shell.extraApps = {
enable = lib.mkEnableOption "Add some fun but mostly useless CLI apps";
};
};
config = lib.mkIf cfg.enable {
# Fun CLI apps that aren't necessary
home.packages = with pkgs; [
# Command Line
disfetch lolcat cowsay
starfetch
(stdenv.mkDerivation {
name = "pokemon-colorscripts";
version = "unstable";
src = fetchFromGitLab {
owner = "phoneybadger";
repo = "pokemon-colorscripts";
rev = "0483c85b93362637bdd0632056ff986c07f30868";
sha256 = "sha256-rj0qKYHCu9SyNsj1PZn1g7arjcHuIDGHwubZg/yJt7A=";
};
installPhase = ''
mkdir -p $out $out/bin $out/opt
cp -rf $src/colorscripts $out/opt
cp $src/pokemon-colorscripts.py $out/opt
cp $src/pokemon.json $out/opt
ln -s $out/opt/pokemon-colorscripts.py $out/bin/pokemon-colorscripts
'';
meta = {
homepage = "https://github.com/Admiral-Fish/PokeFinder";
description = "CLI utility to print out images of pokemon to terminal";
license = lib.licenses.mit;
maintainers = [];
};
})
];
};
}

View File

@@ -0,0 +1,66 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.shell.apps;
in {
options = {
userSettings.shell.apps = {
enable = lib.mkEnableOption "Enable a collection of additional useful CLI apps";
};
};
config = lib.mkIf cfg.enable {
# Collection of useful CLI apps
home.packages = with pkgs; [
# Command Line
killall
libnotify
timer
brightnessctl
gnugrep
bat eza fd bottom ripgrep
rsync
zip unzip
w3m
pandoc
hwinfo
pciutils
numbat
(pkgs.writeShellScriptBin "airplane-mode" ''
#!/bin/sh
connectivity="$(nmcli n connectivity)"
if [ "$connectivity" == "full" ]
then
nmcli n off
else
nmcli n on
fi
'')
(pkgs.writeScriptBin "comma" ''
if [ "$#" = 0 ]; then
echo "usage: comma PKGNAME... [EXECUTABLE]";
elif [ "$#" = 1 ]; then
nix-shell -p $1 --run $1;
elif [ "$#" = 2 ]; then
nix-shell -p $1 --run $2;
else
echo "error: too many arguments";
echo "usage: comma PKGNAME... [EXECUTABLE]";
fi
'')
(pkgs.writeScriptBin "comma-shell" ''
if [ "$#" = 0 ]; then
echo "usage: comma-shell PKGNAME1 [PKGNAME2 PKGNAME3...]";
else
nix-shell -p $@
fi
'')
];
programs.zsh.shellAliases = {
w3m = "w3m -no-cookie -v";
"," = "comma";
",," = "comma-shell";
};
};
}

View File

@@ -0,0 +1,128 @@
[ColorEffects:Disabled]
Color=56,56,56
ColorAmount=0
ColorEffect=0
ContrastAmount=0.65
ContrastEffect=1
IntensityAmount=0.1
IntensityEffect=2
[ColorEffects:Inactive]
ChangeSelectionColor=true
Color=112,111,110
ColorAmount=0.025
ColorEffect=2
ContrastAmount=0.1
ContrastEffect=2
Enable=false
IntensityAmount=0
IntensityEffect=0
[Colors:Button]
BackgroundNormal={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
BackgroundAlternate={{base01-rgb-r}},{{base01-rgb-g}},{{base01-rgb-b}}
ForegroundNormal={{base07-rgb-r}},{{base07-rgb-g}},{{base07-rgb-b}}
DecorationFocus={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
DecorationHover={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
ForegroundActive={{base07-rgb-r}},{{base07-rgb-g}},{{base07-rgb-b}}
ForegroundInactive={{base05-rgb-r}},{{base05-rgb-g}},{{base05-rgb-b}}
ForegroundLink={{base0C-rgb-r}},{{base0C-rgb-g}},{{base0C-rgb-b}}
ForegroundNegative={{base08-rgb-r}},{{base08-rgb-g}},{{base08-rgb-b}}
ForegroundNeutral={{base09-rgb-r}},{{base09-rgb-g}},{{base09-rgb-b}}
ForegroundNormal={{base07-rgb-r}},{{base07-rgb-g}},{{base07-rgb-b}}
ForegroundPositive={{base0B-rgb-r}},{{base0B-rgb-g}},{{base0B-rgb-b}}
ForegroundVisited={{base0D-rgb-r}},{{base0D-rgb-g}},{{base0D-rgb-b}}
[Colors:Complementary]
BackgroundNormal={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
BackgroundAlternate={{base01-rgb-r}},{{base01-rgb-g}},{{base01-rgb-b}}
DecorationFocus={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
DecorationHover={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
ForegroundActive={{base07-rgb-r}},{{base07-rgb-g}},{{base07-rgb-b}}
ForegroundInactive={{base05-rgb-r}},{{base05-rgb-g}},{{base05-rgb-b}}
ForegroundLink={{base0C-rgb-r}},{{base0C-rgb-g}},{{base0C-rgb-b}}
ForegroundNegative={{base08-rgb-r}},{{base08-rgb-g}},{{base08-rgb-b}}
ForegroundNeutral={{base09-rgb-r}},{{base09-rgb-g}},{{base09-rgb-b}}
ForegroundNormal={{base07-rgb-r}},{{base07-rgb-g}},{{base07-rgb-b}}
ForegroundPositive={{base0B-rgb-r}},{{base0B-rgb-g}},{{base0B-rgb-b}}
ForegroundVisited={{base0D-rgb-r}},{{base0D-rgb-g}},{{base0D-rgb-b}}
[Colors:Selection]
BackgroundNormal={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
ForegroundNormal={{base07-rgb-r}},{{base07-rgb-g}},{{base07-rgb-b}}
BackgroundAlternate=255,0,0
DecorationFocus=0,255,0
DecorationHover=0,0,255
ForegroundActive={{base07-rgb-r}},{{base07-rgb-g}},{{base07-rgb-b}}
ForegroundInactive={{base05-rgb-r}},{{base05-rgb-g}},{{base05-rgb-b}}
ForegroundLink={{base0C-rgb-r}},{{base0C-rgb-g}},{{base0C-rgb-b}}
ForegroundNegative={{base08-rgb-r}},{{base08-rgb-g}},{{base08-rgb-b}}
ForegroundNeutral={{base09-rgb-r}},{{base09-rgb-g}},{{base09-rgb-b}}
ForegroundNormal={{base07-rgb-r}},{{base07-rgb-g}},{{base07-rgb-b}}
ForegroundPositive={{base0B-rgb-r}},{{base0B-rgb-g}},{{base0B-rgb-b}}
ForegroundVisited={{base0D-rgb-r}},{{base0D-rgb-g}},{{base0D-rgb-b}}
[Colors:Tooltip]
BackgroundAlternate={{base01-rgb-r}},{{base01-rgb-g}},{{base01-rgb-b}}
BackgroundNormal={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
DecorationFocus={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
DecorationHover={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
ForegroundActive={{base07-rgb-r}},{{base07-rgb-g}},{{base07-rgb-b}}
ForegroundInactive={{base05-rgb-r}},{{base05-rgb-g}},{{base05-rgb-b}}
ForegroundLink={{base0C-rgb-r}},{{base0C-rgb-g}},{{base0C-rgb-b}}
ForegroundNegative={{base08-rgb-r}},{{base08-rgb-g}},{{base08-rgb-b}}
ForegroundNeutral={{base09-rgb-r}},{{base09-rgb-g}},{{base09-rgb-b}}
ForegroundNormal={{base07-rgb-r}},{{base07-rgb-g}},{{base07-rgb-b}}
ForegroundPositive={{base0B-rgb-r}},{{base0B-rgb-g}},{{base0B-rgb-b}}
ForegroundVisited={{base0D-rgb-r}},{{base0D-rgb-g}},{{base0D-rgb-b}}
[Colors:View]
BackgroundAlternate={{base01-rgb-r}},{{base01-rgb-g}},{{base01-rgb-b}}
BackgroundNormal={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
DecorationFocus={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
DecorationHover={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
ForegroundActive={{base07-rgb-r}},{{base07-rgb-g}},{{base07-rgb-b}}
ForegroundInactive={{base05-rgb-r}},{{base05-rgb-g}},{{base05-rgb-b}}
ForegroundLink={{base0C-rgb-r}},{{base0C-rgb-g}},{{base0C-rgb-b}}
ForegroundNegative={{base08-rgb-r}},{{base08-rgb-g}},{{base08-rgb-b}}
ForegroundNeutral={{base09-rgb-r}},{{base09-rgb-g}},{{base09-rgb-b}}
ForegroundNormal={{base07-rgb-r}},{{base07-rgb-g}},{{base07-rgb-b}}
ForegroundPositive={{base0B-rgb-r}},{{base0B-rgb-g}},{{base0B-rgb-b}}
ForegroundVisited={{base0D-rgb-r}},{{base0D-rgb-g}},{{base0D-rgb-b}}
[Colors:Window]
BackgroundAlternate={{base01-rgb-r}},{{base01-rgb-g}},{{base01-rgb-b}}
BackgroundNormal={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
DecorationFocus={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
DecorationHover={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
ForegroundActive={{base07-rgb-r}},{{base07-rgb-g}},{{base07-rgb-b}}
ForegroundInactive={{base05-rgb-r}},{{base05-rgb-g}},{{base05-rgb-b}}
ForegroundLink={{base0C-rgb-r}},{{base0C-rgb-g}},{{base0C-rgb-b}}
ForegroundNegative={{base08-rgb-r}},{{base08-rgb-g}},{{base08-rgb-b}}
ForegroundNeutral={{base09-rgb-r}},{{base09-rgb-g}},{{base09-rgb-b}}
ForegroundNormal={{base07-rgb-r}},{{base07-rgb-g}},{{base07-rgb-b}}
ForegroundPositive={{base0B-rgb-r}},{{base0B-rgb-g}},{{base0B-rgb-b}}
ForegroundVisited={{base0D-rgb-r}},{{base0D-rgb-g}},{{base0D-rgb-b}}
[General]
ColorScheme=Breeze
Name={{scheme-name}}
shadeSortColumn=true
desktopFont=Intel One Mono,12,-1,5,50,0,0,0,0,0
fixed=Intel One Mono,12,-1,5,50,0,0,0,0,0
font=Intel One Mono,12,-1,5,50,0,0,0,0,0
menuFont=Intel One Mono,12,-1,5,50,0,0,0,0,0
smallestReadableFont=Intel One Mono,10,-1,5,50,0,0,0,0,0
toolBarFont=Intel One Mono,10,-1,5,50,0,0,0,0,0
[KDE]
contrast=4
[WM]
activeFont=Intel One Mono,10,-1,5,50,0,0,0,0,0
activeBlend={{base01-rgb-r}},{{base01-rgb-g}},{{base01-rgb-b}}
activeBackground={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
activeForeground={{base07-rgb-r}},{{base07-rgb-g}},{{base07-rgb-b}}
inactiveBlend={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
inactiveBackground={{base00-rgb-r}},{{base00-rgb-g}},{{base00-rgb-b}}
inactiveForeground={{base01-rgb-r}},{{base01-rgb-g}},{{base01-rgb-b}}

View File

@@ -0,0 +1,127 @@
{ config, lib, pkgs, inputs, osConfig, ... }:
let
cfg = config.userSettings.stylix;
theme = import (./. + "../../../themes"+("/"+config.userSettings.stylix.theme));
in
{
options = {
userSettings.stylix = {
enable = lib.mkEnableOption "Enable stylix theming";
};
userSettings.stylix.theme = lib.mkOption {
default = if (osConfig.stylix.enable) then osConfig.systemSettings.stylix.theme else "io";
type = lib.types.enum (builtins.attrNames (lib.filterAttrs (name: type: type == "directory") (builtins.readDir ../../themes)));
description = "Theme for stylix to use for the user. A list of themes can be found in the `themes` directory.";
};
};
# for whatever reason, I can't import stylix hmModule if the nixosModule is imported
imports = lib.optionals (!osConfig.stylix.enable) [ inputs.stylix.homeManagerModules.stylix ];
config = lib.mkIf cfg.enable {
stylix.enable = true;
home.file.".currenttheme".text = config.userSettings.stylix.theme;
stylix.autoEnable = false;
stylix.polarity = theme.polarity;
stylix.image = pkgs.fetchurl {
url = theme.backgroundUrl;
sha256 = theme.backgroundSha256;
};
stylix.base16Scheme = theme;
stylix.fonts = {
# TODO abstract fonts into an option
monospace = {
name = "FiraCode Nerd Font";
package = pkgs.nerd-fonts.fira-code;
};
serif = {
name = "FiraCode Nerd Font";
package = pkgs.nerd-fonts.fira-code;
};
sansSerif = {
name = "FiraCode Nerd Font";
package = pkgs.nerd-fonts.fira-code;
};
emoji = {
name = "Noto Color Emoji";
package = pkgs.noto-fonts-emoji-blob-bin;
};
sizes = {
terminal = 18;
applications = 12;
popups = 12;
desktop = 12;
};
};
# move into alacritty config
stylix.targets.alacritty.enable = false;
programs.alacritty.settings = {
colors = {
# TODO revisit these color mappings
# these are just the default provided from stylix
# but declared directly due to alacritty v3.0 breakage
primary.background = "#"+config.lib.stylix.colors.base00;
primary.foreground = "#"+config.lib.stylix.colors.base07;
cursor.text = "#"+config.lib.stylix.colors.base00;
cursor.cursor = "#"+config.lib.stylix.colors.base07;
normal.black = "#"+config.lib.stylix.colors.base00;
normal.red = "#"+config.lib.stylix.colors.base08;
normal.green = "#"+config.lib.stylix.colors.base0B;
normal.yellow = "#"+config.lib.stylix.colors.base0A;
normal.blue = "#"+config.lib.stylix.colors.base0D;
normal.magenta = "#"+config.lib.stylix.colors.base0E;
normal.cyan = "#"+config.lib.stylix.colors.base0B;
normal.white = "#"+config.lib.stylix.colors.base05;
bright.black = "#"+config.lib.stylix.colors.base03;
bright.red = "#"+config.lib.stylix.colors.base09;
bright.green = "#"+config.lib.stylix.colors.base01;
bright.yellow = "#"+config.lib.stylix.colors.base02;
bright.blue = "#"+config.lib.stylix.colors.base04;
bright.magenta = "#"+config.lib.stylix.colors.base06;
bright.cyan = "#"+config.lib.stylix.colors.base0F;
bright.white = "#"+config.lib.stylix.colors.base07;
};
font.size = config.stylix.fonts.sizes.terminal;
font.normal.family = config.stylix.fonts.monospace.name;
};
# move into kitty config
stylix.targets.kitty.enable = true;
stylix.targets.gtk.enable = true;
home.file = {
".config/qt5ct/colors/oomox-current.conf".source = config.lib.stylix.colors {
template = builtins.readFile ./oomox-current.conf.mustache;
extension = ".conf";
};
".config/Trolltech.conf".source = config.lib.stylix.colors {
template = builtins.readFile ./Trolltech.conf.mustache;
extension = ".conf";
};
".config/kdeglobals".source = config.lib.stylix.colors {
template = builtins.readFile ./Trolltech.conf.mustache;
extension = "";
};
".config/qt5ct/qt5ct.conf".text = pkgs.lib.mkBefore (builtins.readFile ./qt5ct.conf);
};
home.packages = with pkgs; [
libsForQt5.qt5ct pkgs.libsForQt5.breeze-qt5 libsForQt5.breeze-icons pkgs.noto-fonts-monochrome-emoji
];
qt = {
enable = true;
style.package = pkgs.libsForQt5.breeze-qt5;
style.name = "breeze-dark";
platformTheme = "kde";
};
fonts.fontconfig.defaultFonts = {
monospace = [ config.stylix.fonts.monospace.name ];
sansSerif = [ config.stylix.fonts.sansSerif.name ];
serif = [ config.stylix.fonts.serif.name ];
};
};
}

View File

@@ -0,0 +1,5 @@
# FG BTN_BG bright less brdark less da txt fg br text btn fg txt bg bg shadow sel bg sel fg link visited alt bg default tooltip bg tooltip_fg
[ColorScheme]
active_colors=#{{base07-hex}}, #{{base00-hex}}, #{{base00-hex}}, #{{base00-hex}}, #{{base00-hex}}, #{{base00-hex}}, #{{base07-hex}}, #{{base07-hex}}, #{{base07-hex}}, #{{base00-hex}}, #{{base00-hex}}, #{{base00-hex}}, #{{base01-hex}}, #{{base00-hex}}, #{{base01-hex}}, #{{base07-hex}}, #{{base00-hex}}, #{{base07-hex}}, #{{base00-hex}}, #{{base07-hex}}
disabled_colors=#767081, #{{base00-hex}}, #{{base00-hex}}, #{{base00-hex}}, #{{base00-hex}}, #{{base00-hex}}, #767081, #767081, #767081, #{{base00-hex}}, #{{base00-hex}}, #{{base00-hex}}, #{{base01-hex}}, #{{base00-hex}}, #{{base01-hex}}, #767081, #{{base00-hex}}, #767081, #{{base00-hex}}, #767081
inactive_colors=#{{base07-hex}}, #{{base00-hex}}, #{{base00-hex}}, #{{base00-hex}}, #{{base00-hex}}, #{{base00-hex}}, #{{base07-hex}}, #{{base07-hex}}, #{{base07-hex}}, #{{base00-hex}}, #{{base00-hex}}, #{{base00-hex}}, #{{base01-hex}}, #{{base00-hex}}, #{{base01-hex}}, #{{base07-hex}}, #{{base00-hex}}, #{{base07-hex}}, #{{base00-hex}}, #{{base07-hex}}

View File

@@ -0,0 +1,35 @@
[Appearance]
color_scheme_path=~/.config/qt5ct/colors/oomox-current.conf
custom_palette=true
icon_theme=oomox-current
standard_dialogs=kde
style=Breeze
[Fonts]
fixed="Intel One Mono,12,-1,0,50,0,0,0,0,0"
general="Intel One Mono,12,-1,0,50,0,0,0,0,0"
[Interface]
activate_item_on_single_click=1
buttonbox_layout=2
cursor_flash_time=1000
dialog_buttons_have_icons=1
double_click_interval=400
gui_effects=@Invalid()
keyboard_scheme=2
menus_have_icons=true
show_shortcuts_in_context_menus=true
stylesheets=@Invalid()
toolbutton_style=4
underline_shortcut=1
wheel_scroll_lines=3
#[PaletteEditor]
#geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\x1t\0\0\x1\x83\0\0\x4\x7f\0\0\x4\x9c\0\0\x1t\0\0\x1\x83\0\0\x3\xea\0\0\x3\x93\0\0\0\0\x2\0\0\0\n\0\0\0\x1t\0\0\x1\x83\0\0\x4\x7f\0\0\x4\x9c)
#[SettingsWindow]
#geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\0\0\0\0\0\0\0\0\x6\x9a\0\0\x5\x65\0\0\0\0\0\0\0\0\0\0\x2\xde\0\0\x2\xbb\0\0\0\0\x2\0\0\0\n\0\0\0\0\0\0\0\0\0\0\0\x6\x9a\0\0\x5\x65)
[Troubleshooting]
force_raster_widgets=1
ignored_applications=@Invalid()

View File

@@ -0,0 +1,19 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.alacritty;
in {
options = {
userSettings.alacritty = {
enable = lib.mkEnableOption "Enable alacritty";
};
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.alacritty ];
programs.alacritty.enable = true;
programs.alacritty.settings = {
window.opacity = lib.mkForce 0.85;
};
};
}

View File

@@ -0,0 +1,16 @@
{ config, lib, pkgs, ... }:
{
options = {
userSettings.terminal = lib.mkOption {
default = "alacritty";
description = "Default terminal";
type = lib.types.enum [ "alacritty" "kitty" ];
};
};
config = {
userSettings.alacritty.enable = lib.mkDefault (config.userSettings.browser == "brave");
userSettings.kitty.enable = lib.mkDefault (config.userSettings.browser == "librewolf");
};
}

View File

@@ -0,0 +1,20 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.kitty;
in {
options = {
userSettings.kitty = {
enable = lib.mkEnableOption "Enable kitty";
};
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.kitty ];
programs.kitty.enable = true;
programs.kitty.settings = {
background_opacity = lib.mkForce "0.85";
modify_font = "cell_width 90%";
};
};
}

View File

@@ -0,0 +1,18 @@
{ config, lib, pkgs, ... }:
{
options = {
userSettings = {
name = lib.mkOption {
default = "";
description = "User full name";
type = lib.types.str;
};
email = lib.mkOption {
default = "";
description = "User email";
type = lib.types.str;
};
};
};
}

View File

@@ -0,0 +1,32 @@
{ config, lib, pkgs, ... }:
let
cfg = config.userSettings.virtualization.virtualMachines;
in {
options = {
userSettings.virtualization.virtualMachines = {
enable = lib.mkEnableOption "Enable helpful VM apps";
};
};
config = lib.mkIf cfg.enable {
# Various packages related to virtualization, compatability and sandboxing
home.packages = with pkgs; [
# Virtual Machines and wine
libvirt
virt-manager
qemu
uefi-run
lxc
swtpm
bottles
# Filesystems
dosfstools
];
home.file.".config/libvirt/qemu.conf".text = ''
nvram = ["/run/libvirt/nix-ovmf/OVMF_CODE.fd:/run/libvirt/nix-ovmf/OVMF_VARS.fd"]
'';
};
}

View File

@@ -0,0 +1,39 @@
{config, lib, pkgs, ... }:
let
cfg = config.userSettings.xdg;
in {
options = {
userSettings.xdg = {
enable = lib.mkEnableOption "Enable xdg user dirs with my xdg directory structure";
};
};
config = lib.mkIf cfg.enable {
# TODO fix mime associations, most of them are totally broken :(
xdg.enable = true;
xdg.userDirs = {
enable = true;
createDirectories = true;
music = "${config.home.homeDirectory}/Media/Music";
videos = "${config.home.homeDirectory}/Media/Videos";
pictures = "${config.home.homeDirectory}/Media/Pictures";
templates = "${config.home.homeDirectory}/Templates";
download = "${config.home.homeDirectory}/Downloads";
documents = "${config.home.homeDirectory}/Documents";
desktop = null;
publicShare = null;
extraConfig = {
XDG_DOTFILES_DIR = "${config.home.homeDirectory}/.dotfiles";
XDG_ARCHIVE_DIR = "${config.home.homeDirectory}/Archive";
XDG_PROJECTS_DIR = "${config.home.homeDirectory}/Projects";
XDG_CLOUD_DIR = "${config.home.homeDirectory}/Drive";
XDG_BOOK_DIR = "${config.home.homeDirectory}/Media/Books";
XDG_VM_DIR = "${config.home.homeDirectory}/Machines";
XDG_NOTES_DIR = "${config.home.homeDirectory}/Notes";
};
};
xdg.mime.enable = true;
xdg.mimeApps.enable = true;
};
}