/desktop-environment

Helps you control your GNU/Linux computer from Emacs

Primary LanguageEmacs LispGNU General Public License v3.0GPL-3.0

desktop-environment

MELPA Stable MELPA pipeline status

Summary

The package desktop-environment provides commands and a global minor mode to control your GNU/Linux desktop from Emacs.

With desktop-environment, you can control the brightness and volume as well as take screenshots and lock your screen. The package depends on the availability of shell commands to do the hard work for us. These commands can be changed by customizing the appropriate variables.

The global minor mode desktop-environment-mode binds standard keys to provided commands: e.g., <XF86AudioRaiseVolume> to raise the volume, <print> to take a screenshot, and <s-l> to lock the screen.

Installing

Add the following to your initialization file:

(add-to-list 'load-path "~/.emacs.d/lib/desktop-environment/")
(require 'desktop-environment)

If you want all commands to be bound to keys, add this line after the ones above:

(desktop-environment-mode)

Usage

The following table summarizes the available commands and their keybinding if desktop-environment-mode is enabled:

CommandKey binding
desktop-environment-brightness-increment<XF86MonBrightnessUp>
desktop-environment-brightness-decrement<XF86MonBrightnessDown>
desktop-environment-brightness-increment-slowlyS-<XF86MonBrightnessUp>
desktop-environment-brightness-decrement-slowlyS-<XF86MonBrightnessDown>
desktop-environment-volume-increment<XF86AudioRaiseVolume>
desktop-environment-volume-decrement<XF86AudioLowerVolume>
desktop-environment-volume-increment-slowlyS-<XF86AudioRaiseVolume>
desktop-environment-volume-decrement-slowlyS-<XF86AudioLowerVolume>
desktop-environment-toggle-mute<XF86AudioMute>
desktop-environment-toggle-microphone-mute<XF86AudioMicMute>
desktop-environment-screenshot-partS-<print>
desktop-environment-screenshot<print>
desktop-environment-lock-screens-l or <XF86ScreenSaver>
desktop-environment-toggle-wifi<XF86WLAN>
desktop-environment-toggle-bluetooth<XF86Bluetooth>
desktop-environment-toggle-music<XF86AudioPlay>
desktop-environment-music-previous<XF86AudioPrev>
desktop-environment-music-next<XF86AudioNext>
desktop-environment-music-stop<XF86AudioStop>

Configuration

Default configuration

To use all commands desktop-environment provides without customizing the package, the following system packages must be available on your system:

Configuring desktop-environment

The table below summarizes the available options. You can use M-x customize-group RET desktop-environment RET to change them.

OptionDescription
desktop-environment-keyboard-backlight-normal-incrementNormal keyboard increment value
desktop-environment-keyboard-backlight-normal-decrementNormal keyboard decrement value
desktop-environment-brightness-normal-incrementNormal brightness increment value
desktop-environment-brightness-normal-decrementNormal brightness decrement value
desktop-environment-brightness-small-incrementSmall brightness increment value
desktop-environment-brightness-small-decrementSmall brightness decrement value
desktop-environment-brightness-get-commandShell command getting current screen brightness level
desktop-environment-brightness-get-regexpRegular expression matching brightness value
desktop-environment-brightness-set-commandShell command setting the brightness level
desktop-environment-volume-normal-incrementNormal volume increment value
desktop-environment-volume-normal-decrementNormal volume decrement value
desktop-environment-volume-small-incrementSmall volume increment value
desktop-environment-volume-small-decrementSmall volume decrement value
desktop-environment-volume-get-commandShell command getting current volume level
desktop-environment-volume-get-regexpRegular expression matching volume value
desktop-environment-volume-set-commandShell command setting the volume level
desktop-environment-volume-toggle-commandShell command toggling between muted and unmuted
desktop-environment-volume-toggle-microphone-commandShell command toggling microphone between muted and unmuted
desktop-environment-screenshot-commandShell command taking a screenshot in the current working directory
desktop-environment-screenshot-partial-commandShell command taking a partial screenshot in the current working directory
desktop-environment-screenshot-directoryDirectory where to save screenshots
desktop-environment-screenshot-delay-argumentShell argument to append to the screenshot command to delay the screenshot
desktop-environment-screenlock-commandShell command locking the screen
desktop-environment-wifi-commandShell command toggling wifi
desktop-environment-bluetooth-commandShell command toggling bluetooth
desktop-environment-music-toggle-commandShell command toggling the music player
desktop-environment-music-previous-commandShell command for going to previous song
desktop-environment-music-next-commandShell command for going to next song
desktop-environment-music-stop-commandShell command for stopping the music player

Using light instead of brightnessctl

You might prefer to use light instead of brightnessctl. This can be done by adding the following to your configuration file:

(setq desktop-environment-brightness-get-command "light")
(setq desktop-environment-brightness-set-command "light %s")
(setq desktop-environment-brightness-get-regexp "^\\([0-9]+\\)")
(setq desktop-environment-brightness-normal-increment "-A 10")
(setq desktop-environment-brightness-normal-decrement "-U 10")
(setq desktop-environment-brightness-small-increment "-A 5")
(setq desktop-environment-brightness-small-decrement "-U 5")

EXWM Compatibility

The customizable variable desktop-environment-update-exwm-global-keys can be used to control how key bindings should be handled when EXWM is loaded.

If set to :global (the default), the key bindings will be set via `exwm-input-set-key`. This ensures that these are global bindings which work regardless of char-mode or line-mode.

When predominantly working with line mode, however, it may make sense to set it to the value :prefix instead. This way, EXWM knows to forward the bindings to the minor mode map in line mode. This way, when disabling desktop-environment-mode, the bindings are deactivated again.

Set to nil to disable any kind of special behavior in the presence of EXWM.

License

See COPYING. Copyright (c) 2018 Damien Cassou.

Donate using Liberapay