helix-discord-rpc
A fork of presence.hx with customisation and multi-instance support
- Stars: 6
- Last commit:
- Created:
A fork of presence.hx with customisation and multi-instance support
Discord RPC support for Helix via Steel.
forge pkg install --git https://github.com/norinorin/helix-discord-rpc.git
require it in your init.scm:(require "helix-discord-rpc/init.scm")
Minimal setup:
# home.nix
{inputs, pkgs, ...}: let
helix-discord-rpc = inputs.helix-discord-rpc.packages.${pkgs.stdenv.hostPlatform.system}.default;
in {
programs.helix = {
enable = true;
package = pkgs.steelix; # unstable
};
xdg.configFile."helix/plugins/helix-discord-rpc".source =
"${helix-discord-rpc}/share/helix-discord-rpc";
xdg.configFile."helix/init.scm".text = ''
(require "plugins/helix-discord-rpc/init.scm")
'';
home.file = {
".steel/native/libhelix_discord_rpc.so".source =
"${helix-discord-rpc}/lib/libhelix_discord_rpc.so";
};
}
; init.scm
(require "helix-discord-rpc/init.scm")
(discord-rpc-connect)
; init.scm
(require-builtin steel/strings)
(require "helix-discord-rpc/init.scm")
(require "helix-discord-rpc/utils.scm")
(discord-rpc-register-details-fn
(lambda ()
"In a workspace"))
; naive impl
(define (a-or-an word)
(let ([w (string-downcase word)])
(if (or (starts-with? w "a")
(starts-with? w "e")
(starts-with? w "i")
(starts-with? w "o")
(starts-with? w "u"))
"an"
"a")))
(discord-rpc-register-state-fn
(lambda ()
(let ([lang (discord-rpc-current-language)])
(if (string=? lang "")
"Editing a file"
(string-append
"Editing "
(a-or-an lang)
" "
lang
" file")))))
(discord-rpc-connect)
; init.scm
(require "helix-discord-rpc/init.scm")
(require "helix-discord-rpc/utils.scm")
; Each `discord-rpc-register-should-display-fn` call overrides
; the previous one, so only use this function once!
; To apply multiple rules, compose them in a single lambda.
; 1. Exact-match blacklist
(define ignored-workspaces '("secret-project" "confidential"))
(discord-rpc-register-should-display-fn
(lambda ()
(let ([folder (discord-rpc-basename (discord-rpc-current-workspace-path))])
(not (member folder ignored-workspaces)))))
; 2. Substring-match blacklist
(discord-rpc-register-should-display-fn
(lambda ()
(let ([path (discord-rpc-current-workspace-path)])
(not (string-contains? path "/private/")))))
; 3. Language whitelist
(discord-rpc-register-should-display-fn
(lambda ()
(let ([lang (discord-rpc-current-language)])
(or (string=? lang "rust")
(string=? lang "scheme")))))
(discord-rpc-connect)
vscord project, licensed under the MIT license.