From 40f190de881cc8c0272135fef51a78a8a8e23450 Mon Sep 17 00:00:00 2001 From: Sebastian Moser Date: Sun, 12 Jan 2025 18:50:01 +0100 Subject: [PATCH] a bunch of stuff, including upgrade to wayland and ndi streaming to imac --- common/all.nix | 2 +- common/nixos-graphical.nix | 9 + common/nixos-wayland.nix | 1085 ++++++++++++++++++++++++++++++ flake.lock | 2 +- flake.nix | 31 +- hardware/fusu.nix | 5 + hardware/hpm-laptop.nix | 22 +- hosts/fusu.nix | 41 +- hosts/mac.nix | 157 +++++ hosts/main.nix | 70 +- hosts/test | 1 - misc/my-hosts-h | 5 +- mods/nurPkgs/ndi-monitor.nix | 54 ++ mods/nurPkgs/ndi-monitor.patch | 13 + mybin/htldoc | 9 +- mybin/ru | 7 +- programs/lf/default.nix | 2 +- programs/ssh.nix | 10 +- random-pkgs.nix | 54 +- scripts/batteryscript.sh | 79 +++ scripts/change_charging_state.sh | 16 + scripts/colorscript.sh | 16 + scripts/get_power_usage.sh | 5 + scripts/idlescript | 12 + scripts/keyboard_alert.sh | 31 + scripts/lockscript | 8 + scripts/screenshot.sh | 1 + scripts/toggle_freeze_process.sh | 18 + scripts/waybar-timer.sh | 103 +++ 29 files changed, 1813 insertions(+), 55 deletions(-) create mode 100644 common/nixos-wayland.nix create mode 100644 hosts/mac.nix delete mode 100644 hosts/test create mode 100644 mods/nurPkgs/ndi-monitor.nix create mode 100644 mods/nurPkgs/ndi-monitor.patch create mode 100755 scripts/batteryscript.sh create mode 100755 scripts/change_charging_state.sh create mode 100755 scripts/colorscript.sh create mode 100755 scripts/get_power_usage.sh create mode 100755 scripts/idlescript create mode 100755 scripts/keyboard_alert.sh create mode 100755 scripts/lockscript create mode 100755 scripts/screenshot.sh create mode 100755 scripts/toggle_freeze_process.sh create mode 100755 scripts/waybar-timer.sh diff --git a/common/all.nix b/common/all.nix index fc8254c..f2fb6ca 100644 --- a/common/all.nix +++ b/common/all.nix @@ -25,7 +25,7 @@ ''; nix.settings = { - experimental-features = lib.mkDefault "nix-command flakes repl-flake"; + experimental-features = lib.mkDefault "nix-command flakes"; trusted-users = [ "root" "@wheel" ]; }; nixpkgs.config.allowUnfree = true; diff --git a/common/nixos-graphical.nix b/common/nixos-graphical.nix index 92b438a..d1f9322 100644 --- a/common/nixos-graphical.nix +++ b/common/nixos-graphical.nix @@ -4,6 +4,10 @@ ../mods/battery_monitor.nix ]; + # after firefox 1.122 the cursor did not change on links anymore..... + # so i had a firefox-tmp binary, which was built with + # sudo nix build github:c2vi/nixos/1b07ba88b21e7f46a6012ecadc0ca3a86eda7281#nixosConfigurations.main.config.home-manager.users.me.programs.firefox.package -L + modules.battery_monitor.enable = true; # Enable the X11 windowing system. @@ -67,6 +71,11 @@ sound.enable = true; hardware.pulseaudio.enable = true; services.blueman.enable = true; + hardware.bluetooth.settings = { + General = { + Enable = "Source,Sink,Media,Socket"; + }; + }; hardware.bluetooth.enable = true; # Enable touchpad support (enabled default in most desktopManager). diff --git a/common/nixos-wayland.nix b/common/nixos-wayland.nix new file mode 100644 index 0000000..2178a56 --- /dev/null +++ b/common/nixos-wayland.nix @@ -0,0 +1,1085 @@ + +# special thanks to: https://github.com/lostMia/nixos-config +# TODOs +# - monitor scaling +# - fix copying +# - flameshot +# - rofi config +# - rofi show ssh as well +# - fix audio next,prev +# - backgroudn and transperency +# - hibernation +# - swapfile not found in stage1 +# - win + D command +# - kernel output for luks pwd on all displays + +{ pkgs, nur, unstable, ... }: { + + services.greetd = { + enable = true; + settings = { + default_session = { + #command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time -d --env WLR_RENDERER_ALLOW_SOFTWARE=1 --cmd sway"; + command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd ${pkgs.writeScriptBin "run-sway" '' + export WLR_RENDERER_ALLOW_SOFTWARE=1 + export SDL_VIDEODRIVER=wayland + export _JAVA_AWT_WM_NONREPARENTING=1 + export QT_QPA_PLATFORM=wayland + export XDG_CURRENT_DESKTOP=sway + export XDG_SESSION_DESKTOP=sway + exec sway + ''}/bin/run-sway"; + user = "me"; + }; + }; + }; + + security.rtkit.enable = true; + services.pipewire = { + enable = true; + pulse.enable = true; + jack.enable = true; + audio.enable = true; + alsa = { + enable = true; + support32Bit = true; + }; + }; + xdg.portal = { + enable = true; + config = { + common = { + default = "wlr"; + }; + }; + wlr.enable = true; + wlr.settings.screencast = { + output_name = "eDP-1"; + chooser_type = "simple"; + chooser_cmd = "${pkgs.slurp}/bin/slurp -f %o -or"; + }; + extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; + }; + + fonts.packages = with pkgs; [ + (nerdfonts.override {fonts = ["Hack"];}) + ]; + + sound.enable = true; + services.blueman.enable = true; + hardware.bluetooth.enable = true; + + services.keyd = { + enable = true; + keyboards.default.settings = { + main = { + leftalt = "leftcontrol"; + leftcontrol = "leftalt"; + }; + }; + }; + + environment.systemPackages = with pkgs; [ + xdg-desktop-portal + wlr-randr + rofi-wayland + wev + swayfx + wl-clipboard + zoxide + waybar + power-profiles-daemon + brightnessctl + autotiling + alejandra + vesktop + wayland + xdg-utils + grim + slurp + unstable.shikane + networkmanagerapplet + blueman + sway-audio-idle-inhibit + dunst + libnotify + nur.repos.kira-bruneau.swaylock-fprintd + swayidle + corrupter + swayosd + stress + wl-mirror + fortune + ]; + + home-manager.users.me.home.file = { + ".config/sway/config".text = '' + + # c2vi's sway config, stolen from Mia's sway config + + ### Colors + set $rosewater #f5e0dc + set $flamingo #f2cdcd + set $pink #f5c2e7 + set $mauve #cba6f7 + set $red #f38ba8 + set $maroon #eba0ac + set $peach #fab387 + set $green #a6e3a1 + set $teal #94e2d5 + set $sky #89dceb + set $sapphire #74c7ec + set $blue #89b4fa + set $lavender #b4befe + set $text #cdd6f4 + set $subtext1 #bac2de + set $subtext0 #a6adc8 + set $overlay2 #9399b2 + set $overlay1 #7f849c + set $overlay0 #6c7086 + set $surface2 #585b70 + set $surface1 #45475a + set $surface0 #313244 + set $base #1e1e2e + set $mantle #181825 + set $crust #11111b + + ### Flameshot fix + exec_always "export SDL_VIDEODRIVER=wayland" + exec_always "export _JAVA_AWT_WM_NONREPARENTING=1" + exec_always "export QT_QPA_PLATFORM=wayland" + exec_always "export XDG_CURRENT_DESKTOP=sway" + exec_always "export XDG_SESSION_DESKTOP=sway" + exec_always "export QT_AUTO_SCREEN_SCALE_FACTOR=0" + + exec_always systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK + exec_always hash dbus-update-activation-environment 2>/dev/null && \ + dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK + + ### Variables + set $mod Mod1 + set $left h + set $down j + set $up k + set $right l + set $term alacritty + set $menu rofi + + ### Font + font HackNerdFont-Regular 16 + + ### Output configuration + #output * scale 1 bg ${./..}/resources/nix.png fill + + ### Input configuration + input type:keyboard { + xkb_layout de,de + repeat_delay 160,160 + repeat_rate 80,80 + xkb_options altwin:swap_lalt_lwin + } + + # altwin:swap_lalt_lwin swaps the left alt and windows keys, so the win key is on the right and the alt is on the left. + # ctrl:swap_ralt_rctl swaps the right alt and right control keys, so the control key is on the left and the alt is on the right. + #xkb_options grp:rctrl_toggle,altwin:swap_lalt_lwin + + input 2362:628:PIXA3854:00_093A:0274_Touchpad { + pointer_accel 0 + tap enabled + accel_profile flat + scroll_method two_finger + middle_emulation enabled + } + + input 1133:49291:Logitech_G502_HERO_Gaming_Mouse { + accel_profile flat + pointer_accel -0.5 + } + + ### Border colors and looks + client.focused #ff4060 #222222 #ff4060 #ff4060 #ff4060 + client.focused_inactive #222222 #222222 #ff4060 #222222 #222222 + client.unfocused #222222 #222222 #222222 #222222 #222222 + client.urgent $peach $base $peach $overlay0 $peach + client.placeholder $overlay0 $base $text $overlay0 $overlay0 + client.background $base + + ## Autostart + exec autotiling # Automatically tiles in whatever direction is the longest + exec "/usr/bin/env bash ${./..}/scripts/idlescript" # Manages suspending and locking + exec "/usr/bin/env bash ${./..}/scripts/batteryscript.sh" # Sends battery notifications when necessary + exec nm-applet # Networkmanager applet + exec blueman-applet # Bluetoothmanager applet + exec blueman-tray # Bluetoothmanager tray icon + exec shikane # Manages displays and known display setups + exec sway-audio-idle-inhibit # Prevents sleep when audio is playing + exec swayosd-server # OSD server for audio and screen brightness popups + exec waybar # Status bar for sway + + assign [class="vesktop"] workspace 1 + assign [class="Signal"] workspace 1 + assign [app_id="firefox"] workspace 2 + assign [app_id="thunderbird"] workspace 10 + + + ### Key bindings + bindsym Mod4+Shift+Return exec $term + + bindsym $mod+Shift+Return exec $term + bindsym $mod+delete exec $term + bindsym $mod+Shift+c kill + bindsym $mod+q reload + bindsym $mod+x exec ${./..}/scripts/lockscript + bindsym $mod+Shift+s exec "${./..}/scripts/screenshot.sh" + + #bindsym $mod+p exec $menu -show combi -combi-modes "run" -modi combi -monitor "eDP-1" # rofi + bindsym $mod+p exec $menu -show combi -combi-modes "run" -modi combi + bindsym $mod+Shift+p exec $menu -show ssh -monitor "eDP-1" + + bindsym $mod+Shift+q exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -B 'Yes, exit sway' 'swaymsg exit' + + bindsym $mod+Shift+Control+c exec "swaymsg exit" + + #bindsym $mod+Escape exec 'swaymsg input type:keyboard xkb_switch_layout next' + + # bindsym $mod+odiaeresis exec woomer + + #bindsym $mod+a exec woomer + #bindsym $mod+p exec ${./..}/scripts/toggle_freeze_process.sh + + # Function Keys + bindsym $mod+Shift+m exec sleep 0.1 && swaymsg output eDP-1 dpms toggle + + bindsym $mod+Shift+y exec swayosd-client --brightness -2 + bindsym $mod+y exec swayosd-client --brightness +2 + + #bindsym $mod+m exec swayosd-client --output-volume mute-toggle --max-volume 200 + + bindsym $mod+Shift+v exec swayosd-client --output-volume -2 --max-volume 200 + bindsym $mod+v exec swayosd-client --output-volume +2 --max-volume 200 + + # Moving around: + bindsym $mod+$left focus left + bindsym $mod+$down focus down + bindsym $mod+$up focus up + bindsym $mod+$right focus right + + bindsym $mod+Left focus left + bindsym $mod+Down focus down + bindsym $mod+Up focus up + bindsym $mod+Right focus right + + bindsym $mod+Shift+$left move left + bindsym $mod+Shift+$down move down + bindsym $mod+Shift+$up move up + bindsym $mod+Shift+$right move right + + bindsym $mod+Shift+Left move left + bindsym $mod+Shift+Down move down + bindsym $mod+Shift+Up move up + bindsym $mod+Shift+Right move right + + bindsym $mod+u workspace prev + bindsym $mod+i workspace next + + # Workspaces: + bindsym $mod+1 workspace number 1 + bindsym $mod+2 workspace number 2 + bindsym $mod+3 workspace number 3 + bindsym $mod+4 workspace number 4 + bindsym $mod+5 workspace number 5 + bindsym $mod+6 workspace number 6 + bindsym $mod+7 workspace number 7 + bindsym $mod+8 workspace number 8 + bindsym $mod+9 workspace number 9 + bindsym $mod+0 workspace number 10 + + bindsym $mod+Shift+1 move container to workspace number 1 + bindsym $mod+Shift+2 move container to workspace number 2 + bindsym $mod+Shift+3 move container to workspace number 3 + bindsym $mod+Shift+4 move container to workspace number 4 + bindsym $mod+Shift+5 move container to workspace number 5 + bindsym $mod+Shift+6 move container to workspace number 6 + bindsym $mod+Shift+7 move container to workspace number 7 + bindsym $mod+Shift+8 move container to workspace number 8 + bindsym $mod+Shift+9 move container to workspace number 9 + bindsym $mod+Shift+0 move container to workspace number 10 + + # define display output names + set $disp1 "eDP-1" + set $disp2 "DP-1" + + # default display outputs for workspaces with fallback to disp1 + workspace 1 output $disp2 $disp1 + workspace 2 output $disp2 $disp1 + workspace 3 output $disp2 $disp1 + workspace 4 output $disp2 $disp1 + workspace 5 output $disp2 $disp1 + workspace 6 output $disp2 $disp1 + workspace 7 output $disp2 $disp1 + workspace 8 output $disp2 $disp1 + workspace 9 output $disp2 $disp1 + workspace 10 output $disp2 $disp1 + + workspace_auto_back_and_forth false + + # Fx stuff: + blur disable + blur_passes 0 + blur_radius 1 + blur_noise 0 + blur_brightness 1 + + corner_radius 12 + default_dim_inactive 0.15 + + # Layout stuff: + gaps inner 2 + gaps outer 2 + + gaps top 5 + #smart_borders on + #smart_gaps on + + default_border pixel 2 + corner_radius 0 + # disable_titlebar yes + floating_modifier $mod normal + + #bindsym $mod+h splith + #bindsym $mod+m splitv + + # Switch the current container between different layout styles + bindsym $mod+Comma layout tabbed + bindsym $mod+Period layout toggle split + + bindsym $mod+Return fullscreen + bindsym $mod+Shift+space floating toggle + bindsym $mod+space focus mode_toggle + + # Scratchpad: + # Sway has a "scratchpad", which is a bag of holding for windows. + # You can send windows there and get them back later. + + # Move the currently focused window to the scratchpad + bindsym $mod+Shift+Tab move scratchpad + + # Show the next scratchpad window or hide the focused scratchpad window. + # If there are multiple scratchpad windows, this command cycles through them. + bindsym $mod+Tab scratchpad show + + # Resizing containers: + #mode "resize" { + # left will shrink the containers width + # right will grow the containers width + # up will shrink the containers height + # down will grow the containers height + set $move_amount 175px + + bindsym $mod+Mod4+$right resize grow width $move_amount + bindsym $mod+Mod4+$up resize shrink height $move_amount + bindsym $mod+Mod4+$down resize grow height $move_amount + bindsym $mod+Mod4+$left resize shrink width $move_amount + + bindsym $mod+Mod4+Left resize grow width $move_amount + bindsym $mod+Mod4+Down resize shrink height $move_amount + bindsym $mod+Mod4+Up resize grow height $move_amount + bindsym $mod+Mod4+Right resize shrink width $move_amount + + # Return to default mode + # bindsym Return mode "default" + # bindsym Escape mode "default" + # bindsym $mod+r mode "resize" + ''; + }; + + + home-manager.users.me.programs.waybar = { + enable = true; + settings = { + mainbar = { + layer = "top"; + position = "top"; + + modules-left = [ + "group/options" + "sway/workspaces" + "sway/window#protocol" + "sway/window#name" + ]; + modules-center = [ + "clock" + ]; + modules-right = [ + "tray" + "pulseaudio" + "custom/gpu" + "memory" + "cpu" + "temperature" + "battery" + "power-profiles-daemon" + "custom/power-usage" + "disk" + ]; + + "custom/separator" = { + format = " "; + tooltip = false; + }; + "custom/options" = { + format = "  "; + tooltip = false; + }; + + "idle_inhibitor" = { + format = " {icon}"; + format-icons = { + activated = " "; + deactivated = "󰒲 "; + }; + }; + + "custom/quit" = { + format = " 󰗼 "; + tooltip = false; + on-click = "swaymsg exit"; + }; + "custom/lock" = { + format = " 󰍁 "; + tooltip = false; + on-click = "swaylock"; + }; + "custom/reboot" = { + format = "  "; + tooltip = false; + on-click = "/run/current-system/sw/bin/reboot"; + }; + "custom/power" = { + format = "  "; + tooltip = false; + on-click = "/run/current-system/sw/bin/shutdown now"; + }; + + "sway/workspaces" = { + disable-scroll = true; + format = " {name} "; + }; + + "sway/window#protocol" = { + format = "{shell}"; + max-length = 50; + rewrite = { + xwayland = ""; + xdg_shell = ""; + "" = " ᨐ "; + }; + }; + "sway/window#name" = { + format = "{title} "; + max-length = 25; + rewrite = { + "(.*)Mozilla Firefox(.*)" = "󰈹 "; + "(.*)nvim(.*)" = " "; + "(.*)Neovide(.*)" = " "; + "(.*)~(.*)" = " "; + "(.*)Alacritty(.*)" = " "; + "" = ""; + }; + }; + + "sway/language" = { + format = "{variant}"; + tooltip = false; + on-click = "swaymsg input type:keyboard xkb_switch_layout next"; + rewrite = { + "(.*)bone(.*)" = "eeeeeeeeeeee "; + "" = " ᨐ "; + }; + }; + + "custom/timer" = { + exec = "${./..}/scripts/waybar-timer.sh updateandprint"; + exec-on-event = true; + return-type = "json"; + interval = 1; + signal = 4; + format = "{icon} {0}"; + format-icons = { + standby = "󰔞"; + running = "󱎫"; + paused = "󱫟"; + }; + on-click = "${./..}/scripts/waybar-timer.sh new 25 'notify-send \"Timer done!\"'"; + on-click-middle = "${./..}/scripts/waybar-timer.sh cancel"; + on-click-right = "${./..}/scripts/waybar-timer.sh togglepause"; + on-scroll-up = "${./..}/scripts/waybar-timer.sh increase 60 || ${./..}/scripts/waybar-timer.sh new 1 'notify-send -u critical \"Timer expired.\"'"; + on-scroll-down = "${./..}/scripts/waybar-timer.sh increase -60"; + }; + + "clock" = { + format = " {:%H:%M}"; + format-alt = "{:%A, %B %d, %Y} "; + tooltip-format = "{calendar}"; + locale = "C"; + calendar = { + mode = "year"; + mode-mon-col = 3; + weeks-pos = "right"; + on-scroll = 1; + format = { + months = "{}"; + days = "{}"; + weeks = "{}"; + weekdays = "{}"; + today = "{}"; + }; + }; + actions = { + on-click-right = "mode"; + on-scroll-up = "shift_up"; + on-scroll-down = "shift_down"; + }; + }; + + "custom/outside-temperature" = { + interval = 1; + exec = "${./..}/nixos/scripts/get_weather_data.sh"; + tooltip-format = "Innsbruck Temperatur: {}°C"; + format = "T {}°C"; + tooltip = true; + }; + + "tray" = { + icon-size = 18; + spacing = 5; + }; + + "pulseaudio" = { + format = "{icon} {volume:2}%"; + format-bluetooth = " {volume}%"; + format-muted = "󰝟"; + format-icons = { + headphones = ""; + default = [ + "" + "" + ]; + }; + scroll-step = 5; + on-click = "pamixer -t"; + on-click-right = "pavucontrol"; + }; + + "custom/gpu" = { + interval = 1; + exec = "cat /sys/class/hwmon/hwmon*/device/gpu_busy_percent"; + format = "󰢮 {}%"; + tooltip = true; + }; + + "memory" = { + interval = 1; + format = " {}%"; + }; + + "cpu" = { + interval = 1; + format = " {usage:2}%"; + }; + + "temperature" = { + interval = 1; + thermal-zone = 2; + critical-threshold = 80; + format = "{icon} {temperatureC}°C"; + format-icons = [ + "" + "" + "" + "" + "" + "" + "" + "" + "" + ]; + }; + + "battery" = { + interval = 1; + states = { + good = 95; + warning = 30; + critical = 15; + }; + format = "{icon} {capacity}%"; + format-plugged = "󰂄 {capacity}%"; + format-charging = "󰂄 {capacity}%"; + format-icons = [ + "󰂎" + "󰁺" + "󰁻" + "󰁼" + "󰁽" + "󰁾" + "󰁿" + "󰂀" + "󰂁" + "󰂂" + "󰁹" + ]; + }; + + "disk" = { + interval = 60; + format = "󰋊 {percentage_used:2}%"; + path = "/"; + }; + + "custom/power-usage" = { + exec = "${pkgs.bash}/bin/bash ${./..}/scripts/get_power_usage.sh"; + format = "{}W"; + interval = 1; + }; + + "power-profiles-daemon" = { + format = "{icon}"; + tooltip-format = "Power profile: {profile}"; + tooltip = true; + format-icons = { + default = ""; + performance = ""; + balanced = ""; + power-saver = ""; + }; + }; + + "user" = { + format = " {work_d}d {work_H}h"; + interval = 60; + height = 20; + width = 20; + }; + + "group/options" = { + orientation = "horizontal"; + drawer = { + transition-duration = 300; + children-class = "option"; + transition-left-to-right = true; + }; + modules = [ + "custom/options" + "user" + "idle_inhibitor" + "custom/quit" + "custom/lock" + "custom/reboot" + "custom/power" + ]; + }; + }; + }; + + style = '' + * { + font-size: 22px; + font-family: "HackNerdFont-Regular", monospace; + } + + window#waybar { + background: rgba(0,0,0,0); + color: #ffffff; + } + + #custom-options, + #custom-quit, + #custom-lock, + #custom-reboot, + #custom-power, + #idle_inhibitor, + #user, + #custom-timer, + #clock, + #language, + #tray, + #custom-outside-temperature, + #pulseaudio, + #custom-gpu, + #memory, + #cpu, + #temperature, + #battery, + #power-profiles-daemon, + #custom-power-usage, + #disk { + background: #1c1c1c; + padding: 0px 15px; + margin: 0 4px; + border-radius: 20px; + transition: background-color 0.2s ease; + transition: color 0.2s ease; + } + + #custom-options { + border-radius: 20px; + padding-right: 5px; + color: #b4befe; + } + + #user:hover, + #idle_inhibitor:hover, + #custom-quit:hover, + #custom-lock:hover, + #custom-reboot:hover, + #custom-power:hover, + #custom-options:hover, + #user:hover, + #custom-timer:hover, + #clock:hover, + #pulseaudio:hover, + #custom-gpu:hover, + #memory:hover, + #cpu:hover, + #temperature:hover, + #battery:hover, + #power-profiles-daemon:hover, + #custom-power-usage:hover, + #disk:hover, + #custom-outside-temperature:hover { + color: #000000; + } + + #idle_inhibitor, + #custom-quit, + #custom-lock, + #custom-reboot, + #custom-power { + background: #1c1c1c; + margin-left: 3px; + margin-right: 3px; + } + + #custom-options { + color: #cba6f7; + border: 1.5px solid #cba6f7; + padding-left: 10px; + } + + #user { + color: #b4befe; + border: 1.5px solid #b4befe; + padding-right: 20px; + } + + #idle_inhibitor + { + color: #89dceb; + border: 1.5px solid #89dceb; + padding-right: 20px; + } + + #custom-quit { + color: #a6e3a1; + border: 1.5px solid #a6e3a1; + padding-right: 20px; + } + #custom-lock { + color: #f9e2af; + border: 1.5px solid #f9e2af; + padding-right: 20px; + } + #custom-reboot { + color: #fab387; + border: 1.5px solid #fab387; + padding-right: 20px; + } + #custom-power { + color: #e78284; + border: 1.5px solid #e78284; + padding-right: 20px; + } + + #custom-options:hover { + background: #cba6f7; + } + #user:hover { + background: #b4befe; + } + #idle_inhibitor:hover { + background: #89dceb; + } + #custom-quit:hover { + background: #a6e3a1; + } + #custom-lock:hover { + background: #f9e2af; + } + #custom-reboot:hover { + background: #fab387; + } + #custom-power:hover { + background: #e78284; + } + + #workspaces button { + padding: 0px; + color: #ffffff; + background: #1c1c1c; + margin-left: 4px; + margin-right: 4px; + border-radius: 20px; + } + + #workspaces button.focused { + color: #000000; + background: #ffffff; + } + #workspaces button:hover { + color: #000000; + box-shadow: inherit; + text-shadow: inherit; + } + #workspaces button:nth-child(1) { + border: 1.5px solid #b4befe; + } + #workspaces button:nth-child(2) { + border: 1.5px solid #89dceb; + } + #workspaces button:nth-child(3) { + border: 1.5px solid #a6e3a1; + } + #workspaces button:nth-child(4) { + border: 1.5px solid #f9e2af; + } + #workspaces button:nth-child(5) { + border: 1.5px solid #fab387; + } + #workspaces button:nth-child(6) { + border: 1.5px solid #e78284; + } + #workspaces button:nth-child(7) { + border: 1.5px solid #eba0ac; + } + #workspaces button:nth-child(8) { + border: 1.5px solid #f5c2e7; + } + #workspaces button:nth-child(9) { + border: 1.5px solid #cba6f7; + } + #workspaces button:nth-child(10) { + border: 1.5px solid #ffffff; + } + #workspaces button.focused:nth-child(1), + #workspaces button:hover:nth-child(1) { + background: #b4befe; + } + #workspaces button.focused:nth-child(2), + #workspaces button:hover:nth-child(2) { + background: #89dceb; + } + #workspaces button.focused:nth-child(3), + #workspaces button:hover:nth-child(3) { + background: #a6e3a1; + } + #workspaces button.focused:nth-child(4), + #workspaces button:hover:nth-child(4) { + background: #f9e2af; + } + #workspaces button.focused:nth-child(5), + #workspaces button:hover:nth-child(5) { + background: #fab387; + } + #workspaces button.focused:nth-child(6), + #workspaces button:hover:nth-child(6) { + background: #e78284; + } + #workspaces button.focused:nth-child(7), + #workspaces button:hover:nth-child(7) { + background: #eba0ac; + } + #workspaces button.focused:nth-child(8), + #workspaces button:hover:nth-child(8) { + background: #f5c2e7; + } + #workspaces button.focused:nth-child(9), + #workspaces button:hover:nth-child(9) { + background: #cba6f7; + } + #workspaces button.focused:nth-child(10), + #workspaces button:hover:nth-child(10) { + background: #ffffff; + } + + #custom-timer { + border: 1.5px solid #f9e2af; + } + + #window.protocol { + background: #1c1c1c; + margin-left: 2px; + border: 1.5px solid #ffffff; + border-right: none; + border-radius: 20px 0px 0px 20px; + } + + #window.name { + background: #1c1c1c; + border: 1.5px solid #ffffff; + border-left: none; + border-radius: 0px 20px 20px 0px; + } + + #clock { + padding: 0px 20px 0px 20px; + font-family: sourcecodepronormal; + border: 1.5px solid #ffffff; + color: #ffffff; + } + + #language { + padding: 0px 20px 0px 20px; + border: 1.5px solid #ffffff; + color: #ffffff; + } + + tooltip { + background-color: #171717; + padding: 20px; + margin: 20px; + border-width: 2px; + border-color: #aaaaaa; + border-radius: 20px; + } + + #clock:hover { + background: #ffffff; + } + + #custom-outside-temperature { + border: 1.5px solid #cba6f7; + } + + #custom-outside-temperature:hover { + background: #cba6f7; + } + + #tray { + border: 1.5px solid #cba6f7; + } + #pulseaudio { + border: 1.5px solid #f5c2e7; + } + #custom-gpu { + border: 1.5px solid #eba0ac; + } + #memory { + border: 1.5px solid #e78284; + } + #cpu { + border: 1.5px solid #fab387; + } + #temperature { + border: 1.5px solid #f9e2af; + } + #battery { + border: 1.5px solid #a6e3a1; + } + #custom-power-usage, + #power-profiles-daemon { + border: 1.5px solid #89dceb; + + } + #disk { + border: 1.5px solid #b4befe; + } + + #power-profiles-daemon { + margin-right: 0px; + padding-right: 16px; + border-radius: 20px 0px 0px 20px; + border-right: none; + } + + #custom-power-usage { + margin-left: 0px; + padding-left: 0px; + border-radius: 0px 2px; + border-radius: 0px 20px 20px 0px; + border-left: none; + } + + #custom-timer:hover { + background: #f9e2af; + } + #tray:hover { + background: #cba6f7; + } + #pulseaudio:hover { + background: #f5c2e7; + } + #custom-gpu:hover { + background: #eba0ac; + } + #memory:hover { + background: #e78284; + } + #cpu:hover { + background: #fab387; + } + #temperature:hover { + background: #f9e2af; + } + #battery:hover { + background: #a6e3a1; + } + #custom-power-usage:hover, + #power-profiles-daemon:hover { + background: #89dceb; + } + #disk:hover { + background: #b4befe; + } + ''; + }; + + home-manager.users.me.home.file.".config/swaylock/config".text = '' + daemonize + show-failed-attempts + show-keyboard-layout + ignore-empty-password + fingerprint + image=$HOME/Pictures/Screenshots/screen.png + indicator-radius=200 + indicator-thickness=10 + inside-color=#00000000 + line-color=#00000000 + ring-color=#00000000 + text-color=#00000000 + + layout-bg-color=#00000000 + layout-text-color=#00000000 + + inside-clear-color=#00000000 + line-clear-color=#00000000 + ring-clear-color=#ffff99 + text-clear-color=#00000000 + + inside-ver-color=#00000000 + line-ver-color=#00000000 + ring-ver-color=#70ffff + text-ver-color=#00000000 + + inside-wrong-color=#00000000 + line-wrong-color=#00000000 + ring-wrong-color=#ff5555 + text-wrong-color=#00000000 + + bs-hl-color=#ff5555 + key-hl-color=#99ff99 + + text-caps-lock-color=#ffffff + ''; + +} diff --git a/flake.lock b/flake.lock index efbe6ed..7cb3b3f 100644 --- a/flake.lock +++ b/flake.lock @@ -2911,8 +2911,8 @@ }, "original": { "owner": "NixOS", - "ref": "release-24.05", "repo": "nixpkgs", + "rev": "b9562c824b11473587286eb499680129c2d0d4f1", "type": "github" } }, diff --git a/flake.nix b/flake.nix index 34eb101..4e57a78 100644 --- a/flake.nix +++ b/flake.nix @@ -3,7 +3,8 @@ ################################### INPUTS ######################################### inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/release-24.05"; + #nixpkgs.url = "github:NixOS/nixpkgs/release-24.11"; + nixpkgs.url = "github:NixOS/nixpkgs/b9562c824b11473587286eb499680129c2d0d4f1"; #nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; @@ -83,13 +84,13 @@ }; }; - outputs = { self, nixpkgs, nixpkgs-unstable, nixos-generators, flake-utils, systems, ... }@inputs: + outputs = { self, nixpkgs, nixpkgs-unstable, nixos-generators, flake-utils, systems, ... }@inputs: ################################### LET FOR OUPUTS ######################################### let confDir = "/home/me/work/config"; workDir = "/home/me/work"; - secretsDir = "/home/me/work/here/secrets"; + secretsDir = "/home/me/secrets"; persistentDir = "/home/me/work/app-data"; tunepkgs = import nixpkgs { @@ -116,19 +117,26 @@ "electron-25.9.0" ]; }; - overlays = [ + overlays = [ #( import ./mods/my-nixpkgs-overlay.nix { inherit nixpkgs; } ) #( import ./mods/second-overlay.nix { inherit nixpkgs; } ) ]; }; specialArgs = { - inherit inputs confDir workDir secretsDir persistentDir self tunepkgs; + inherit inputs confDir workDir secretsDir persistentDir self tunepkgs unstable nur; system = "x86_64-linux"; pkgs = mypkgs; }; - eachSystem = inputs.flake-utils.outputs.lib.eachSystem; - allSystems = inputs.flake-utils.outputs.lib.allSystems; + eachSystem = inputs.flake-utils.outputs.lib.eachSystem; + allSystems = inputs.flake-utils.outputs.lib.allSystems; + + unstable = import nixpkgs-unstable { + system = "x86_64-linux"; + config.allowUnfree = true; + }; + + nur = import inputs.nur { pkgs = mypkgs; }; in ################################### EACH SYSTEM OUPUTS ######################################### @@ -286,6 +294,14 @@ ]; }; + "mac" = nixpkgs.lib.nixosSystem { + inherit specialArgs; + system = "x86_64-linux"; + modules = [ + ./hosts/mac.nix + ]; + }; + "gui" = nixpkgs.lib.nixosSystem { inherit specialArgs; system = "x86_64-linux"; @@ -544,3 +560,4 @@ }; }; } + diff --git a/hardware/fusu.nix b/hardware/fusu.nix index 7d0432b..60b2555 100644 --- a/hardware/fusu.nix +++ b/hardware/fusu.nix @@ -23,6 +23,11 @@ fsType = "ext4"; }; + fileSystems."/boot" = + { device = "/dev/disk/by-label/FUSU-BOOT"; + fsType = "vfat"; + }; + swapDevices = [ ]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking diff --git a/hardware/hpm-laptop.nix b/hardware/hpm-laptop.nix index d75bc2e..8d566fb 100755 --- a/hardware/hpm-laptop.nix +++ b/hardware/hpm-laptop.nix @@ -23,8 +23,18 @@ boot.initrd.kernelModules = [ "dm-snapshot" ]; boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; - boot.loader.efi.canTouchEfiVariables = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.initrd.luks.devices = { + root = { + #name = "root"; + device = "/dev/disk/by-partuuid/ffc93316-5bcf-478a-9143-9ccacd428f48"; + preLVM = true; + allowDiscards = true; + }; + }; + + /* fileSystems."/" = { device = "/dev/disk/by-uuid/6518e61e-7120-48ef-81a3-5eae0f67297e"; fsType = "btrfs"; @@ -34,6 +44,16 @@ device = "/dev/disk/by-uuid/0E6C-F209"; fsType = "vfat"; }; + */ + fileSystems."/" = { + device = "/dev/disk/by-label/main-root"; + fsType = "btrfs"; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-label/MAIN-BOOT"; + fsType = "vfat"; + }; #swapDevices = [ #{ device = "/dev/disk/by-uuid/418bf0d8-e548-45d5-802a-53de72707ebc"; } diff --git a/hosts/fusu.nix b/hosts/fusu.nix index 89f418e..d60a5d4 100644 --- a/hosts/fusu.nix +++ b/hosts/fusu.nix @@ -9,25 +9,36 @@ inputs.home-manager.nixosModules.home-manager ../users/me/headless.nix ../users/root/default.nix - ../users/server/headles.nix + ../users/files/headless.nix ]; # mac address for wakeonlan: 00:19:99:fd:28:23 # allow acern to ssh into server - users.users.server.openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHTV1VoNAjMha5IP+qb8XABDo02pW3iN0yPBIbSqZA27 me@acern" - ]; + #users.users.server.openssh.authorizedKeys.keys = [ + #"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHTV1VoNAjMha5IP+qb8XABDo02pW3iN0yPBIbSqZA27 me@acern" + #]; # allow server user to shutdown fusu - security.sudo.extraRules = [ - { - users = [ "server" ]; - commands = [ { command = "/run/current-system/sw/bin/shutdown"; options = [ "SETENV" "NOPASSWD" ]; } ]; - } - ]; + #security.sudo.extraRules = [ + #{ + #users = [ "server" ]; + #commands = [ { command = "/run/current-system/sw/bin/shutdown"; options = [ "SETENV" "NOPASSWD" ]; } ]; + #} + #]; + + + boot.supportedFilesystems = [ "zfs" ]; + boot.zfs.package = pkgs.zfs_unstable; + boot.zfs.forceImportRoot = false; + networking.hostId = "7552c83e"; + + fileSystems."/home/files/storage" = { + device = "storage"; + fsType = "zfs"; + }; virtualisation.libvirtd = { enable = true; @@ -39,7 +50,8 @@ # Use the GRUB 2 boot loader. boot.loader.grub = { enable = true; - device = "/dev/disk/by-id/ata-TOSHIBA_MQ04ABF100_11MYT5RBT"; + #device = "/dev/disk/by-id/ata-TOSHIBA_MQ04ABF100_11MYT5RBT"; + device = "nodev"; # don't install, when i do nixre -h fusu ... but when installing onto the two discs (sata hdd and nvme ssd) change to the device like above efiSupport = false; extraConfig = '' set timeout=2 @@ -57,6 +69,7 @@ settings.PasswordAuthentication = false; settings.KbdInteractiveAuthentication = false; settings.PermitRootLogin = "yes"; + ports = [ 49388 ]; settings.X11Forwarding = true; @@ -76,11 +89,9 @@ 8080 # for mitm proxy 5901 # vnc - 25565 # mc server - 25566 # mc server ]; - networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. + networking.networkmanager.enable = false; # Easiest to use and most distros use this by default. # to build rpi images boot.binfmt.emulatedSystems = [ @@ -111,7 +122,7 @@ prefixLength = 24; } ]; networking = { - #usePredictableInterfaceNames = false; + usePredictableInterfaceNames = true; defaultGateway = { address = "192.168.1.1"; interface = "br0"; diff --git a/hosts/mac.nix b/hosts/mac.nix new file mode 100644 index 0000000..4d2dc76 --- /dev/null +++ b/hosts/mac.nix @@ -0,0 +1,157 @@ +{ pkgs, inputs, ... }: let + +myobs = pkgs.wrapOBS { + plugins = with pkgs.obs-studio-plugins; [ + obs-ndi + obs-teleport + ]; +}; + + +in { + + imports = [ + ../common/all.nix + ../common/nixos.nix + ../common/building.nix + + inputs.home-manager.nixosModules.home-manager + ../users/me/headless.nix + ../users/root/default.nix + ]; + + networking.hostName = "mac"; + networking.firewall.enable = false; + networking.useDHCP = true; + services.avahi = { + enable = true; + nssmdns = true; + publish = { + enable = true; + addresses = true; + domain = true; + hinfo = true; + userServices = true; + workstation = true; + }; + }; + + # Use the GRUB 2 boot loader. + boot.loader.grub = { + enable = true; + #device = "/dev/nbd1"; + device = "nodev"; + efiSupport = true; + extraConfig = '' + set timeout=2 + ''; + }; + + environment.systemPackages = with pkgs; [ + mount + pkgs.hicolor-icon-theme + efibootmgr + tcpdump + ]; + + + fileSystems."/" = { + device = "/dev/disk/by-label/mac-root"; + fsType = "ext4"; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-label/EFI"; + fsType = "vfat"; + }; + + networking = { + #usePredictableInterfaceNames = false; + defaultGateway = { + address = "192.168.1.1"; + interface = "enp2s0"; + }; + nameservers = [ "1.1.1.1" "8.8.8.8" ]; + interfaces = { + "enp2s0" = { + name = "enp2s0"; + ipv4.addresses = [ + { address = "192.168.1.33"; prefixLength = 24;} + ]; + }; + }; + }; + + services.openssh = { + enable = true; + # require public key authentication for better security + settings.PasswordAuthentication = false; + settings.KbdInteractiveAuthentication = false; + settings.PermitRootLogin = "no"; + + settings.X11Forwarding = true; + + extraConfig = '' + X11UseLocalhost no + ''; + }; + + ###################################################### the kiosk stuff + + boot.plymouth.enable = true; + services.dbus.enable = true; + + fonts.enableDefaultPackages = true; + xdg.icons.enable = true; + gtk.iconCache.enable = true; + + services.udisks2.enable = false; + hardware.opengl.enable = true; + hardware.enableRedistributableFirmware = true; + + systemd.services."cage@" = { + enable = true; + after = [ "systemd-user-sessions.service" "dbus.socket" "systemd-logind.service" "getty@%i.service" "plymouth-deactivate.service" "plymouth-quit.service" ]; + before = [ "graphical.target" ]; + wants = [ "dbus.socket" "systemd-logind.service" "plymouth-deactivate.service" ]; + wantedBy = [ "graphical.target" ]; + conflicts = [ "getty@%i.service" ]; # "plymouth-quit.service" "plymouth-quit-wait.service" + + restartIfChanged = false; + serviceConfig = { + ExecStart = "${pkgs.cage}/bin/cage -d -- ${myobs}/bin/obs"; + User = "root"; + + # ConditionPathExists = "/dev/tty0"; + IgnoreSIGPIPE = "no"; + + # Log this user with utmp, letting it show up with commands 'w' and + # 'who'. This is needed since we replace (a)getty. + UtmpIdentifier = "%I"; + UtmpMode = "user"; + # A virtual terminal is needed. + TTYPath = "/dev/%I"; + TTYReset = "yes"; + TTYVHangup = "yes"; + TTYVTDisallocate = "yes"; + # Fail to start if not controlling the virtual terminal. + StandardInput = "tty-fail"; + #StandardOutput = "syslog"; + #StandardError = "syslog"; + # Set up a full (custom) user session for the user, required by Cage. + PAMName = "cage"; + }; + }; + + security.pam.services.cage.text = '' + auth required pam_unix.so nullok + account required pam_unix.so + session required pam_unix.so + session required ${pkgs.systemd}/lib/security/pam_systemd.so + ''; + + systemd.targets.graphical.wants = [ "cage@tty1.service" ]; + + systemd.defaultUnit = "graphical.target"; + +} diff --git a/hosts/main.nix b/hosts/main.nix index fcc7db7..d5fc5b8 100644 --- a/hosts/main.nix +++ b/hosts/main.nix @@ -10,6 +10,34 @@ # ??????????? TODO # fileSystems."/".options = [ "noatime" "nodiratime" "discard" ]; + +/* + services.xserver.displayManager.gdm.enable = true; + services.xserver.displayManager.gdm.wayland = false; + services.xserver.desktopManager.plasma5.enable = true; + + + modules.battery_monitor.enable = true; + services.blueman.enable = true; + hardware.bluetooth.enable = true; + + + # Enable the gnome-keyring secrets vault. + # Will be exposed through DBus to programs willing to store secrets. + services.gnome.gnome-keyring.enable = true; + + # enable Sway window manager + programs.sway = { + enable = true; + wrapperFeatures.gtk = true; + }; + */ + + #services.openssh.enable = true; + + virtualisation.vmVariant.services.timesyncd.enable = lib.mkForce false; + + services.nscd.enable = lib.mkForce false; virtualisation.docker.enable = true; @@ -21,6 +49,8 @@ ''; services.xserver.displayManager.xserverArgs = [ "-listen tcp" ]; + nixpkgs.config.allowUnfree = lib.mkForce true; + programs.nix-ld.enable = true; programs.steam.enable = true; @@ -33,8 +63,10 @@ imports = [ ../common/all.nix ../common/nixos-headless.nix - ../common/nixos-graphical.nix + #../common/nixos-graphical.nix + ../common/nixos-wayland.nix ../common/building.nix + ../mods/battery_monitor.nix inputs.networkmanager.nixosModules.networkmanager inputs.home-manager.nixosModules.home-manager @@ -48,6 +80,17 @@ environment.systemPackages = with pkgs; [ + grim # screenshot functionality + slurp # screenshot functionality + wl-clipboard # wl-copy and wl-paste for copy/paste from stdin / stdout + mako # notification system developed by swaywm maintainer + (pkgs.wrapOBS { + plugins = with obs-studio-plugins; [ + obs-ndi + obs-teleport + ]; + }) + slint-lsp cifs-utils nfs-utils @@ -159,8 +202,19 @@ security.polkit.enable = true; services.rpcbind.enable = true; - services.avahi.enable = true; - services.avahi.hostName = "c2vi"; + #services.avahi.hostName = "c2vi"; + services.avahi = { + enable = true; + nssmdns = true; + publish = { + enable = true; + addresses = true; + domain = true; + hinfo = true; + userServices = true; + workstation = true; + }; + }; networking.networkmanager.enable = true; #networking.networkmanager.extraConfig = '' @@ -170,7 +224,7 @@ #networking.useDHCP = lib.mkForce true; networking.firewall.allowPing = true; - networking.firewall.enable = true; + networking.firewall.enable = false; services.samba.openFirewall = true; @@ -190,7 +244,7 @@ 53 # allow dns ]; - networking.search = [ "c2vi.local" ]; + #networking.search = [ "c2vi.local" ]; #networking.hosts = { #"10.1.1.3" = [ "phone" ]; #}; @@ -489,8 +543,8 @@ ############################## swap and hibernate ################################### - swapDevices = [ { device = "/dev/lvm0/swap"; } ]; - boot.resumeDevice = "/dev/lvm0/swap"; + swapDevices = [ { device = "/swapfile"; } ]; + boot.resumeDevice = "/swapfile"; services.logind = { extraConfig = '' HandlePowerKey=suspend-then-hibernate @@ -500,7 +554,7 @@ lidSwitchDocked = "ignore"; }; systemd.sleep.extraConfig = '' - HibernateDelaySec=2h + HibernateDelaySec=27h HibernateMode=shutdown ''; } diff --git a/hosts/test b/hosts/test deleted file mode 100644 index 32f95c0..0000000 --- a/hosts/test +++ /dev/null @@ -1 +0,0 @@ -hi \ No newline at end of file diff --git a/misc/my-hosts-h b/misc/my-hosts-h index 98362f4..2206e01 100644 --- a/misc/my-hosts-h +++ b/misc/my-hosts-h @@ -1,9 +1,8 @@ 192.168.1.6 hpm -192.168.1.3 fusu -192.168.1.2 rpi +192.168.1.2 fusu 192.168.1.2 files -192.168.1.2 rpis 192.168.1.5 acern 192.168.1.22 fasu 192.168.1.1 rou 192.168.1.1 router +192.168.1.33 mac diff --git a/mods/nurPkgs/ndi-monitor.nix b/mods/nurPkgs/ndi-monitor.nix new file mode 100644 index 0000000..c91286b --- /dev/null +++ b/mods/nurPkgs/ndi-monitor.nix @@ -0,0 +1,54 @@ +{ stdenv +, fetchFromGitHub +, lib +, ndi +}: + +stdenv.mkDerivation rec { + pname = "ndi-monitor"; + version = "0.3.2"; + + src = fetchFromGitHub { + owner = "lplassman"; + repo = "NDI-Monitor"; + rev = "f4ae6506d308b1b847e449833aa4cea3555caf15"; + sha256 = "sha256-YLNvFdyqKb6DJV/cmdF8O5hmxOOqCCFbwGlFxI6rpW0="; + }; + + patches = [ ./ndi-monitor.patch ]; + + nativeBuildInputs = [ + ndi + ]; + + buildPhase = '' + g++ -std=c++14 -pthread -Wl,--allow-shlib-undefined -Wl,--as-needed -Iinclude/ -I${ndi}/include/ -L lib -o ndi_monitor ndi_monitor.cpp mongoose.c mjson.c -lndi -ldl + ''; + + installPhase = '' + mkdir -p $out/bin + cp ndi_monitor $out/bin/ndi-monitor + cp -r $src/assets $out + ''; + + buildInputs = [ + #ncurses + ]; + + meta = with lib; { + description = "A small pogram to display network traffic of interfaces in realtime"; + longDescription = '' + Simple curses-based GUI. + + It is useful for Internet or LAN speed tests, measuring the velocity of a link, to establish a benchmark or to monitor your connections. + + CBM can be used with virtual, wired or wireless networks. + + Originally imported from some tarballs from the Debian Project: http://snapshot.debian.org/package/cbm/. Now maintained by volunteers. + ''; + homepage = "https://github.com/resurrecting-open-source-projects/cbm"; + license = licenses.gpl2Only; + #maintainers = [ ]; + platforms = platforms.all; + }; +} diff --git a/mods/nurPkgs/ndi-monitor.patch b/mods/nurPkgs/ndi-monitor.patch new file mode 100644 index 0000000..67e0c56 --- /dev/null +++ b/mods/nurPkgs/ndi-monitor.patch @@ -0,0 +1,13 @@ +diff --git a/ndi_monitor.cpp b/ndi_monitor.cpp +index 6de4dff..6b5c35b 100644 +--- a/ndi_monitor.cpp ++++ b/ndi_monitor.cpp +@@ -84,7 +84,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data){ + }else if(mg_http_match_uri(hm, "/rest")) { //handle REST events + mg_http_reply(c, 200, "", "{\"result\": %d}\n", 123); + }else{ // Serve static files +- struct mg_http_serve_opts opts = {.root_dir = "/opt/ndi_monitor/assets/"}; ++ struct mg_http_serve_opts opts = {.root_dir = getenv("NDI_MONITOR_ASSETS_DIR")}; + mg_http_serve_dir(c, (mg_http_message*)ev_data, &opts); + } + }else if (ev == MG_EV_WS_MSG){ diff --git a/mybin/htldoc b/mybin/htldoc index 203620d..84e84c7 100755 --- a/mybin/htldoc +++ b/mybin/htldoc @@ -1,12 +1,9 @@ #!/bin/sh if [ -f "htldoc.nix" ]; then - echo -en "" + htldocUrl=$(nix eval --expr 'let config = (import ./htldoc.nix {}); in if builtins.hasAttr "htldocVersion" config then config.htldocVersion else "github:c2vi/htldoc/master"' --impure) + nix run $htldocUrl -- $@ else - echo "There is not htldoc.nix in this directory" >&2 - exit 1 + nix run github:c2vi/htldoc/master -- $@ fi -htldocUrl=$(nix eval --expr 'let config = (import ./htldoc.nix {}); in if builtins.hasAttr "htldocVersion" config then config.htldocVersion else "github:c2vi/htldoc/master"' --impure) - -nix run $htldocUrl diff --git a/mybin/ru b/mybin/ru index f3498ed..bcefacd 100755 --- a/mybin/ru +++ b/mybin/ru @@ -17,6 +17,11 @@ then ssh tab "rm /sdcard/note/CUR/*" +elif [ "$1" == "du" ] +then +du -d 1 -h $2 | sort -h -r + + elif [ "$1" == "mnt-wechner" ] then rclone mount --vfs-cache-mode full -vvvv onedrive-school:projekt-autobatterie ~/work/htl/projekt/wechner/mnt @@ -104,7 +109,7 @@ sudo systemctl hibernate elif [ "$1" == "suspend" ] then -sudo systemctl suspend +sudo systemctl suspend-then-hibernate fi diff --git a/programs/lf/default.nix b/programs/lf/default.nix index 569e0d3..f6e3d36 100644 --- a/programs/lf/default.nix +++ b/programs/lf/default.nix @@ -164,7 +164,7 @@ set shellopts "-eu" set ifs "\n" set shell "bash" - set ruler "df:acc:progress:selection:filter:ind" + #set ruler "df:acc:progress:selection:filter:ind" ''; }; } diff --git a/programs/ssh.nix b/programs/ssh.nix index 9f6017c..56572cd 100644 --- a/programs/ssh.nix +++ b/programs/ssh.nix @@ -31,10 +31,6 @@ hostname = "127.0.0.1"; user = "me"; }; - rpi = { - port = 49388; - user = "me"; - }; files = { port = 49388; user = "files"; @@ -59,11 +55,6 @@ hpm = { user = "me"; }; - - fusus = { - hostname = "fusu"; - user = "server"; - }; fasu = { hostname = "fasu"; user = "me"; @@ -74,6 +65,7 @@ }; fusu = { + port = 49388; hostname = "fusu"; user = "me"; }; diff --git a/random-pkgs.nix b/random-pkgs.nix index 1fc1628..739c6c5 100644 --- a/random-pkgs.nix +++ b/random-pkgs.nix @@ -40,6 +40,58 @@ in rec { }; + ####################################################################### + # make an iso + #to build: nix build .#random.iso.config.system.build.isoImage + + # an old old nixpkgs: https://github.com/NixOS/nixpkgs/tree/release-15.09 + iso = let + oldNixpkgsSrc = pkgs.fetchFromGitHub { + owner = "NixOS"; + repo = "nixpkgs"; + rev = "cc7c26173149348ba43f0799fac3f3823a2d21fc"; # 15.09 + #rev = "3ba3d8d8cbec36605095d3a30ff6b82902af289c"; + #rev = "71db8c7a02f3be7cb49b495786050ce1913246d3"; + hash = "sha256-Bu0ECsynGNuj4lYK/QcvuKqKCKd6b1j8jlE7fLjE+t0="; + }; + oldPkgs = import oldNixpkgsSrc { system = "x86_64-linux"; }; + + # ${nixpkgs-repo}/nixos/default.nix holds a function, that takes a system and a configuration and outputs just what nixpkgs.lib.nixosSystem outputs + # so we can make our own nixosSystem func + oldNixosSystem = { system, modules, ... }: import (oldNixpkgsSrc + "/nixos") { + inherit system; + configuration = { imports = modules; }; + }; + + + + system = oldNixosSystem { + system = "x86_64-linux"; + modules = [ + (oldNixpkgsSrc + "/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix") + ({ pkgs, ...}: { + boot.initrd.kernelModules = [ "fbcon" ]; + services.openssh.enable = true; + users.users.root.password = "changeme"; + + services.xserver.enable = false; + #services.displayManager.enable = false; + }) + ]; + }; + in system.config.system.build.isoImage; + + + + obs = let + pkgs = import inputs.nixpkgs-unstable { inherit system; }; + in pkgs.wrapOBS { + plugins = with pkgs.obs-studio-plugins; [ + obs-ndi + ]; + }; + + zephyr = inputs.zephyr-nix.packages.${system}; @@ -178,7 +230,7 @@ in rec { }); run-vm = specialArgs.pkgs.writeScriptBin "run-vm" '' - ${self.nixosConfigurations.hpm.config.system.build.vm}/bin/run-hpm-vm -m 4G -cpu host -smp 4 + ${self.nixosConfigurations.main.config.system.build.vm}/bin/run-main-vm -m 4G -cpu host -smp 4 ''; hec-img = nixos-generators.nixosGenerate { diff --git a/scripts/batteryscript.sh b/scripts/batteryscript.sh new file mode 100755 index 0000000..bbb9954 --- /dev/null +++ b/scripts/batteryscript.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash + +# Settings +battery_percent_MODULUS=5 # How many percent difference are required for another update +INTERVAL=5 # The interval at which to check the battery percentage +ALERT_SCRIPT="sudo /home/mia/Scripts/keyboard_alert.sh" + +# Battery Levels +BAT_RECOMMENDED_UPPER_LIMIT=80 +BAT_RECOMMENDED_LOWER_LIMIT=40 +BAT_SLIGHTLY_LOW=30 +BAT_LOW=20 +BAT_VERY_LOW=10 +BAT_HIB=5 + +force_notification=0 +last_battery_percent=0 + +get_percentage() +{ + echo $(cat /sys/bus/acpi/drivers/battery/*/power_supply/BAT?/capacity) +} + +countdown() +{ + for i in $(seq 1 10); + do + if [[ $(cat /sys/bus/acpi/drivers/battery/*/power_supply/BAT?/status) = "Charging" ]]; then + return + fi + + sleep 1 + notify-send $((10-$i)) -u critical + done + systemctl hibernate +} + +while true; +do + sleep $INTERVAL + + battery_percent=$(get_percentage) + + if [[ $battery_percent -eq $last_battery_percent ]]; then + continue + fi + + if [[ $(( battery_percent % $battery_percent_MODULUS )) -ne 0 && $force_notification -ne 1 ]]; then + continue + fi + + # Is battery charging? + if [[ $(cat /sys/bus/acpi/drivers/battery/*/power_supply/BAT?/status) = "Charging" ]]; then + if [[ $battery_percent -ge $BAT_RECOMMENDED_UPPER_LIMIT ]]; then + notify-send "Im full!" -u low + $ALERT_SCRIPT + fi + + # Is battery discharging? + else + if [[ $battery_percent -le $BAT_HIB ]]; then + notify-send "Self destructing in T Minus 10 Seconds..." -u critical && + countdown + elif [[ $battery_percent -le $BAT_VERY_LOW ]]; then + notify-send "I beg you, I'm about to die!" -u critical && + $ALERT_SCRIPT 5 + elif [[ $battery_percent -le $BAT_LOW ]]; then + notify-send "Can you please plug me in aleady? I'm dying!" -u normal && + $ALERT_SCRIPT 2 + elif [[ $battery_percent -le $BAT_SLIGHTLY_LOW ]]; then + notify-send "I'd need a recharge about now pwp" -u normal && + $ALERT_SCRIPT 1 + elif [[ $battery_percent -le $BAT_RECOMMENDED_LOWER_LIMIT ]]; then + notify-send "Please plug me in pwp" -u low + fi + fi + + last_battery_percent=$battery_percent +done diff --git a/scripts/change_charging_state.sh b/scripts/change_charging_state.sh new file mode 100755 index 0000000..d8ce715 --- /dev/null +++ b/scripts/change_charging_state.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +export XDG_RUNTIME_DIR="/run/user/$(id -u $SENDER_USER)" +export WAYLAND_DISPLAY="wayland-0" +ALERT_SCRIPT="sudo ./keyboard_alert.sh 2" + +status=$1 +if [[ $status -eq 0 ]]; then + dunstctl close-all + notify-send "No mommy put it back pwp" -u low + $ALERT_SCRIPT +else + dunstctl close-all + notify-send "Thank you for plugging me mommy ~" -u low + $ALERT_SCRIPT +fi diff --git a/scripts/colorscript.sh b/scripts/colorscript.sh new file mode 100755 index 0000000..0502ddd --- /dev/null +++ b/scripts/colorscript.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +while true; do + sudo ectool led battery red + sleep 0.2 + sudo ectool led battery green + sleep 0.2 + sudo ectool led battery blue + sleep 0.2 + sudo ectool led battery yellow + sleep 0.2 + sudo ectool led battery white + sleep 0.2 + sudo ectool led battery amber + sleep 0.2 +done diff --git a/scripts/get_power_usage.sh b/scripts/get_power_usage.sh new file mode 100755 index 0000000..fd11e4b --- /dev/null +++ b/scripts/get_power_usage.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +power=$(cat /sys/class/power_supply/BAT1/current_now /sys/class/power_supply/BAT1/voltage_now | xargs | awk '{ printf "%.1f\n", $1 * $2 / 1e12 }') + +echo $power diff --git a/scripts/idlescript b/scripts/idlescript new file mode 100755 index 0000000..cfaf2ec --- /dev/null +++ b/scripts/idlescript @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +swayidle -w -d \ + timeout 15 'bash -c "~/.config/nixos/scripts/keyboard_fade_brightness.sh 4 0 0.05"' \ + resume 'bash -c "brightnessctl -d framework_laptop::kbd_backlight set 4"' \ + timeout 170 'bash -c "brightnessctl g > /tmp/current_brightness && brightnessctl -e s 30%-"' \ + resume 'bash -c "if [ -f /tmp/current_brightness ]; then brightnessctl set $(cat /tmp/current_brightness); fi"' \ + timeout 180 '/home/mia/Scripts/lockscript' \ + timeout 200 'swaymsg "output * dpms off"' \ + resume 'swaymsg "output * dpms on"' \ + after-resume 'swaymsg "output * dpms on"' \ + before-sleep '/home/mia/Scripts/lockscript' diff --git a/scripts/keyboard_alert.sh b/scripts/keyboard_alert.sh new file mode 100755 index 0000000..d35f3c1 --- /dev/null +++ b/scripts/keyboard_alert.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +CURRENT_LIGHT=$(sudo ectool pwmgetkblight | cut -d' ' -f 5) + +echo $CURRENT_LIGHT >> /home/mia/Scripts/output.txt + +if [[ $CURRENT_LIGHT -eq "" ]] +then + CURRENT_LIGHT=0 +fi + +if [[ $CURRENT_LIGHT -eq 0 ]]; +then + FIRST_LIGHT_VALUE=100 + SECOND_LIGHT_VALUE=0 +else + FIRST_LIGHT_VALUE=$CURRENT_LIGHT + SECOND_LIGHT_VALUE=0 +fi + +count=0 +while [[ $count -lt $1 ]]; +do + sudo ectool pwmsetkblight $FIRST_LIGHT_VALUE + sleep 0.13 + sudo ectool pwmsetkblight $SECOND_LIGHT_VALUE + sleep 0.13 + ((count=count+1)) +done + +sudo ectool pwmsetkblight $CURRENT_LIGHT diff --git a/scripts/lockscript b/scripts/lockscript new file mode 100755 index 0000000..5a320b2 --- /dev/null +++ b/scripts/lockscript @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +path="/home/mia/Pictures/Screenshots/screen.png" +grim "$path" && +corrupter -add 0 -bheight 20 -stdabber 10 -boffset 50 "$path" "$path" && + +swaylock -c /home/mia/.config/swaylock/config && +swaymsg "output * dpms on" diff --git a/scripts/screenshot.sh b/scripts/screenshot.sh new file mode 100755 index 0000000..ed816fa --- /dev/null +++ b/scripts/screenshot.sh @@ -0,0 +1 @@ +flameshot gui -r | wl-copy diff --git a/scripts/toggle_freeze_process.sh b/scripts/toggle_freeze_process.sh new file mode 100755 index 0000000..4b7432b --- /dev/null +++ b/scripts/toggle_freeze_process.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# Get the PID of the focused window +PID=$(swaymsg -t get_tree | jq -r '.. | select(.focused? == true).pid') +FOCUSED_WIN_ID=$(swaymsg -t get_tree | jq -r '.. | select(.focused? == true).id') + +# Check if the process is frozen +STATE=$(ps -o state= -p $PID) + +if [[ "$STATE" == *T* ]]; then + # If the process is frozen, unfreeze it and reset border color + kill -CONT $PID + swaymsg [con_id=$FOCUSED_WIN_ID] border pixel 2 +else + # If the process is running, freeze it and change border color + kill -STOP $PID + swaymsg [con_id=$FOCUSED_WIN_ID] border pixel 10 +fi diff --git a/scripts/waybar-timer.sh b/scripts/waybar-timer.sh new file mode 100755 index 0000000..7309645 --- /dev/null +++ b/scripts/waybar-timer.sh @@ -0,0 +1,103 @@ +#!/usr/bin/env bash + +### AUTHOR: Johann Birnick (github: jbirnick) +### PROJECT REPO: https://github.com/jbirnick/waybar-timer + +## FUNCTIONS + +now () { date --utc +%s; } + +killTimer () { rm -rf /tmp/waybar-timer ; } +timerSet () { [ -e /tmp/waybar-timer/ ] ; } +timerPaused () { [ -f /tmp/waybar-timer/paused ] ; } + +timerExpiry () { cat /tmp/waybar-timer/expiry ; } +timerAction () { cat /tmp/waybar-timer/action ; } + +secondsLeftWhenPaused () { cat /tmp/waybar-timer/paused ; } +minutesLeftWhenPaused () { echo $(( ( $(secondsLeftWhenPaused) + 59 ) / 60 )) ; } +secondsLeft () { echo $(( $(timerExpiry) - $(now) )) ; } +minutesLeft () { echo $(( ( $(secondsLeft) + 59 ) / 60 )) ; } + +printExpiryTime () { notify-send -u low -r 12345 "Timer expires at $( date -d "$(secondsLeft) sec" +%H:%M)" ;} +printPaused () { notify-send -u low -r 12345 "Timer paused" ; } +removePrinting () { notify-send -C 12345 ; } + +updateTail () { + # check whether timer is expired + if timerSet + then + if { timerPaused && [ $(minutesLeftWhenPaused) -le 0 ] ; } || { ! timerPaused && [ $(minutesLeft) -le 0 ] ; } + then + eval $(timerAction) + killTimer + removePrinting + fi + fi + + # update output + if timerSet + then + if timerPaused + then + echo "{\"text\": \"$(minutesLeftWhenPaused)\", \"alt\": \"paused\", \"tooltip\": \"Timer paused\", \"class\": \"timer\" }" + else + echo "{\"text\": \"$(minutesLeft)\", \"alt\": \"running\", \"tooltip\": \"Timer expires at $( date -d "$(secondsLeft) sec" +%H:%M)\", \"class\": \"timer\" }" + fi + else + echo "{\"text\": \"0\", \"alt\": \"standby\", \"tooltip\": \"No timer set\", \"class\": \"timer\" }" + fi +} + +## MAIN CODE + +case $1 in + updateandprint) + updateTail + ;; + new) + killTimer + mkdir /tmp/waybar-timer + echo "$(( $(now) + 60*${2} ))" > /tmp/waybar-timer/expiry + echo "${3}" > /tmp/waybar-timer/action + printExpiryTime + ;; + increase) + if timerSet + then + if timerPaused + then + echo "$(( $(secondsLeftWhenPaused) + ${2} ))" > /tmp/waybar-timer/paused + else + echo "$(( $(timerExpiry) + ${2} ))" > /tmp/waybar-timer/expiry + printExpiryTime + fi + else + exit 1 + fi + ;; + cancel) + killTimer + removePrinting + ;; + togglepause) + if timerSet + then + if timerPaused + then + echo "$(( $(now) + $(secondsLeftWhenPaused) ))" > /tmp/waybar-timer/expiry + rm -f /tmp/waybar-timer/paused + printExpiryTime + else + secondsLeft > /tmp/waybar-timer/paused + rm -f /tmp/waybar-timer/expiry + printPaused + fi + else + exit 1 + fi + ;; + *) + echo "Please read the manual at https://github.com/jbirnick/waybar-timer ." + ;; +esac