updated home/desktop

This commit is contained in:
serenity-F 2024-11-19 15:52:34 +10:00
parent d02f6b152d
commit b4450deecf
No known key found for this signature in database
6 changed files with 2 additions and 2 deletions

View file

@ -0,0 +1,9 @@
{ pkgs, config, ... }:
{
imports = [
./startup.nix
./desktop.nix
./nix-utils.nix
];
}

View file

@ -0,0 +1,92 @@
{ pkgs, config, ... }:
let
homedir = config.home.homeDirectory;
increments = "5";
menu = pkgs.writeShellScriptBin "menu" ''
if pgrep wofi; then
pkill wofi
else
${pkgs.wofi}/bin/wofi --show drun
fi
'';
powermenu = pkgs.writeShellScriptBin "powermenu" ''
if pgrep wlogout; then
pkill wlogout
else
${pkgs.wlogout}/bin/wlogout
fi
'';
brightness-up = pkgs.writeShellScriptBin "brightness-up" ''
brightness-change up ${increments}
'';
brightness-down = pkgs.writeShellScriptBin "brightness-down" ''
brightness-change down ${increments}
'';
brightness-change = pkgs.writeShellScriptBin "brightness-change" ''
sleep 0.05
[[ $1 == "up" ]] && ${pkgs.brightnessctl}/bin/brightnessctl set ${increments}%+
[[ $1 == "down" ]] && ${pkgs.brightnessctl}/bin/brightnessctl set ${increments}%-
brightness_level=$(${pkgs.brightnessctl}/bin/brightnessctl get)
message="󰃠 Brightness: $brightness_level%"
${pkgs.libnotify}/bin/notify-send "$message" \
-h int:value:"$brightness_level" \
--replace-id="$(cat "/tmp/nixy-notification" 2>/dev/null || echo 0)" --print-id > "/tmp/nixy-notification"
'';
screenshot = pkgs.writeShellScriptBin "screenshot" ''
if [[ $2 == "swappy" ]];then
folder="/tmp"
else
folder="$HOME/Pictures/screenshots"
fi
filename="$(date +%Y-%m-%d_%H:%M:%S).png"
mode="region" # Default to region
if [[ $1 == "window" ]];then
mode="window"
elif [[ $1 == "monitor" ]];then
mode="output"
fi
${pkgs.hyprshot}/bin/hyprshot -m $mode -o $folder -f $filename -s || exit 1
if [[ $2 == "swappy" ]];then
${pkgs.swappy}/bin/swappy -f "$folder/$filename" -o "$HOME/Pictures/screenshots/$filename"
exit 0
fi
message=" Screenshot saved"
${pkgs.libnotify}/bin/notify-send "$message" \
--icon="$folder/$filename" \
--replace-id="$(cat "/tmp/nixy-notification" 2>/dev/null || echo 0)" --print-id > "/tmp/nixy-notification"
'';
vault = pkgs.writeShellScriptBin "vault" ''
nvim $HOME/Nextcloud/obsidian
'';
in {
home.packages = with pkgs; [
menu
powermenu
brightness-up
brightness-down
brightness-change
screenshot
hyprshot
vault
];
}

View file

@ -0,0 +1,55 @@
{ pkgs, config, ... }:
let
homedir = config.home.homeDirectory;
#hostname = config.system.nixos.distroId;
nixsyu = pkgs.writeShellScriptBin "nixsyu" ''
cd {$homedir}/flakes/nixdots && sudo nix flake update && sudo nixos-rebuild switch --upgrade-all --flake {$homedir}/flakes/nixdots#{$hostname} --show-trace && sudo nix-collect-garbage -d && sudo nix-store --optimise
'';
nixrb = pkgs.writeShellScriptBin "nixrb" ''
sudo nixos-rebuild switch --flake {$homedir}/flakes/nixdots#{$hostname}
'';
nixrbt = pkgs.writeShellScriptBin "nixrbt" ''
sudo nixos-rebuild switch --flake {$homedir}/flakes/nixdots#{$hostname} --show-trace
'';
nixupg = pkgs.writeShellScriptBin "nixupg" ''
sudo nixos-rebuild switch --upgrade-all --flake {$homedir}/flakes/nixdots#{$hostname} --show-trace
'';
nixcb = pkgs.writeShellScriptBin "nixcb" ''
sudo /run/current-system/bin/switch-to-configuration boot
'';
nixgc = pkgs.writeShellScriptBin "nixgc" ''
cd {$homedir}/flakes/nixdots/nixos && sudo nix-collect-garbage -d
'';
nixu = pkgs.writeShellScriptBin "nixu" ''
cd {$homedir}/flakes/nixdots && sudo nix flake update
'';
nixe = pkgs.writeShellScriptBin "nixe" ''
$EDITOR {$homedir}/flakes/nixdots
'';
in {
home.packages = with pkgs; [
nixsyu
nixrbt
nixrb
nixupg
nixu
nixe
nixgc
nixcb
];
}

View file

@ -0,0 +1,38 @@
# File runned at startup by Hyprland
{ pkgs, config, ... }:
let
homedir = config.home.homeDirectory;
battery-notif = pkgs.writeShellScriptBin "battery-notif" ''
# Send notifications when low on battery and not in charge
while true; do
battery_level=$(cat /sys/class/power_supply/BAT*/capacity)
battery_status=$(cat /sys/class/power_supply/BAT*/status)
if [[ $battery_level -le 20 ]] && [[ $battery_status == "Discharging" ]]; then
${pkgs.libnotify}/bin/notify-send "󰁻 Low battery" "Battery level is $battery_level%"
elif [[ $battery_level -le 10 ]] && [[ $battery_status == "Discharging" ]]; then
${pkgs.libnotify}/bin/notify-send --urgency=critical "󰁺 Very low battery" "Battery level is $battery_level%"
fi
sleep 60
done
'';
startup = pkgs.writeShellScriptBin "startup" ''
# Because HM enabling services suck.
systemctl --user start sops-nix
systemctl --user start hyprpolkitagent
swww-daemon & sleep 0.1
swww img ~/flakes/nixdots/home/desktop/resources/wallpapers/sphericaEssentia-uncredited.png
'';
in {
home.packages = with pkgs; [
startup
#battery-notif
];
}