diff --git a/pkgs/default.nix b/pkgs/default.nix index 677507c..d81563a 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -22,6 +22,7 @@ in myintercom-doorbell = callPackage ./myintercom-doorbell { inherit poetry2nix; }; + pomodoro-timer = callPackage ./pomodoro-timer { }; pretix-banktool = callPackage ./pretix-banktool { }; tabbed-box-maker = callPackage ./tabbed-box-maker { }; vesc-firmware = callPackage ./vesc-tool/firmware.nix { }; diff --git a/pkgs/pomodoro-timer/default.nix b/pkgs/pomodoro-timer/default.nix new file mode 100644 index 0000000..839ac12 --- /dev/null +++ b/pkgs/pomodoro-timer/default.nix @@ -0,0 +1,52 @@ +{ lib +, stdenv +, yad +, uair +, gnused +, writeShellScript +, makeDesktopItem +}: + +let + pomodoroTimer = writeShellScript "pomodoro-timer" '' + export PATH=${lib.makeBinPath [yad uair gnused]} + uairctl listen -o yad \ + | yad \ + --title="Pomodoro" \ + --geometry="300x50" \ + --scale \ + --progress \ + --no-buttons \ + --css="* { font-size: 60px;} progress { min-height: 1200px; margin: -100px -8px -6px;}" + ''; +in +stdenv.mkDerivation rec { + pname = "pomodoro-timer"; + version = "1.0.0"; + src = ./pomodorotimer.svg; + dontUnpack = true; + + installPhase = '' + dir=$out/share/icons/hicolor/scalable/apps/ + mkdir -p $dir + cp $src $dir/pomodorotimer.svg + mkdir $out/bin + cp "${pomodoroTimer}" $out/bin/pomodoro-timer + ln -s "${desktopItem}/share/applications" $out/share/ + ''; + + desktopItem = makeDesktopItem { + name = pname; + exec = pname; + icon = "pomodorotimer"; + desktopName = pname; + comment = meta.description; + categories = [ "Utility" ]; + }; + + meta = with lib; { + description = "Pomodoro timer (GUI for uair)"; + maintainers = with maintainers; [ jalr ]; + platforms = platforms.linux; + }; +} diff --git a/pkgs/pomodoro-timer/pomodorotimer.svg b/pkgs/pomodoro-timer/pomodorotimer.svg new file mode 100644 index 0000000..b771a33 --- /dev/null +++ b/pkgs/pomodoro-timer/pomodorotimer.svg @@ -0,0 +1,274 @@ + + + + + + + + + + + + + + + + + + + + + + + + Pomodoro Timer + + + + + + + image/svg+xml + + + + + Openclipart + + + Pomodoro Timer + 2011-05-03T21:58:11 + The Pomodoro Technique® is a way to get the most out of time management. Develop by Francesco Cirillo. + https://openclipart.org/detail/135631/pomodoro-timer-by-fairhonanth + + + fairhonanth + + + + + management + pomodoro + productivity + techinique + timer + + + + + + + + + + + diff --git a/users/jalr/modules/default.nix b/users/jalr/modules/default.nix index f7734d5..b72ee3d 100644 --- a/users/jalr/modules/default.nix +++ b/users/jalr/modules/default.nix @@ -28,6 +28,7 @@ ./openscad.nix ./ots.nix ./pass.nix + ./pomodoro.nix ./python.nix ./remarkable ./snapclient.nix diff --git a/users/jalr/modules/pomodoro.nix b/users/jalr/modules/pomodoro.nix new file mode 100644 index 0000000..42b1bc3 --- /dev/null +++ b/users/jalr/modules/pomodoro.nix @@ -0,0 +1,69 @@ +{ nixosConfig, lib, pkgs, config, ... }: + +let + tomlFormat = pkgs.formats.toml { }; +in +lib.mkIf nixosConfig.jalr.gui.enable { + home.packages = with pkgs; [ + uair + pomodoro-timer + ]; + + xdg.configFile."uair/uair.toml".source = tomlFormat.generate "uair.toml" { + defaults = { + loop_on_end = true; + paused_state_text = "paused"; + resumed_state_text = "resumed"; + overrides = { + yad = { + format = "{percent}\n#{time}\n"; + }; + json = { + format = ''{"name": "{name}", "percent": {percent}", "time": "{time}", "running": {state}, "total": "{total}"} + ''; + paused_state_text = "false"; + resumed_state_text = "true"; + }; + waybar = { + format = ''{"text": "{name}: {time}", "class": "{state}"} + ''; + paused_state_text = "paused"; + resumed_state_text = "resumed"; + }; + }; + }; + sessions = + let + work-finished = "notify-send 'Pomodoro done! Enjoy your break.'; dnd off"; + break-finished = "notify-send 'Get back to work!'; dnd on"; + in + [ + { name = "Work 1"; duration = "25m"; command = work-finished; } + { name = "Break 1"; duration = "5m"; command = break-finished; } + { name = "Work 2"; duration = "25m"; command = work-finished; } + { name = "Break 2"; duration = "5m"; command = break-finished; } + { name = "Work 3"; duration = "25m"; command = work-finished; } + { name = "Break 3"; duration = "5m"; command = break-finished; } + { name = "Work 4"; duration = "25m"; command = work-finished; } + { name = "Long Break"; duration = "20m"; command = break-finished; } + ]; + }; + + systemd.user.services.uair = { + Unit.Description = "Pomodoro timer"; + Service = { + ExecStart = "${pkgs.uair}/bin/uair"; + NoNewPrivileges = true; + ProtectControlGroups = true; + ProtectKernelModules = true; + ProtectKernelTunables = true; + RestrictAddressFamilies = "AF_INET AF_INET6 AF_UNIX"; + RestrictNamespaces = true; + Type = "simple"; + Environment = [ + "PATH=/etc/profiles/per-user/jalr/bin:/run/current-system/sw/bin/" + ]; + }; + Install.WantedBy = [ "default.target" ]; + }; +} diff --git a/users/jalr/modules/sway/default.nix b/users/jalr/modules/sway/default.nix index bb16c26..2f3a27a 100644 --- a/users/jalr/modules/sway/default.nix +++ b/users/jalr/modules/sway/default.nix @@ -293,6 +293,13 @@ in }; command = "floating enable"; } + { + criteria = { + app_id = "yad"; + title = "Pomodoro"; + }; + command = "floating enable"; + } ]; window.border = 2; diff --git a/users/jalr/modules/sway/waybar.nix b/users/jalr/modules/sway/waybar.nix index e3ca9d8..377f4d2 100644 --- a/users/jalr/modules/sway/waybar.nix +++ b/users/jalr/modules/sway/waybar.nix @@ -41,6 +41,7 @@ in "custom/screencast" "custom/redshift" "idle_inhibitor" + "custom/pomodoro" "backlight" "pulseaudio" "network" @@ -71,6 +72,32 @@ in format = "󰌵"; tooltip = false; }; + "custom/pomodoro" = let uairctl = "${pkgs.uair}/bin/uairctl"; in { + # We need to remove nul-characters + # See https://github.com/metent/uair/issues/15 + exec = pkgs.writeShellScript "uairctl-without-null-characters" '' + ${uairctl} listen -o waybar | ${pkgs.gnused}/bin/sed --unbuffered 's/\x0//g' + ''; + + on-click = "${uairctl} toggle"; + on-scroll-up = "${uairctl} next"; + on-scroll-down = "${uairctl} prev"; + on-click-middle = "${uairctl} finish"; + menu = "on-click-right"; + /* + menu-actions = { + "work 1" = "${uairctl} jump 0"; + "break 1" = "${uairctl} jump 1"; + "work 2" = "${uairctl} jump 2"; + "break 2" = "${uairctl} jump 3"; + "work 3" = "${uairctl} jump 4"; + "break 3" = "${uairctl} jump 5"; + "work 4" = "${uairctl} jump 6"; + "long break" = "${uairctl} jump 7"; + }; + */ + return-type = "json"; + }; idle_inhibitor = { format = "{icon}"; format-icons = { @@ -362,6 +389,11 @@ in animation-iteration-count: infinite; animation-direction: alternate; } + + #custom-pomodoro.resumed { + color: @base01; + background-color: @base0B; + } ''; systemd.user.services.waybar = {