diff --git a/home/features/cli/default.nix b/home/features/cli/default.nix index 3272b09..e984d96 100644 --- a/home/features/cli/default.nix +++ b/home/features/cli/default.nix @@ -76,6 +76,7 @@ rocmPackages.rocminfo rocmPackages.rocm-runtime tldr + pomodoro-timer trash-cli unimatrix unzip diff --git a/home/features/desktop/hyprland.nix b/home/features/desktop/hyprland.nix index cdd568f..1e94a60 100644 --- a/home/features/desktop/hyprland.nix +++ b/home/features/desktop/hyprland.nix @@ -119,6 +119,10 @@ "float, title:^(Media viewer)$" "float, title:^(Volume Control)$" "float, title:^(Picture-in-Picture)$" + "float,title:^(floating-pomodoro)$" + "size 250 50, title:^(floating-pomodoro)$" + "move 12 100%-150,title:^(floating-pomodoro)$" + "pin,title:^(floating-pomodoro)$" ]; "$mainMod" = "SUPER"; @@ -127,6 +131,7 @@ "$mainMod, return, exec, kitty -e zellij-ps" # "$mainMod, t, exec, warp-terminal" "$mainMod, t, exec, kitty -e fish -c 'fastfetch; exec fish'" + "$mainMod SHIFT, t, exec, launch-timer" "$mainMod SHIFT, e, exec, kitty -e zellij_nvim" "$mainMod, o, exec, hyprctl setprop activewindow opaque toggle" "$mainMod, b, exec, thunar" diff --git a/hosts/m3-ares/services/sound.nix b/hosts/m3-ares/services/sound.nix index 44e0d96..2e8841e 100644 --- a/hosts/m3-ares/services/sound.nix +++ b/hosts/m3-ares/services/sound.nix @@ -1,6 +1,5 @@ {pkgs, ...}: { environment.systemPackages = with pkgs; [ - speechd ]; security.rtkit.enable = true; services.pipewire = { diff --git a/pkgs/default.nix b/pkgs/default.nix index b25f3d7..e795ec3 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -4,4 +4,5 @@ zellij-ps = pkgs.callPackage ./zellij-ps {}; aider-chat-env = pkgs.callPackage ./aider-chat-env {}; code2prompt = pkgs.callPackage ./code2prompt {}; + pomodoro-timer = pkgs.callPackage ./pomodoro-timer {}; } diff --git a/pkgs/pomodoro-timer/default.nix b/pkgs/pomodoro-timer/default.nix new file mode 100644 index 0000000..131e9e4 --- /dev/null +++ b/pkgs/pomodoro-timer/default.nix @@ -0,0 +1,92 @@ +{ + lib, + stdenv, + writeShellScriptBin, + timer, + kitty, + rofi, + libnotify, + speechd, +}: let + launcher = writeShellScriptBin "launch-timer" '' + #!/bin/bash + + validate_time() { + local input=$1 + if [[ $input =~ ^[0-9]+[mhs]$ ]]; then + return 0 + else + return 1 + fi + } + + notify_end() { + local session_name=$1 + ${libnotify}/bin/notify-send "Pomodoro" "$session_name session ended!" + ${speechd}/bin/spd-say "$session_name session ended" + } + + start_timer() { + local duration=$1 + local session_name=$2 + kitty \ + --class="floating-pomodoro" \ + --title="floating-pomodoro" \ + ${timer}/bin/timer $duration + notify_end "$session_name" + } + + # Show rofi menu with options + selected=$(printf "work\nbreak\ncustom" | rofi -dmenu -p "Work Timer:" -l 3) + + # Exit if no selection was made + [ -z "$selected" ] && exit + + case $selected in + "work") + start_timer "45m" "work" + ;; + "break") + start_timer "10m" "break" + ;; + "custom") + # Show input dialog for custom time + custom_time=$(rofi -dmenu -p "Enter time (e.g., 25m, 1h, 30s):" -l 0) + + # Validate input and start timer + if [ ! -z "$custom_time" ] && validate_time "$custom_time"; then + start_timer "$custom_time" "custom" + else + ${libnotify}/bin/notify-send "Invalid time format" "Please use format: 30s, 25m, or 1h" + exit 1 + fi + ;; + esac + ''; +in + stdenv.mkDerivation { + pname = "work-timer"; + version = "0.1.0"; + + dontUnpack = true; + + buildInputs = [ + timer + kitty + rofi + libnotify + speechd + ]; + + installPhase = '' + mkdir -p $out/bin + ln -s ${launcher}/bin/launch-timer $out/bin/launch-timer + ''; + + meta = with lib; { + description = "A Work timer."; + license = licenses.mit; + platforms = platforms.linux; + maintainers = []; + }; + }