{ pkgs, lib, config, ... }: { systemd.user = { services.arbtt-capture = { Service = { Environment = [ "PATH=${lib.makeBinPath [ pkgs.coreutils ]}" ]; ExecStart = pkgs.writeShellScript "arbtt-capture-start" '' set -eu LOG=${config.xdg.dataHome}/arbtt/$(date +%Y).capture ln -snf "$LOG" "${config.xdg.dataHome}/arbtt/capture.log" exec ${pkgs.haskellPackages.arbtt}/bin/arbtt-capture --logfile="$LOG" ''; Restart = "always"; }; Unit = { Description = "Arbtt capture service"; PartOf = [ "graphical-session.target" ]; After = [ "graphical-session-pre.target" ]; }; Install = { WantedBy = [ "graphical-session.target" ]; }; }; }; home.activation.linkDotfiles = lib.hm.dag.entryAfter [ "writeBoundary" ] '' ln -sfn ${config.xdg.dataHome}/arbtt $HOME/.arbtt ''; xdg.dataFile."arbtt/categorize.cfg".text = lib.mkDefault '' -- Simple rule that just tags the current program $idle > 30 ==> tag inactive, tag Program:$current.program, ''; home.packages = [ pkgs.haskellPackages.arbtt (pkgs.writeShellScriptBin "arbtt-stats-for" '' set -eu period=''${1-} shift case "$period" in today) today=$(date +"%Y-%m-%d") echo "$today" arbtt-stats -m 0.1 --filter='$date>='$today "$@" ;; week) today=$(date +"%Y-%m-%d") today=$(date -dlast-monday +%Y-%m-%d) echo "$today to Now" arbtt-stats -m 0.1 --filter='$date>='$today "$@" ;; month) today=$(date +"%Y-%m-01") echo "$today to Now" arbtt-stats -m 0.01 --filter='$date>='$today "$@" ;; prevmonth) startday=$(date --date="$(date +%Y-%m-15) -1 month" +'%Y-%m-01') endday=$(date --date="$(date +%Y-%m-01) -1 day" +'%Y-%m-%d') echo "$startday to $endday" arbtt-stats -m 0.01 --filter='$date>='$startday' && $date<='$(date +%Y-%m-01) "$@" ;; prevday) startday=$(date --date="$(date +%Y-%m-%d) -1 day" +'%Y-%m-%d') endday=$(date +%Y-%m-%d) echo "$startday" arbtt-stats -m 0.1 --filter='$date>='$startday' && $date<='$endday "$@" ;; -d) startday=$2 endday=$(date --date="$2 +1 day" +'%Y-%m-%d') echo "$startday" arbtt-stats -m 0.1 --filter='$date>='$startday' && $date<='$endday "$@" ;; *) echo "Usage: arbtt [OPTIONS...]" echo " today" echo " week" echo " month" echo " prevmonth" echo " prevday" echo " -d [%Y-%m-%d]" esac '') ]; }