2017-11-15 17:35:17 +01:00
|
|
|
;; Configure additional settings if this is one of my NixOS machines
|
|
|
|
;; (i.e. if ExWM is required)
|
|
|
|
;; -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
(require 's)
|
|
|
|
(require 'f)
|
|
|
|
|
|
|
|
(defvar is-nixos
|
|
|
|
(let ((os-f "/etc/os-release"))
|
|
|
|
(s-contains?
|
|
|
|
"NixOS" (if (f-file? os-f) (f-read os-f)))))
|
|
|
|
|
2017-11-18 23:19:15 +01:00
|
|
|
(defun pulseaudio-ctl (cmd)
|
|
|
|
(shell-command (concat "pulseaudio-ctl " cmd))
|
|
|
|
(message "Volume command: %s" cmd))
|
|
|
|
|
|
|
|
(defun volume-mute () (interactive) (pulseaudio-ctl "mute"))
|
|
|
|
(defun volume-up () (interactive) (pulseaudio-ctl "up"))
|
|
|
|
(defun volume-down () (interactive) (pulseaudio-ctl "down"))
|
|
|
|
|
2017-11-17 16:12:40 +01:00
|
|
|
(defun brightness-up ()
|
|
|
|
(interactive)
|
2017-11-18 23:19:15 +01:00
|
|
|
(shell-command "exec light -A 10")
|
|
|
|
(message "Brightness increased"))
|
2017-11-17 16:12:40 +01:00
|
|
|
|
|
|
|
(defun brightness-down ()
|
|
|
|
(interactive)
|
2017-11-18 23:19:15 +01:00
|
|
|
(shell-command "exec light -U 10")
|
|
|
|
(message "Brightness decreased"))
|
2017-11-17 16:12:40 +01:00
|
|
|
|
2017-11-17 18:24:27 +01:00
|
|
|
(defun lock-screen ()
|
|
|
|
(interactive)
|
|
|
|
(shell-command "i3lock"))
|
|
|
|
|
2017-11-15 17:35:17 +01:00
|
|
|
(if is-nixos
|
|
|
|
(progn
|
|
|
|
(message "Running on NixOS, configuring ExWM.")
|
|
|
|
(require 'exwm)
|
|
|
|
(require 'exwm-config)
|
|
|
|
|
2017-11-15 18:29:30 +01:00
|
|
|
(fringe-mode 3)
|
|
|
|
|
|
|
|
(setq exwm-workspace-number 2)
|
2017-11-15 17:35:17 +01:00
|
|
|
;; Make class name the buffer name
|
|
|
|
(add-hook 'exwm-update-class-hook
|
|
|
|
(lambda ()
|
|
|
|
(exwm-workspace-rename-buffer exwm-class-name)))
|
|
|
|
|
|
|
|
;; 's-r': Reset
|
|
|
|
(exwm-input-set-key (kbd "s-r") #'exwm-reset)
|
|
|
|
;; 's-w': Switch workspace
|
|
|
|
(exwm-input-set-key (kbd "s-w") #'exwm-workspace-switch)
|
|
|
|
;; 's-N': Switch to certain workspace
|
|
|
|
(dotimes (i 10)
|
|
|
|
(exwm-input-set-key (kbd (format "s-%d" i))
|
|
|
|
`(lambda ()
|
|
|
|
(interactive)
|
|
|
|
(exwm-workspace-switch-create ,i))))
|
|
|
|
|
|
|
|
;; Launch applications with completion (dmenu style!)
|
2017-11-18 23:19:30 +01:00
|
|
|
(exwm-input-set-key (kbd "s-d") #'helm-run-external-command)
|
|
|
|
(exwm-input-set-key (kbd "s-p") #'helm-pass)
|
2017-11-15 17:35:17 +01:00
|
|
|
|
2017-11-15 18:29:30 +01:00
|
|
|
;; Toggle between line-mode / char-mode
|
|
|
|
(exwm-input-set-key (kbd "C-c C-t C-t") #'exwm-input-toggle-keyboard)
|
|
|
|
|
2017-11-18 23:19:15 +01:00
|
|
|
;; Volume keys
|
|
|
|
(exwm-input-set-key (kbd "<XF86AudioMute>") #'volume-mute)
|
|
|
|
(exwm-input-set-key (kbd "<XF86AudioRaiseVolume>") #'volume-up)
|
|
|
|
(exwm-input-set-key (kbd "<XF86AudioLowerVolume>") #'volume-down)
|
|
|
|
|
2017-11-17 16:12:40 +01:00
|
|
|
;; Brightness keys
|
|
|
|
(exwm-input-set-key (kbd "<XF86MonBrightnessDown>") #'brightness-down)
|
|
|
|
(exwm-input-set-key (kbd "<XF86MonBrightnessUp>") #'brightness-up)
|
2017-11-17 18:24:27 +01:00
|
|
|
(exwm-input-set-key (kbd "<XF86Display>") #'lock-screen)
|
2017-11-17 16:12:40 +01:00
|
|
|
|
2017-11-15 17:35:17 +01:00
|
|
|
;; Line-editing shortcuts
|
|
|
|
(exwm-input-set-simulation-keys
|
2017-11-15 18:30:33 +01:00
|
|
|
'(([?\C-d] . delete)
|
|
|
|
([?\C-w] . ?\C-c)))
|
2017-11-15 17:35:17 +01:00
|
|
|
|
|
|
|
;; Enable EXWM
|
|
|
|
(exwm-enable)
|
|
|
|
|
2017-11-15 20:46:56 +01:00
|
|
|
;; Show time in the mode line
|
2017-11-15 21:00:59 +01:00
|
|
|
(display-time-mode)
|
|
|
|
|
|
|
|
;; Let buffers move seamlessly between workspaces
|
|
|
|
(setq exwm-workspace-show-all-buffers t)
|
|
|
|
(setq exwm-layout-show-all-buffers t)))
|
2017-11-15 18:56:01 +01:00
|
|
|
|
2017-11-15 17:35:17 +01:00
|
|
|
(provide 'nixos)
|