Add ActivityWatch

This commit is contained in:
Tristan D. 2024-07-02 15:10:26 +02:00
parent 78dc834962
commit ec23782180
Signed by: tristan
SSH key fingerprint: SHA256:9oFM1J63hYWJjCnLG6C0fxBS15rwNcWwdQNMOHYKJ/4
7 changed files with 4779 additions and 17 deletions

View file

@ -125,6 +125,12 @@
;; ) ;; )
;; (setq! tramp-default-method "ssh") ;; (setq! tramp-default-method "ssh")
;; awatch
(use-package! activity-watch-mode
:config
(global-activity-watch-mode))
;; rust ;; rust
(setq! lsp-inlay-hint-enable t) (setq! lsp-inlay-hint-enable t)
(setq! lsp-rust-analyzer-cargo-run-build-scripts t) (setq! lsp-rust-analyzer-cargo-run-build-scripts t)
@ -297,26 +303,35 @@
(string-trim (buffer-substring-no-properties (point-min) (point-max))))) (string-trim (buffer-substring-no-properties (point-min) (point-max)))))
(setq! gptel-backend (gptel-make-openai "groq" (setq! gptel-backend
:host "api.groq.com" (gptel-make-openai "llama-cpp"
:endpoint "/openai/v1/chat/completions" :stream t
:stream t :protocol "http"
:key (read-api-secret ".groq_api_key") :host "100.64.0.3:8080"
:models '("llama3-70b-8192" :models '("llama-cpp-model")))
"mixtral-8x7b-32768" (setq! gptel-model "llama-cpp-model")
"llama3-8b-8192"))
gptel-model "llama3-70b-8192"
)
(gptel-make-openai "llama-cpp"
:stream t
:protocol "http"
:host "100.64.0.3:8080"
:models '("llama-cpp-model"))
(setq! gptel-directives '(('default
. "You are a large language model living in Emacs and a helpful assistant. Respond concisely.")
('programming
. "You are a large language model and a careful programmer. Provide code and only code as output without any additional text, prompt or note.")
('writing
. "You are a large language model and a writing assistant. Respond concisely.")
('chat
. "You are a large language model and a conversation partner. Respond concisely.")))
(setq! gptel-expert-commands t) (setq! gptel-expert-commands t)
(setq! gptel-temperature 0.2) (setq! gptel-temperature 0.2)
(gptel-make-openai "groq"
:host "api.groq.com"
:endpoint "/openai/v1/chat/completions"
:stream t
:key (read-api-secret ".groq_api_key")
:models '("llama3-70b-8192"
"mixtral-8x7b-32768"
"llama3-8b-8192"))
(add-hook 'gptel-post-response-functions 'gptel-end-of-response) (add-hook 'gptel-post-response-functions 'gptel-end-of-response)
(add-hook 'gptel-post-stream-hook 'gptel-auto-scroll) (add-hook 'gptel-post-stream-hook 'gptel-auto-scroll)

View file

@ -51,13 +51,14 @@
;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;
;; gptel ;; gptel
(package! gptel :recipe (:type git :host nil :repo "https://git.vlt81.de/tristan/gptel.git" :branch "master")) (package! gptel :recipe (:type git :host nil :repo "https://github.com/karthink/gptel.git" :branch "master"))
;; gptel-extensions ;; gptel-extensions
(package! gptel-extensions :recipe (:host github :repo "kamushadenes/gptel-extensions.el")) (package! gptel-extensions :recipe (:host github :repo "kamushadenes/gptel-extensions.el"))
;; gptcommit ;; gptcommit
(package! magit-gptcommit :recipe (:host github :repo "douo/magit-gptcommit")) (package! magit-gptcommit :recipe (:host github :repo "douo/magit-gptcommit"))
;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;
(package! activity-watch-mode)
;; Doom's packages are pinned to a specific commit and updated from release to ;; Doom's packages are pinned to a specific commit and updated from release to
;; release. The `unpin!' macro allows you to unpin single packages... ;; release. The `unpin!' macro allows you to unpin single packages...
;;(unpin! pinned-package) ;;(unpin! pinned-package)

View file

@ -127,6 +127,7 @@
}; };
packages."${system}" = { packages."${system}" = {
spotube = pkgs.callPackage ./pkgs/spotube.nix { }; spotube = pkgs.callPackage ./pkgs/spotube.nix { };
awatcher = pkgs.callPackage ./pkgs/awatcher.nix { };
}; };
diskoConfigurations = { diskoConfigurations = {
nixos-desk = import ./systems/nixos-desk/disko.nix; nixos-desk = import ./systems/nixos-desk/disko.nix;

View file

@ -0,0 +1,28 @@
{ config
, pkgs
, inputs
, ...
}: {
home.packages = with pkgs; [
# aw-watcher-afk
# aw-watcher-window-wayland # does not support kwin wayland
# aw-webui
# python312Packages.aw-core
aw-server-rust
my.awatcher
];
programs.firefox.profiles.default.extensions = with config.nur.repos.rycee.firefox-addons; [
aw-watcher-web
];
services.activitywatch = {
enable = true;
package = pkgs.aw-server-rust;
watchers = {
awatcher.package = pkgs.my.awatcher;
};
};
# TODO Add timer for `aw-sync --sync-dir=$HOME/Nextcloud/ActivityWatch/ sync --mode both`
# (aw-sync binary is part of aw-server-rust)
}

4662
pkgs/awatcher.Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

54
pkgs/awatcher.nix Normal file
View file

@ -0,0 +1,54 @@
# --- parts/pkgs/awatcher.nix
#
# Author: tsandrini <tomas.sandrini@seznam.cz>
# URL: https://github.com/tsandrini/tensorfiles
# License: MIT
#
# 888 .d888 d8b 888
# 888 d88P" Y8P 888
# 888 888 888
# 888888 .d88b. 88888b. .d8888b .d88b. 888d888 888888 888 888 .d88b. .d8888b
# 888 d8P Y8b 888 "88b 88K d88""88b 888P" 888 888 888 d8P Y8b 88K
# 888 88888888 888 888 "Y8888b. 888 888 888 888 888 888 88888888 "Y8888b.
# Y88b. Y8b. 888 888 X88 Y88..88P 888 888 888 888 Y8b. X88
# "Y888 "Y8888 888 888 88888P' "Y88P" 888 888 888 888 "Y8888 88888P'
{ lib
, rustPlatform
, fetchFromGitHub
, pkg-config
, openssl
, ...
}:
rustPlatform.buildRustPackage rec {
pname = "awatcher";
version = "0.2.7";
src = fetchFromGitHub {
owner = "2e3s";
repo = pname;
rev = "v${version}";
hash = "sha256-e65QDbK55q1Pbv/i7bDYRY78jgEUD1q6TLdKD8Gkswk=";
};
nativeBuildInputs = [ pkg-config ];
buildInputs = [ openssl ];
# NOTE needed due to Cargo.lock containing git dependencies
cargoLock = {
lockFile = ./awatcher.Cargo.lock;
outputHashes = {
"aw-client-rust-0.1.0" = "sha256-fCjVfmjrwMSa8MFgnC8n5jPzdaqSmNNdMRaYHNbs8Bo=";
};
};
meta = with lib; {
description = "Awatcher is a window activity and idle watcher for ActivityWatcher with an optional tray and UI for statistics.";
homepage = "https://github.com/2e3s/awatcher";
changelog = "https://github.com/2e3s/awatcher/releases/tag/${version}";
license = licenses.mpl20;
maintainers = with tensorfiles.maintainers; [ tsandrini ];
platforms = platforms.linux;
mainProgram = pname;
};
}

View file

@ -6,6 +6,7 @@
, ... , ...
}: { }: {
imports = [ imports = [
../home-mods/activity-watch
../home-mods/ai ../home-mods/ai
../home-mods/audio ../home-mods/audio
../home-mods/common ../home-mods/common