Package for Emacs to create and control tray icons.
This package contains tiny daemon, written in C, which creates and controls tray icon via appindicator library, and lisp code to interact with it. Daemon can hide/show/change icon, set label (as far as I know, some desktop environments doesn’t support this feature), and set up context menus with lisp callbacks. For now, only Linux bases operation systems supported. Please visit issue if you are interested in support for other systems.
This repository contains library only, check jumper047/emacs-appindicator-modes for various useful minor modes!
To build daemon these packages should be installed:
make
libappindicator3-dev
orlibayatana-appindicator3-dev
(for Ubuntu/Debian, name in your distribution may vary)
Clone this repository somewhere into your load-path
and add to your config
(require 'appindicator)
With use-package
you can do something like:
(use-package appindicator
:load-path "~/paht/to/appindicator/sources")
Or install it with quelpa
:
(quelpa '(appindicator :repo "jumper047/emacs-appindicator" :fetcher github :files ("*.el" "appindicator-helper")))
The entry point is appindicator-create
macro - creates functions to control new appindicator-helper instance.
- appindicator-…-init - starts appindicator-helper process (usually called automatically inside
appindicator-create
macro) - appindicator-…-kill - kill appindicator helper process
- appindicator-…-set-icon - set tray icon
- appindicator-…-set-label - set label
- appindicator-…-set-active - hide/show icon
- appindicator-…-set-menu - set context menu
Function appindicator-NAME-set-icon
can set both icons from local filesystem and from online collections supported by svg-lib.
Icons from online collections may be used like this: (appindicator-NAME-set-icon "icon-name" "collection-name")
. You can check for available collections and icons they contain below:
- “bootstrap” - https://icons.getbootstrap.com/
- “simple” - https://simpleicons.org/
- “material” - https://mui.com/material-ui/material-icons/
- “octicons” - https://octicons.github.com
- “boxicons” - https://boxicons.com/
Code below will create tray icon with context menu:
(require 'appindicator)
(appindicator-create "emacs")
(appindicator-emacs-set-icon "gnuemacs" "simple")
(appindicator-emacs-set-label "emacs")
(appindicator-emacs-set-menu
'(("Minimize to tray" . iconify-or-deiconify-frame)
separator
("Hide icon" . (lambda () (appindicator-emacs-set-active nil)))))
(appindicator-emacs-set-active 't)
(appindicator-emacs-kill)