+ work-timer

This commit is contained in:
m3tam3re 2025-04-21 15:00:21 +02:00
parent b6e8a1614b
commit d69a9b9b38
5 changed files with 99 additions and 1 deletions

View File

@ -76,6 +76,7 @@
rocmPackages.rocminfo rocmPackages.rocminfo
rocmPackages.rocm-runtime rocmPackages.rocm-runtime
tldr tldr
pomodoro-timer
trash-cli trash-cli
unimatrix unimatrix
unzip unzip

View File

@ -119,6 +119,10 @@
"float, title:^(Media viewer)$" "float, title:^(Media viewer)$"
"float, title:^(Volume Control)$" "float, title:^(Volume Control)$"
"float, title:^(Picture-in-Picture)$" "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"; "$mainMod" = "SUPER";
@ -127,6 +131,7 @@
"$mainMod, return, exec, kitty -e zellij-ps" "$mainMod, return, exec, kitty -e zellij-ps"
# "$mainMod, t, exec, warp-terminal" # "$mainMod, t, exec, warp-terminal"
"$mainMod, t, exec, kitty -e fish -c 'fastfetch; exec fish'" "$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 SHIFT, e, exec, kitty -e zellij_nvim"
"$mainMod, o, exec, hyprctl setprop activewindow opaque toggle" "$mainMod, o, exec, hyprctl setprop activewindow opaque toggle"
"$mainMod, b, exec, thunar" "$mainMod, b, exec, thunar"

View File

@ -1,6 +1,5 @@
{pkgs, ...}: { {pkgs, ...}: {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
speechd
]; ];
security.rtkit.enable = true; security.rtkit.enable = true;
services.pipewire = { services.pipewire = {

View File

@ -4,4 +4,5 @@
zellij-ps = pkgs.callPackage ./zellij-ps {}; zellij-ps = pkgs.callPackage ./zellij-ps {};
aider-chat-env = pkgs.callPackage ./aider-chat-env {}; aider-chat-env = pkgs.callPackage ./aider-chat-env {};
code2prompt = pkgs.callPackage ./code2prompt {}; code2prompt = pkgs.callPackage ./code2prompt {};
pomodoro-timer = pkgs.callPackage ./pomodoro-timer {};
} }

View File

@ -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 = [];
};
}