From 225da437c5457e3b76e48b521eee21d8b9802f23 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Sun, 25 Aug 2024 14:09:28 +0200 Subject: [PATCH] Modularize scripts --- README.md | 48 +++++++-- base/common_hardware.nix | 106 ++++++++++-------- base/env.nix | 28 ++--- example/{example.nix => configuration.nix} | 11 +- {programs => home}/common.nix | 0 {programs => home}/default.nix | 16 ++- {programs => home}/sync.nix | 0 {programs => home}/themes/default.nix | 0 {programs => home}/xdg.nix | 0 lib/default.nix | 11 +- modules/conf.nix | 18 ++++ modules/programs/default.nix | 4 +- modules/programs/home_packages.nix | 6 +- modules/programs/hyprland/hyprland.nix | 23 ++-- modules/programs/oxi/default.nix | 57 ++++++++++ modules/programs/oxi/oxidash.nix | 64 +++++++++++ modules/programs/oxi/oxinoti.nix | 104 ++++++++++++++++++ modules/programs/oxi/oxipaste.nix | 42 ++++++++ modules/programs/oxi/oxishut.nix | 36 +++++++ modules/programs/scripts.nix | 120 +++++++++++++++++++++ programs/oxi/default.nix | 2 - programs/oxi/oxidash.nix | 52 --------- programs/oxi/oxinoti.nix | 92 ---------------- programs/oxi/oxipaste.nix | 30 ------ programs/oxi/oxishut.nix | 24 ----- scripts/audio_control.sh | 80 -------------- scripts/change-brightness | 12 --- scripts/part.sh | 23 ---- scripts/penguin1.sh | 1 - scripts/penguin2.sh | 3 - 30 files changed, 590 insertions(+), 423 deletions(-) rename example/{example.nix => configuration.nix} (78%) rename {programs => home}/common.nix (100%) rename {programs => home}/default.nix (73%) rename {programs => home}/sync.nix (100%) rename {programs => home}/themes/default.nix (100%) rename {programs => home}/xdg.nix (100%) create mode 100644 modules/programs/oxi/default.nix create mode 100644 modules/programs/oxi/oxidash.nix create mode 100644 modules/programs/oxi/oxinoti.nix create mode 100644 modules/programs/oxi/oxipaste.nix create mode 100644 modules/programs/oxi/oxishut.nix create mode 100644 modules/programs/scripts.nix delete mode 100644 programs/oxi/default.nix delete mode 100644 programs/oxi/oxidash.nix delete mode 100644 programs/oxi/oxinoti.nix delete mode 100644 programs/oxi/oxipaste.nix delete mode 100644 programs/oxi/oxishut.nix delete mode 100755 scripts/audio_control.sh delete mode 100755 scripts/change-brightness delete mode 100755 scripts/part.sh delete mode 100644 scripts/penguin1.sh delete mode 100644 scripts/penguin2.sh diff --git a/README.md b/README.md index 7e828a0..06f40e7 100644 --- a/README.md +++ b/README.md @@ -34,35 +34,64 @@ nixosConfigurations = (inputs.dashNix.dashNixLib.build_systems [ ``` In order for your configuration to work, you are required to at least provide a single config file with a further config file being optional for custom configuration. +The hardware.nix specifies additional NixOS configuration, while home.nix specifies additional home-manager configuration. (both optional) |- flake.nix\ |- flake.lock\ |- system1/\ -|---- system1.nix (required)\ -|---- configuration.nix (optional)\ +|---- configuration.nix (required)\ +|---- hardware.nix (optional)\ +|---- home.nix (optional) |- system2/\ -|---- system2.nix (required)\ -|---- configuration.nix (optional)\ +|---- configuration.nix (required)\ +|---- hardware.nix (optional)\ +|---- home.nix (optional) |- system3/\ -|---- system3.nix (required)\ -|---- configuration.nix (optional) +|---- configuration.nix (required) +|---- hardware.nix (optional)\ +|---- home.nix (optional) + +Here is a minimal required configuration.nix (the TODOs mention a required change): -Here is a minimal required configuration (the TODOs mention a required change): ```nix { # variables for system + # TODO important changes conf = { - # TODO change this to your monitor and your pc name + # change this to your monitor and your pc name # should be something like DP-1 monitor = "YOURMONITOR"; + # your username username = "YOURNAME"; # the name of your system hostname = "YOURNAME"; # TODO only needed when you use intel -> amd is default # cpu = "intel"; + locale = "something.UTF-8"; + timezone = "CONTINENT/CITY"; }; # modules mods = { + # default disk config has root home boot and swap partition, overwrite if you want something different + defaultDrives.enable = false; + extraDrives = [ + { + name = "boot"; + drive = { + device = "/dev/disk/by-label/BOOT"; + fsType = "vfat"; + options = [ "rw" "fmask=0022" "dmask=0022" "noatime" ]; + }; + } + { + name = ""; + drive = { + device = "/dev/disk/by-label/ROOT"; + fsType = "ext4"; + options = [ "noatime" "nodiratime" "discard" ]; + }; + } + ]; sops.enable = false; nextcloud.enable = false; hyprland.monitor = [ @@ -81,6 +110,8 @@ Here is a minimal required configuration (the TODOs mention a required change): }; } ``` +## First Login +After logging in the first time, your password will be set to "firstlogin", please change this to whatever you like. # Modules @@ -118,3 +149,4 @@ For package lists, please check the individual modules, as the lists can be long - sops: Enables sops-nix - fish: Enables and configures fish shell - kitty: Enables and configures kitty terminal +- oxi: My own programs, can be selectively disabled, or as a whole diff --git a/base/common_hardware.nix b/base/common_hardware.nix index 724cf83..5071382 100644 --- a/base/common_hardware.nix +++ b/base/common_hardware.nix @@ -4,28 +4,49 @@ in { imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; # Bootloader. - boot.loader.systemd-boot = { - enable = true; - configurationLimit = 5; + boot = { + loader = { + systemd-boot = { + enable = true; + configurationLimit = 5; + }; + efi.canTouchEfiVariables = true; + }; + plymouth = { enable = true; }; + kernelPackages = config.conf.kernel; + initrd.availableKernelModules = + [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ]; + kernelParams = [ ''resume="PARTLABEL=SWAP"'' ] ++ config.conf.boot_params; }; - boot.loader.efi.canTouchEfiVariables = true; - boot.plymouth = { enable = true; }; # Enable networking - networking.useDHCP = lib.mkDefault true; - networking.networkmanager.enable = true; - networking.hostName = config.conf.hostname; - - services.flatpak.enable = true; + networking = { + useDHCP = lib.mkDefault true; + networkmanager.enable = true; + hostName = config.conf.hostname; + }; # Set your time zone. - time.timeZone = "Europe/Zurich"; + time.timeZone = config.conf.timezone; # Select internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; + i18n.defaultLocale = config.conf.locale; # Enable the X11 windowing system. - services.xserver.enable = true; + services = { + flatpak.enable = true; + xserver.enable = true; + fstrim.enable = lib.mkDefault true; + pipewire = { + enable = true; + alsa = { + enable = true; + support32Bit = true; + }; + jack.enable = true; + pulse.enable = true; + }; + }; nixpkgs.hostPlatform = lib.mkDefault config.conf.system; nix = { @@ -43,48 +64,39 @@ in { }; # Enable sound with pipewire. - hardware.pulseaudio.enable = false; - hardware.cpu.${config.conf.cpu}.updateMicrocode = - lib.mkDefault config.hardware.enableRedistributableFirmware; - - services.fstrim.enable = lib.mkDefault true; - security.rtkit.enable = true; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; + hardware = { + pulseaudio.enable = false; + cpu.${config.conf.cpu}.updateMicrocode = + lib.mkDefault config.hardware.enableRedistributableFirmware; }; + security.rtkit.enable = true; + environment.variables = { XDG_CACHE_HOME = "$HOME/.cache"; DIRENV_LOG_FORMAT = ""; }; - boot.kernelPackages = config.conf.kernel; - boot.initrd.availableKernelModules = - [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ]; - boot.kernelParams = [ ''resume="PARTLABEL=SWAP"'' ] - ++ config.conf.boot_params; - # allows user change later on - users.mutableUsers = true; - users.users.${username} = { - isNormalUser = true; - description = username; - extraGroups = [ - "networkmanager" - "wheel" - "gamemode" - "docker" - "vboxusers" - "video" - "audio" - ]; - packages = with pkgs; [ home-manager xdg-desktop-portal-gtk ]; - # this password will only last for the first login - # e.g. login, then change to whatever else, this also ensures no public hash is available - password = "firstlogin"; + users = { + mutableUsers = true; + users.${username} = { + isNormalUser = true; + description = username; + extraGroups = [ + "networkmanager" + "wheel" + "gamemode" + "docker" + "vboxusers" + "video" + "audio" + ]; + packages = with pkgs; [ home-manager xdg-desktop-portal-gtk ]; + # this password will only last for the first login + # e.g. login, then change to whatever else, this also ensures no public hash is available + password = "firstlogin"; + }; }; } diff --git a/base/env.nix b/base/env.nix index 5c54393..9b76e00 100644 --- a/base/env.nix +++ b/base/env.nix @@ -1,16 +1,18 @@ { pkgs, config, ... }: { - environment.variables = { - GSETTINGS_SCHEMA_DIR = - "${pkgs.glib.getSchemaPath pkgs.gsettings-desktop-schemas}"; - NEOVIDE_MAXIMIZED = "0"; - GPG_TTY = "$(tty)"; - EDITOR = "neovide --no-fork"; - SUDO_EDITOR = "neovide --no-fork"; - SCRIPTS = "$HOME/.config/scripts"; - }; - environment.sessionVariables = { - NIXOS_OZONE_WL = "1"; - GOPATH = "$HOME/.go"; - FLAKE = config.conf.nix_path; + environment = { + variables = { + GSETTINGS_SCHEMA_DIR = + "${pkgs.glib.getSchemaPath pkgs.gsettings-desktop-schemas}"; + NEOVIDE_MAXIMIZED = "0"; + GPG_TTY = "$(tty)"; + EDITOR = "neovide --no-fork"; + SUDO_EDITOR = "neovide --no-fork"; + SCRIPTS = "$HOME/.config/scripts"; + }; + sessionVariables = { + NIXOS_OZONE_WL = "1"; + GOPATH = "$HOME/.go"; + FLAKE = config.conf.nix_path; + }; }; } diff --git a/example/example.nix b/example/configuration.nix similarity index 78% rename from example/example.nix rename to example/configuration.nix index 997dde6..54240e4 100644 --- a/example/example.nix +++ b/example/configuration.nix @@ -1,21 +1,26 @@ { # variables for system + # TODO important changes conf = { - # TODO change this to your monitor and your pc name + # change this to your monitor and your pc name # should be something like DP-1 monitor = "YOURMONITOR"; + # your username username = "YOURNAME"; # the name of your system hostname = "YOURNAME"; # TODO only needed when you use intel -> amd is default # cpu = "intel"; + locale = "something.UTF-8"; + timezone = "CONTINENT/CITY"; }; # modules mods = { + # default disk config has root home boot and swap partition, overwrite if you want something different defaultDrives.enable = false; extraDrives = [ { - name = "/boot"; + name = "boot"; drive = { device = "/dev/disk/by-label/BOOT"; fsType = "vfat"; @@ -23,7 +28,7 @@ }; } { - name = "/root"; + name = ""; drive = { device = "/dev/disk/by-label/ROOT"; fsType = "ext4"; diff --git a/programs/common.nix b/home/common.nix similarity index 100% rename from programs/common.nix rename to home/common.nix diff --git a/programs/default.nix b/home/default.nix similarity index 73% rename from programs/default.nix rename to home/default.nix index 68b5f6b..4f7804a 100644 --- a/programs/default.nix +++ b/home/default.nix @@ -1,4 +1,4 @@ -{ inputs, pkgs, config, lib, mod, ... }: +{ inputs, pkgs, config, lib, mod, additionalHomeConfig, ... }: let base_imports = [ inputs.anyrun.homeManagerModules.default @@ -16,7 +16,6 @@ let inputs.dashvim.homeManagerModules.dashvim ../modules ]; - usernamePassed = config.conf.username; in { xdg = { portal.config.common.default = "*"; @@ -30,14 +29,11 @@ in { useUserPackages = true; extraSpecialArgs = { inherit inputs; }; - users.${usernamePassed} = { - imports = [ - ./common.nix - ./xdg.nix - ./oxi/default.nix - ./themes/default.nix - ./sync.nix - ] ++ base_imports ++ lib.optional (builtins.pathExists mod) mod; + users.${config.conf.username} = { + imports = [ ./common.nix ./xdg.nix ./themes ./sync.nix ] ++ base_imports + ++ lib.optional (builtins.pathExists mod) mod + ++ lib.optional (builtins.pathExists additionalHomeConfig) + additionalHomeConfig; }; }; } diff --git a/programs/sync.nix b/home/sync.nix similarity index 100% rename from programs/sync.nix rename to home/sync.nix diff --git a/programs/themes/default.nix b/home/themes/default.nix similarity index 100% rename from programs/themes/default.nix rename to home/themes/default.nix diff --git a/programs/xdg.nix b/home/xdg.nix similarity index 100% rename from programs/xdg.nix rename to home/xdg.nix diff --git a/lib/default.nix b/lib/default.nix index 0e075fc..82420fd 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -6,18 +6,19 @@ in { name = name; value = let mod = root + /${name}/configuration.nix; - additionalConfig = root + /${name}/${name}.nix; + additionalNixosConfig = root + /${name}/hardware.nix; + additionalHomeConfig = root + /${name}/home.nix; in inputs.nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs mod; }; + specialArgs = { inherit inputs pkgs mod additionalHomeConfig; }; modules = [ inputs.home-manager.nixosModules.home-manager inputs.stylix.nixosModules.stylix ../base - ../programs + ../home ../modules mod - ] ++ inputs.nixpkgs.lib.optional (builtins.pathExists additionalConfig) - additionalConfig + ] ++ inputs.nixpkgs.lib.optional + (builtins.pathExists additionalNixosConfig) additionalNixosConfig ++ inputs.nixpkgs.lib.optional (builtins.pathExists mod) mod; }; }) systems); diff --git a/modules/conf.nix b/modules/conf.nix index aba6e0b..1a861d4 100644 --- a/modules/conf.nix +++ b/modules/conf.nix @@ -101,6 +101,24 @@ ''; }; + timezone = lib.mkOption { + default = "Europe/Zurich"; + example = "Europe/Berlin"; + type = lib.types.str; + description = '' + The timezone. + ''; + }; + + locale = lib.mkOption { + default = "en_US.UTF-8"; + example = "de_DE.UTF-8"; + type = lib.types.str; + description = '' + The locale. + ''; + }; + nixos-config-path = lib.mkOption { default = "/home/${config.conf.username}/gits/nixos/."; example = "yourpath/."; diff --git a/modules/programs/default.nix b/modules/programs/default.nix index 70a3712..4c8afbd 100644 --- a/modules/programs/default.nix +++ b/modules/programs/default.nix @@ -17,12 +17,15 @@ ./hyprland ./kde_connect.nix ./keepassxc.nix + ./kitty.nix ./layout.nix ./media.nix ./ncspot.nix ./nextcloud.nix + ./oxi ./piper.nix ./printing.nix + ./scripts.nix ./sops.nix ./starship.nix ./stylix.nix @@ -30,6 +33,5 @@ ./virtualbox.nix ./xone.nix ./yazi - ./kitty.nix ]; } diff --git a/modules/programs/home_packages.nix b/modules/programs/home_packages.nix index fae7bbd..e5ba917 100644 --- a/modules/programs/home_packages.nix +++ b/modules/programs/home_packages.nix @@ -69,12 +69,8 @@ #my own programs programs = { - oxicalc.enable = true; - oxinoti.enable = true; - oxidash.enable = true; - oxishut.enable = true; - oxipaste.enable = true; hyprdock.enable = true; + oxicalc.enable = true; ReSet.enable = true; ReSet.config.plugins = [ inputs.reset-plugins.packages."x86_64-linux".monitor diff --git a/modules/programs/hyprland/hyprland.nix b/modules/programs/hyprland/hyprland.nix index 42220e0..f20b456 100644 --- a/modules/programs/hyprland/hyprland.nix +++ b/modules/programs/hyprland/hyprland.nix @@ -1,8 +1,4 @@ { config, lib, options, pkgs, ... }: { - imports = [ - - ]; - options.mods = { hyprland = { enable = lib.mkOption { @@ -92,11 +88,9 @@ bind = [ # screenshots ''$mod SUPER,S,exec,grim -g "$(slurp)" - | wl-copy'' - '' - $mod SUPERSHIFTALT,S,exec, grim -g "$(slurp)" $HOME/gits/ost-5semester/Screenshots/$(date +'%Y_%m_%d_%I_%M_%S.png') && (date +'%Y_%m_%d_%I_%M_%S.png') | wl-copy'' ''$mod SUPERSHIFT,S,exec,grim -g "$(slurp)" - | satty -f -'' '' - $mod SUPERCONTROLSHIFT,S,exec,grim -c -g "2560,0 3440x1440" - | wl-copy'' + $mod SUPERSHIFTALT,S,exec,grim -c -g "2560,0 3440x1440" - | wl-copy'' # regular programs "$mod SUPER,F,exec,firefox" @@ -114,14 +108,19 @@ "$mod SUPERSHIFT,K,exec, playerctl -a pause & hyprlock & systemctl hibernate" # media keys - ",XF86AudioMute,exec, $HOME/.config/scripts/audio_control.sh mute" - ",XF86AudioLowerVolume,exec, $HOME/.config/scripts/audio_control.sh sink -5%" - ",XF86AudioRaiseVolume,exec, $HOME/.config/scripts/audio_control.sh sink +5%" + (lib.mkIf config.mods.scripts.audio-control + ",XF86AudioMute,exec, audio-control mute") + (lib.mkIf config.mods.scripts.audio-control + ",XF86AudioLowerVolume,exec, audio-control sink -5%") + (lib.mkIf config.mods.scripts.audio-control + ",XF86AudioRaiseVolume,exec, audio-control sink +5%") ",XF86AudioPlay,exec, playerctl play-pause" ",XF86AudioNext,exec, playerctl next" ",XF86AudioPrev,exec, playerctl previous" - ",XF86MonBrightnessDown,exec, $HOME/.config/scripts/change-brightness brightness 10%-" - ",XF86MonBrightnessUp,exec, $HOME/.config/scripts/change-brightness brightness +10%" + (lib.mkIf config.mods.scripts.change-brightness + ",XF86MonBrightnessDown,exec, change-brightness brightness 10%-") + (lib.mkIf config.mods.scripts.change-brightness + ",XF86MonBrightnessUp,exec, change-brightness brightness +10%") # hyprland keybinds # misc diff --git a/modules/programs/oxi/default.nix b/modules/programs/oxi/default.nix new file mode 100644 index 0000000..269d1fa --- /dev/null +++ b/modules/programs/oxi/default.nix @@ -0,0 +1,57 @@ +{ lib, config, options, inputs, ... }: { + imports = [ ./oxidash.nix ./oxinoti.nix ./oxishut.nix ./oxipaste.nix ]; + options.mods.oxi = { + enable = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Enables oxi programs"; + }; + ReSet = { + enable = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Enables and configures ReSet"; + }; + }; + hyprdock = { + enable = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Enables hyprdock"; + }; + }; + oxicalc = { + enable = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Enables hyprdock"; + }; + }; + }; + config = lib.mkIf config.mods.oxi.enable + (lib.optionalAttrs (options ? home.packages) { + programs = { + hyprdock.enable = lib.mkIf config.mods.oxi.hyprdock.enable true; + oxicalc.enable = lib.mkIf config.mods.oxi.oxicalc.enable true; + ReSet = lib.mkIf config.mods.oxi.ReSet.enable { + enable = true; + config = { + plugins = [ + inputs.reset-plugins.packages."x86_64-linux".monitor + inputs.reset-plugins.packages."x86_64-linux".keyboard + ]; + plugin_config = { + Keyboard = { + path = + "/home/${config.conf.username}/.config/reset/keyboard.conf"; + }; + }; + }; + }; + }; + }); +} diff --git a/modules/programs/oxi/oxidash.nix b/modules/programs/oxi/oxidash.nix new file mode 100644 index 0000000..dfcf188 --- /dev/null +++ b/modules/programs/oxi/oxidash.nix @@ -0,0 +1,64 @@ +{ lib, config, options, ... }: { + options.mods.oxi.oxidash = { + enable = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Enables and configures oxidash"; + }; + }; + config = lib.mkIf (config.mods.oxi.oxidash.enable && config.mods.oxi.enable) + (lib.optionalAttrs (options ? xdg.configFile) { + programs.oxidash.enable = true; + xdg.configFile."oxidash/style.css" = { + text = '' + #MainWindow { + border-radius: 10px; + } + + #MainBox { + border-radius: 10px; + } + + #MainButtonBox { + padding: 10px; + margin: 5px 0px 5px 0px; + border-radius: 5px; + border: solid 2px #327cd5; + } + + #DoNotDisturbButton { + } + + #ExitButton { + } + + #ClearNotificationsButton { + } + + #NotificationsWindow { + } + + .debugimage { + border: solid 3px blue; + } + + .Notification { + padding: 10px; + margin: 5px 0px 5px 0px; + border: solid 2px #327cd5; + border-radius: 5px; + } + + .CloseNotificationButton { + margin: 0px 5px 0px 10px; + } + .PictureButtonBox { + } + .BaseBox { + } + } + ''; + }; + }); +} diff --git a/modules/programs/oxi/oxinoti.nix b/modules/programs/oxi/oxinoti.nix new file mode 100644 index 0000000..5b9cfc9 --- /dev/null +++ b/modules/programs/oxi/oxinoti.nix @@ -0,0 +1,104 @@ +{ lib, config, options, ... }: { + options.mods.oxi.oxinoti = { + enable = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Enables and configures oxinoti"; + }; + }; + config = lib.mkIf (config.mods.oxi.oxinoti.enable && config.mods.oxi.enable) + (lib.optionalAttrs (options ? xdg.configFile) { + programs.oxinoti.enable = true; + xdg.configFile."oxinoti/style.css" = { + text = # css + '' + @import url("/home/${config.conf.username}/.config/gtk-3.0/gtk.css"); + + #MainWindow { + background-color: transparent; + padding: 0px; + /* opacity: 0; */ + } + + .MainBox { + background-color: transparent; + padding: 0px; + /* opacity: 0; */ + } + + .NotificationBox { + background-color: #353747; + border-radius: 5px; + border: solid 1px; + margin: 0px; + padding: 5px; + } + + .NotificationLow { + border-color: green; + } + + .NotificationNormal { + border-color: purple; + } + + .NotificationUrgent { + border-color: red; + } + + .miscbox { + margin: 0px 10px 0px 0px; + } + + .bodybox { + } + + .imagebox { + margin: 0px 0px 0px 10px; + } + + .appname { + font-size: 0.8rem; + } + + .timestamp { + font-size: 0.8rem; + } + + .summary { + font-size: 0.8rem; + } + + .body { + font-size: 1.2rem; + } + + .icon { + font-size: 2rem; + } + + .image { + } + + .bold { + font-weight: bold; + } + + .italic { + font-style: italic; + } + + .underline { + text-decoration-line: underline; + } + ''; + }; + xdg.configFile."oxinoti/oxinoti.toml" = { + text = '' + timeout = 3 + dnd_override = 2 + ''; + }; + }); +} diff --git a/modules/programs/oxi/oxipaste.nix b/modules/programs/oxi/oxipaste.nix new file mode 100644 index 0000000..c6783e4 --- /dev/null +++ b/modules/programs/oxi/oxipaste.nix @@ -0,0 +1,42 @@ +{ lib, config, options, ... }: { + options.mods.oxi.oxipaste = { + enable = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Enables and configures oxipaste"; + }; + }; + config = lib.mkIf (config.mods.oxi.oxipaste.enable && config.mods.oxi.enable) + (lib.optionalAttrs (options ? xdg.configFile) { + programs.oxipaste.enable = true; + xdg.configFile."oxipaste/style.css" = { + text = '' + .main-window { + padding: 10px; + border-radius: 10px; + border: 2px solid #2AC3DE; + } + + .item-window { + padding: 10px; + border-radius: 10px; + border: 2px solid #C0CAF5; + } + + .item-button { + background-color: #1A1B26; + border-radius: 5px; + border: 1px solid #6D728D; + } + + .delete-button { + margin: 5px 25px 5px 5px; + } + + .item-box { + } + ''; + }; + }); +} diff --git a/modules/programs/oxi/oxishut.nix b/modules/programs/oxi/oxishut.nix new file mode 100644 index 0000000..3dc0900 --- /dev/null +++ b/modules/programs/oxi/oxishut.nix @@ -0,0 +1,36 @@ +{ lib, config, options, ... }: { + options.mods.oxi.oxishut = { + enable = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Enables and configures oxishut"; + }; + }; + config = lib.mkIf (config.mods.oxi.oxishut.enable && config.mods.oxi.enable) + (lib.optionalAttrs (options ? xdg.configFile) { + programs.oxishut.enable = true; + xdg.configFile."oxishut/style.css" = { + text = '' + #mainwindow { + border-radius: 10px; + } + + .mainbox { + border-radius: 5px; + padding: 20px; + } + + .button { + margin: 5px; + background-color: #2b2c3b; + -gtk-icon-size: 5rem; + } + + .button:hover { + background-color: #3e4152; + } + ''; + }; + }); +} diff --git a/modules/programs/scripts.nix b/modules/programs/scripts.nix new file mode 100644 index 0000000..9ee3cca --- /dev/null +++ b/modules/programs/scripts.nix @@ -0,0 +1,120 @@ +{ lib, config, options, pkgs, ... }: { + options.mods.scripts = { + change-brightness = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Enables the change-brightness script"; + }; + audio-control = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Enables the audio-control script"; + }; + scripts = lib.mkOption { + default = [ ]; + example = [ ]; + description = + "More scripts to be passed. (check existing ones for types and examples)"; + }; + }; + config = (lib.optionalAttrs (options ? home.packages) { + home.packages = [ + (lib.mkIf config.mods.scripts.change-brightness + (pkgs.writeShellScriptBin "change-brightness" '' + set_brightness() { + brightnessctl set "$1" + CURRENT=$(brightnessctl -m -d intel_backlight | awk -F, '{print substr($4, 0, length($4)-1)}') + dunstify -a "changeBrightness" -r 3 -u low -i brightness-high -h int:value:"$CURRENT" "Brightness: $\{CURRENT\}%" + } + + if [ "$1" == "brightness" ]; then + set_brightness "$2" + fi + '')) + (lib.mkIf config.mods.scripts.audio-control + (pkgs.writeShellScriptBin "audio-control" '' + ncspot() { + NUM=$(pactl list clients short | rg "ncspot" | awk -F 'PipeWire' ' { print $1 } ' | tr -d ' \t\n') + CHANGE=$(pactl list sink-inputs short | rg "$NUM" | awk -F ' ' ' { print $1 }' | tr -d ' \t\n') + pactl set-sink-input-volume "$CHANGE" "$1" + VOLUME=$(pactl list sink-inputs | rg "$NUM" -A7 | rg "Volume:" | awk -F ' ' ' { print $5 }' | tr -d '%') + notify-send -a "ncspot" -r 990 -u low -i audio-volume-high -h int:progress:"$VOLUME" "Spotify Volume: $\{VOLUME\}%" + } + + firefox() { + STRING=$(pactl list clients short | rg "firefox" | awk -F 'PipeWire' ' { print $1 "," } ' | tr -d ' \t\n') + # NUMS=',' read -r -a array <<< "$STRING" + readarray -td, NUMS <<<"$STRING" + declare -p NUMS + for index in "$\{!NUMS[@]\}"; do #"$\{!array[@]\}" + NUM=$(echo "$\{NUMS[index]\}" | tr -d ' \t\n') + CHANGE=$(pactl list sink-inputs short | rg "$NUM" | awk -F ' ' ' { print $1 }' | tr -d ' \t\n') + pactl set-sink-input-volume "$CHANGE" "$1" + done + VOLUME=$(pactl list sink-inputs | rg "$\{NUMS[0]\}" -A7 | rg "Volume:" | awk -F ' ' ' { print $5 }' | tr -d '%') + notify-send -a "Firefox" -r 991 -u low -i audio-volume-high -h int:progress:"$VOLUME" "Firefox Volume: $\{VOLUME\}%" + } + + internal() { + SPEAKER=$(pactl list sinks | grep "Name" | grep "alsa" | awk -F ': ' '{ print $2 }') + if [ "$SPEAKER" != "" ]; then + pactl set-default-sink "$SPEAKER" + pactl set-sink-mute "$SPEAKER" false + DEVICE=$(echo "$SPEAKER" | awk -F '.' ' { print $4 } ') + notify-send "changed audio to "$DEVICE" " + else + notify-send "failed, not available!" + fi + } + + set_volume_sink() { + pactl set-sink-volume @DEFAULT_SINK@ "$1" + CURRENT=$(pactl get-sink-volume @DEFAULT_SINK@ | awk -F'/' '{ print $2 }' | tr -d ' %') + notify-send -a "System Volume" -r 1001 -u low -i audio-volume-high -h int:progress:"$CURRENT" "Output Volume: $\{CURRENT\}%" + } + + set_volume_source() { + pactl set-source-volume @DEFAULT_SOURCE@ "$1" + CURRENT=$(pactl get-source-volume @DEFAULT_SOURCE@ | awk -F'/' '{ print $2 }' | tr -d ' %') + notify-send -a "System Volume" -r 1001 -u low -i audio-volume-high -h int:progress:"$CURRENT" "Input Volume: $\{CURRENT\}%" + } + + bluetooth() { + SPEAKER=$(pactl list sinks | grep "Name" | grep "blue" | awk -F ': ' '{ print $2 }') + if [ "$SPEAKER" != "" ]; then + pactl set-default-sink "$SPEAKER" + pactl set-sink-mute "$SPEAKER" false + DEVICE=$(echo "$SPEAKER" | awk -F '.' ' { print $4 } ') + notify-send "changed audio to "$DEVICE" " + else + notify-send "failed, not available!" + fi + } + + mute() { + pactl set-sink-mute @DEFAULT_SINK@ toggle + MUTE=$(pactl get-sink-mute @DEFAULT_SINK@) + notify-send -a "Audio" -r 994 -u low -i audio-volume-high "Audio: $MUTE" + } + + if [ "$1" == "internal" ]; then + internal + elif [ "$1" == "bluetooth" ]; then + bluetooth + elif [ "$1" == "firefox" ]; then + firefox "$2" + elif [ "$1" == "ncspot" ]; then + ncspot "$2" + elif [ "$1" == "mute" ]; then + mute + elif [ "$1" == "sink" ]; then + set_volume_sink "$2" + elif [ "$1" == "source" ]; then + set_volume_source "$2" + fi + '')) + ] ++ config.mods.scripts.scripts; + }); +} diff --git a/programs/oxi/default.nix b/programs/oxi/default.nix deleted file mode 100644 index c5001e4..0000000 --- a/programs/oxi/default.nix +++ /dev/null @@ -1,2 +0,0 @@ -{ imports = [ ./oxipaste.nix ./oxinoti.nix ./oxishut.nix ./oxidash.nix ]; } - diff --git a/programs/oxi/oxidash.nix b/programs/oxi/oxidash.nix deleted file mode 100644 index cb0b2f2..0000000 --- a/programs/oxi/oxidash.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ - xdg.configFile."oxidash/style.css" = { - text = '' - #MainWindow { - border-radius: 10px; - } - - #MainBox { - border-radius: 10px; - } - - #MainButtonBox { - padding: 10px; - margin: 5px 0px 5px 0px; - border-radius: 5px; - border: solid 2px #327cd5; - } - - #DoNotDisturbButton { - } - - #ExitButton { - } - - #ClearNotificationsButton { - } - - #NotificationsWindow { - } - - .debugimage { - border: solid 3px blue; - } - - .Notification { - padding: 10px; - margin: 5px 0px 5px 0px; - border: solid 2px #327cd5; - border-radius: 5px; - } - - .CloseNotificationButton { - margin: 0px 5px 0px 10px; - } - .PictureButtonBox { - } - .BaseBox { - } - } - ''; - }; -} diff --git a/programs/oxi/oxinoti.nix b/programs/oxi/oxinoti.nix deleted file mode 100644 index 4623f93..0000000 --- a/programs/oxi/oxinoti.nix +++ /dev/null @@ -1,92 +0,0 @@ -{ config, ... }: { - xdg.configFile."oxinoti/style.css" = { - text = # css - '' - @import url("/home/${config.conf.username}/.config/gtk-3.0/gtk.css"); - - #MainWindow { - background-color: transparent; - padding: 0px; - /* opacity: 0; */ - } - - .MainBox { - background-color: transparent; - padding: 0px; - /* opacity: 0; */ - } - - .NotificationBox { - background-color: #353747; - border-radius: 5px; - border: solid 1px; - margin: 0px; - padding: 5px; - } - - .NotificationLow { - border-color: green; - } - - .NotificationNormal { - border-color: purple; - } - - .NotificationUrgent { - border-color: red; - } - - .miscbox { - margin: 0px 10px 0px 0px; - } - - .bodybox { - } - - .imagebox { - margin: 0px 0px 0px 10px; - } - - .appname { - font-size: 0.8rem; - } - - .timestamp { - font-size: 0.8rem; - } - - .summary { - font-size: 0.8rem; - } - - .body { - font-size: 1.2rem; - } - - .icon { - font-size: 2rem; - } - - .image { - } - - .bold { - font-weight: bold; - } - - .italic { - font-style: italic; - } - - .underline { - text-decoration-line: underline; - } - ''; - }; - xdg.configFile."oxinoti/oxinoti.toml" = { - text = '' - timeout = 3 - dnd_override = 2 - ''; - }; -} diff --git a/programs/oxi/oxipaste.nix b/programs/oxi/oxipaste.nix deleted file mode 100644 index 9f3e9bc..0000000 --- a/programs/oxi/oxipaste.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ - xdg.configFile."oxipaste/style.css" = { - text = '' - .main-window { - padding: 10px; - border-radius: 10px; - border: 2px solid #2AC3DE; - } - - .item-window { - padding: 10px; - border-radius: 10px; - border: 2px solid #C0CAF5; - } - - .item-button { - background-color: #1A1B26; - border-radius: 5px; - border: 1px solid #6D728D; - } - - .delete-button { - margin: 5px 25px 5px 5px; - } - - .item-box { - } - ''; - }; -} diff --git a/programs/oxi/oxishut.nix b/programs/oxi/oxishut.nix deleted file mode 100644 index f973921..0000000 --- a/programs/oxi/oxishut.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ - xdg.configFile."oxishut/style.css" = { - text = '' - #mainwindow { - border-radius: 10px; - } - - .mainbox { - border-radius: 5px; - padding: 20px; - } - - .button { - margin: 5px; - background-color: #2b2c3b; - -gtk-icon-size: 5rem; - } - - .button:hover { - background-color: #3e4152; - } - ''; - }; -} diff --git a/scripts/audio_control.sh b/scripts/audio_control.sh deleted file mode 100755 index 33cc652..0000000 --- a/scripts/audio_control.sh +++ /dev/null @@ -1,80 +0,0 @@ - -ncspot() { - NUM=$(pactl list clients short | rg "ncspot" | awk -F 'PipeWire' ' { print $1 } ' | tr -d ' \t\n') - CHANGE=$(pactl list sink-inputs short | rg "$NUM" | awk -F ' ' ' { print $1 }' | tr -d ' \t\n') - pactl set-sink-input-volume "$CHANGE" "$1" - VOLUME=$(pactl list sink-inputs | rg "$NUM" -A7 | rg "Volume:" | awk -F ' ' ' { print $5 }' | tr -d '%') - notify-send -a "ncspot" -r 990 -u low -i audio-volume-high -h int:progress:"$VOLUME" "Spotify Volume: ${VOLUME}%" -} - -firefox() { - STRING=$(pactl list clients short | rg "firefox" | awk -F 'PipeWire' ' { print $1 "," } ' | tr -d ' \t\n') - # NUMS=',' read -r -a array <<< "$STRING" - readarray -td, NUMS <<<"$STRING" - declare -p NUMS - for index in "${!NUMS[@]}"; do #"${!array[@]}" - NUM=$(echo "${NUMS[index]}" | tr -d ' \t\n') - CHANGE=$(pactl list sink-inputs short | rg "$NUM" | awk -F ' ' ' { print $1 }' | tr -d ' \t\n') - pactl set-sink-input-volume "$CHANGE" "$1" - done - VOLUME=$(pactl list sink-inputs | rg "${NUMS[0]}" -A7 | rg "Volume:" | awk -F ' ' ' { print $5 }' | tr -d '%') - notify-send -a "Firefox" -r 991 -u low -i audio-volume-high -h int:progress:"$VOLUME" "Firefox Volume: ${VOLUME}%" -} - -internal() { - SPEAKER=$(pactl list sinks | grep "Name" | grep "alsa" | awk -F ': ' '{ print $2 }') - if [ "$SPEAKER" != "" ]; then - pactl set-default-sink "$SPEAKER" - pactl set-sink-mute "$SPEAKER" false - DEVICE=$(echo "$SPEAKER" | awk -F '.' ' { print $4 } ') - notify-send "changed audio to "$DEVICE" " - else - notify-send "failed, not available!" - fi -} - -set_volume_sink() { - pactl set-sink-volume @DEFAULT_SINK@ "$1" - CURRENT=$(pactl get-sink-volume @DEFAULT_SINK@ | awk -F'/' '{ print $2 }' | tr -d ' %') - notify-send -a "System Volume" -r 1001 -u low -i audio-volume-high -h int:progress:"$CURRENT" "Output Volume: ${CURRENT}%" -} - -set_volume_source() { - pactl set-source-volume @DEFAULT_SOURCE@ "$1" - CURRENT=$(pactl get-source-volume @DEFAULT_SOURCE@ | awk -F'/' '{ print $2 }' | tr -d ' %') - notify-send -a "System Volume" -r 1001 -u low -i audio-volume-high -h int:progress:"$CURRENT" "Input Volume: ${CURRENT}%" -} - -bluetooth() { - SPEAKER=$(pactl list sinks | grep "Name" | grep "blue" | awk -F ': ' '{ print $2 }') - if [ "$SPEAKER" != "" ]; then - pactl set-default-sink "$SPEAKER" - pactl set-sink-mute "$SPEAKER" false - DEVICE=$(echo "$SPEAKER" | awk -F '.' ' { print $4 } ') - notify-send "changed audio to "$DEVICE" " - else - notify-send "failed, not available!" - fi -} - -mute() { - pactl set-sink-mute @DEFAULT_SINK@ toggle - MUTE=$(pactl get-sink-mute @DEFAULT_SINK@) - notify-send -a "Audio" -r 994 -u low -i audio-volume-high "Audio: $MUTE" -} - -if [ "$1" == "internal" ]; then - internal -elif [ "$1" == "bluetooth" ]; then - bluetooth -elif [ "$1" == "firefox" ]; then - firefox "$2" -elif [ "$1" == "ncspot" ]; then - ncspot "$2" -elif [ "$1" == "mute" ]; then - mute -elif [ "$1" == "sink" ]; then - set_volume_sink "$2" -elif [ "$1" == "source" ]; then - set_volume_source "$2" -fi diff --git a/scripts/change-brightness b/scripts/change-brightness deleted file mode 100755 index 198dc44..0000000 --- a/scripts/change-brightness +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/bash - -set_brightness() { -brightnessctl set "$1" -CURRENT=$(brightnessctl -m -d intel_backlight | awk -F, '{print substr($4, 0, length($4)-1)}') -dunstify -a "changeBrightness" -r 3 -u low -i brightness-high -h int:value:"$CURRENT" "Brightness: ${CURRENT}%" -} - -if [ "$1" == "brightness" ]; then - set_brightness "$2" -fi - diff --git a/scripts/part.sh b/scripts/part.sh deleted file mode 100755 index ee9d5c3..0000000 --- a/scripts/part.sh +++ /dev/null @@ -1,23 +0,0 @@ -read -p "formatting disk $1 with hostname $2 is this correct? " IN -read -p "is the disk an nvme drive? " NVME -if [ "$IN" == "y" ]; then - echo "commencing" - #format disk - parted $1 mklabel gpt mkpart primary fat32 1MiB 512MiB mkpart primary linux-swap 512MiB 31029MiB mkpart primary btrfs 31029MiB 40% mkpart primary btrfs 40% 100% - if [ "$NVME" == "y" ]; then - e2label $1p1 BOOT - e2label $1p2 SWAP - e2label $1p3 ROOT - e2label $1p4 HOME - else - e2label "$1"1 BOOT - e2label "$1"2 SWAP - e2label "$1"3 ROOT - e2label "$1"4 HOME - fi - # install nixos - echo "formatting finished, continuing to install system" - nixos-install --flake ./nix/.#$2 --no-root-passwd -else - echo "aborting" -fi diff --git a/scripts/penguin1.sh b/scripts/penguin1.sh deleted file mode 100644 index 87dcf8e..0000000 --- a/scripts/penguin1.sh +++ /dev/null @@ -1 +0,0 @@ -echo "Do you have time to talk about the lord and savior PenguinOS?" | wl-copy diff --git a/scripts/penguin2.sh b/scripts/penguin2.sh deleted file mode 100644 index 7503221..0000000 --- a/scripts/penguin2.sh +++ /dev/null @@ -1,3 +0,0 @@ -echo "Are you tired about ads on your operating system? About forced telemetry? About arbitrary installation requirements like online accounts or forced hardware upgrades? -Fear not penguin is for you, free of charge and free to change. Penguin does not control you, you control penguin. -Don't delay, install penguin today: https://distrochooser.de/" | wl-copy