Browse Source

Add bluetooth and wifi controls, using tlp

tags/v0.3.0
Jáchym Tomášek 5 months ago
parent
commit
a87e697a03
2 changed files with 38 additions and 1 deletions
  1. 3
    0
      README.org
  2. 35
    1
      desktop-environment.el

+ 3
- 0
README.org View File

@@ -67,6 +67,8 @@ keybinding if ~desktop-environment-mode~ is enabled:
| desktop-environment-screenshot-part | ~S-<print>~ |
| desktop-environment-screenshot | ~<print>~ |
| desktop-environment-lock-screen | ~s-l~ |
| desktop-environment-toggle-wifi | ~<XF86WLAN>~ |
| desktop-environment-toggle-bluetooth | ~<XF86Bluetooth>~ |

** Dependencies
To use every commands desktop-environment provides, the following packages must
@@ -76,6 +78,7 @@ be available on your system:
- Screenshot: [[https://tracker.debian.org/pkg/scrot][scrot]]
- Screenlock: [[https://tools.suckless.org/slock/][slock]]
- Keyboard backlight: [[https://upower.freedesktop.org/][upower]]
- Wifi and bluetooth: [[https://linrunner.de/en/tlp/tlp.html][TLP]]

** License


+ 35
- 1
desktop-environment.el View File

@@ -164,6 +164,18 @@ portion of the screen."
:type 'string)

;;; Customization - wifi

(defcustom desktop-environment-wifi-command "wifi toggle"
"Shell command toggling wifi."
:type 'string)

;;; Customization - bluetooth

(defcustom desktop-environment-bluetooth-command "bluetooth toggle"
"Shell command toggling bluetooth."
:type 'string)

;;; Helper functions - brightness

(defun desktop-environment-brightness-get ()
@@ -349,6 +361,24 @@ the screen."
(async-shell-command desktop-environment-screenlock-command)))

;;; Commands - wifi

;;;###autoload
(defun desktop-environment-toggle-wifi ()
"Toggle wifi adapter on and off."
(interactive)
(let ((async-shell-command-buffer 'new-buffer))
(async-shell-command desktop-environment-wifi-command)))

;;; Commands - bluetooth

;;;###autoload
(defun desktop-environment-toggle-bluetooth ()
"Toggle bluetooth on and off."
(interactive)
(let ((async-shell-command-buffer 'new-buffer))
(async-shell-command desktop-environment-bluetooth-command)))
;;; Minor mode

(defvar desktop-environment-mode-map
@@ -369,7 +399,11 @@ the screen."
(,(kbd "S-<print>") . ,(function desktop-environment-screenshot-part))
(,(kbd "<print>") . ,(function desktop-environment-screenshot))
;; Screen locking
(,(kbd "s-l") . ,(function desktop-environment-lock-screen))))
(,(kbd "s-l") . ,(function desktop-environment-lock-screen))
;; Wifi controls
(,(kbd "<XF86WLAN>") . ,(function desktop-environment-toggle-wifi))
;; Bluetooth controls
(,(kbd "<XF86Bluetooth>") . ,(function desktop-environment-toggle-bluetooth))))
(map (make-sparse-keymap)))
(dolist (keybinding desktop-environment--keybindings)
(define-key map (car keybinding) (cdr keybinding)))

Loading…
Cancel
Save