run it all the time: home-manager module and a systemd unit that follows PATH
57 unmodified lines58596061626263646566676869707172737475767778798081828345 unmodified lines57 unmodified lines
then run `jpshow setup` once. it builds the tokenizer data and downloads thedictionaries (~90 MB) into `~/Library/Application Support/jpshow` or`$XDG_DATA_HOME/jpshow` (`JPSHOW_DATA` overrides), and then `jpshow` runs it.`contrib/` has a systemd user unit and a launchd agent to keep it running.
## running it all the time
with home-manager, import the flake's `homeManagerModules.default` and set`services.jpshow.enable = true;` (and `services.jpshow.extraArgs` for flags).that's a systemd user service on linux and a launchd agent on macos.
otherwise on linux copy `contrib/jpshow.service` into `~/.config/systemd/user`and `systemctl --user enable --now jpshow`. it runs the jpshow on your PATH, soafter an update `systemctl --user restart jpshow` is enough.
on macos copy `contrib/dev.dawn.jpshow.plist` into `~/Library/LaunchAgents`,point it at your jpshow (with nix that's `/Users/you/.nix-profile/bin/jpshow`)and `launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/dev.dawn.jpshow.plist`.jpshow then asks for accessibility and input monitoring for itself instead ofyour terminal, and again after every update, since macos ties them to theexact binary.
## usage
```jpshow [flags] watch the selection45 unmodified lines7 unmodified lines89101112131415161717 unmodified lines7 unmodified lines
outputs = inp: inp.parts.lib.mkFlake { inputs = inp; } { flake.homeManagerModules.default = ./contrib/home-manager.nix;
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin"17 unmodified lines12 unmodified lines131415161718192012 unmodified lines <key>KeepAlive</key> <true/> <key>ProcessType</key> <string>Interactive</string> <key>StandardErrorPath</key> <string>/tmp/jpshow.log</string></dict></plist>1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465# home-manager module: services.jpshow.enable = true runs jpshow as a# systemd user service with your graphical session on linux, or as a launchd# agent on macos. `jpshow setup` still has to run once.{ config, lib, pkgs, ...}:let cfg = config.services.jpshow; command = [ (lib.getExe cfg.package) ] ++ cfg.extraArgs;in{ options.services.jpshow = { enable = lib.mkEnableOption "jpshow, furigana and dictionary cards for selected japanese"; package = lib.mkOption { type = lib.types.package; default = import ../default.nix { inherit pkgs; }; defaultText = lib.literalExpression "jpshow from this repository"; description = "the jpshow package to run"; }; extraArgs = lib.mkOption { type = lib.types.listOf lib.types.str; default = [ ]; example = [ "-offline" "-romaji" "wapuro" ]; description = "flags passed to jpshow"; }; };
config = lib.mkIf cfg.enable ( lib.mkMerge [ { home.packages = [ cfg.package ]; } (lib.mkIf pkgs.stdenv.hostPlatform.isLinux { systemd.user.services.jpshow = { Unit = { Description = "jpshow: furigana and dictionary cards for selected japanese"; PartOf = [ "graphical-session.target" ]; After = [ "graphical-session.target" ]; }; Service = { ExecStart = lib.escapeShellArgs command; Restart = "on-failure"; }; Install.WantedBy = [ "graphical-session.target" ]; }; }) (lib.mkIf pkgs.stdenv.hostPlatform.isDarwin { launchd.agents.jpshow = { enable = true; config = { ProgramArguments = command; RunAtLoad = true; KeepAlive = true; ProcessType = "Interactive"; }; }; }) ] );}123245678971011121314# a systemd user unit: copy it into ~/.config/systemd/user, then# systemctl --user enable --now jpshow[Unit]Description=jpshow: furigana and dictionary popups for selected Japanese textDescription=jpshow: furigana and dictionary cards for selected japanesePartOf=graphical-session.targetAfter=graphical-session.target
[Service]# jpshow from the user's PATH, so updates only need a restartExecStart=%h/.local/bin/jpshowExecStart=/usr/bin/env jpshowRestart=on-failure
[Install]WantedBy=graphical-session.target