mirror of
https://git.disroot.org/FollieHiyuki/dotfiles.git
synced 2024-11-29 10:48:46 -05:00
248 lines
8.2 KiB
EmacsLisp
248 lines
8.2 KiB
EmacsLisp
;;; exwm.el -*- lexical-binding: t; -*-
|
|
|
|
(defun follie/run-in-background (command)
|
|
(let ((command-parts (split-string command "[ ]+")))
|
|
(apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
|
|
|
|
(defun follie/set-wallpaper ()
|
|
(interactive)
|
|
(start-process-shell-command
|
|
"feh" nil "feh --no-fehbg --bg-fill --randomize ~/Pictures/Wallpapers/*"))
|
|
|
|
(defun follie/exwm-init-hook ()
|
|
;; Make workspace 1 the default at startup
|
|
;;(exwm-workspace-switch-create 1)
|
|
|
|
;; Open eshell at startup
|
|
;;(eshell)
|
|
|
|
;; Additional status info on modeline
|
|
(setq display-time-day-and-date t)
|
|
(display-time-mode 1)
|
|
(if (not (equal "Battery status not available" (battery)))
|
|
(display-battery-mode 1))
|
|
|
|
;; Startup apps
|
|
(follie/run-in-background "pipewire")
|
|
(follie/run-in-background "dunst")
|
|
(follie/run-in-background "mpDris2")
|
|
(start-process-shell-command "xsetroot" nil "xsetroot -cursor_name left_ptr"))
|
|
|
|
(defun follie/configure-window-by-class ()
|
|
(interactive)
|
|
(pcase exwm-class-name
|
|
("Komikku" (exwm-floating-toggle-floating)
|
|
(exwm-layout-hide-mode-line))))
|
|
|
|
(defun follie/update-displays ()
|
|
(lambda ()
|
|
(start-process-shell-command
|
|
"xrandr" nil "xrandr --output eDP-1 --mode 1920x1080 --pos 0x0 --rotate normal --output HDMI-1 --mode 1920x1080 --pos 1920x0 --rotate normal"))
|
|
(follie/set-wallpaper)
|
|
(message "Updated displays: %s"
|
|
(string-trim (shell-command-to-string "xrandr | grep \" connected\" | awk '{print $1}' | sed '$!N;s/\\n/ /'"))))
|
|
|
|
(defun follie/exwm-rename-buffer ()
|
|
(interactive)
|
|
(exwm-workspace-rename-buffer
|
|
(concat exwm-class-name ":"
|
|
(if (<= (length exwm-title) 30) exwm-title
|
|
(concat (substring exwm-title 0 29))))))
|
|
|
|
(use-package! exwm
|
|
:config
|
|
;; Number of workspaces
|
|
(setq exwm-workspace-number 6)
|
|
|
|
;; Extra stuff at startup
|
|
(add-hook 'exwm-init-hook #'follie/exwm-init-hook)
|
|
|
|
;; Update buffer name
|
|
(add-hook 'exwm-update-class-hook #'follie/exwm-rename-buffer)
|
|
(add-hook 'exwm-update-title-hook #'follie/exwm-rename-buffer)
|
|
|
|
;; Force tiling by default
|
|
(setq exwm-manage-force-tiling nil)
|
|
;; Window rules
|
|
(add-hook 'exwm-manage-finish-hook #'follie/configure-window-by-class)
|
|
|
|
;; Automatically move EXWM buffer to current workspace
|
|
(setq exwm-layout-show-all-buffers t)
|
|
;; Display all buffers in every workspace buffer list
|
|
(setq exwm-workspace-show-all-buffers t)
|
|
|
|
;; Multi monitor
|
|
(require 'exwm-randr)
|
|
(setq exwm-randr-workspace-monitor-plist '(1 "HDMI-1"))
|
|
(add-hook 'exwm-randr-screen-change-hook #'follie/update-displays)
|
|
(exwm-randr-enable)
|
|
|
|
;; Set wallpapers after changing resolution
|
|
;;(follie/set-wallpaper)
|
|
|
|
;; System tray on minibuffer
|
|
(require 'exwm-systemtray)
|
|
(setq exwm-systemtray-height 20)
|
|
(exwm-systemtray-enable)
|
|
|
|
;; Automatically send cursor to the selected display
|
|
(setq exwm-workspace-warp-cursor t)
|
|
;; Focus follows cursor
|
|
(setq mouse-autoselect-window t
|
|
focus-follows-mouse t)
|
|
|
|
;; Keys that always pass through to Emacs in line-mode
|
|
(setq exwm-input-prefix-keys
|
|
'(?\C-x
|
|
?\C-u
|
|
?\C-g ;; keyboard-quit
|
|
?\C-h
|
|
?\M-x
|
|
?\M-`
|
|
?\M-&
|
|
?\M-:
|
|
?\C-\M-j)) ;; Buffer list
|
|
|
|
;; Ctrl+q to enable next key to be sent directly
|
|
(define-key exwm-mode-map [?\C-q] 'exwm-input-send-next-key)
|
|
|
|
;; Global key bindings
|
|
(setq exwm-input-global-keys
|
|
`(
|
|
;; Reset to line-mode (C-c C-k switches to char-mode via exwm-input-release-keyboard)
|
|
([?\s-r] . exwm-reset)
|
|
|
|
;; Move between windows
|
|
([s-left] . windmove-left)
|
|
([s-right] . windmove-right)
|
|
([s-up] . windmove-up)
|
|
([s-down] . windmove-down)
|
|
|
|
;; Launch applications via shell command
|
|
([?\s-&] . (lambda (command)
|
|
(interactive (list (read-shell-command "$ ")))
|
|
(start-process-shell-command command nil command)))
|
|
|
|
;; Switch workspace
|
|
([?\s-w] . exwm-workspace-switch)
|
|
([?\s-`] . (lambda () (interactive) (exwm-workspace-switch-create 0)))
|
|
|
|
;; 's-N': Switch to certain workspace with Super (Win) plus a number key (0 - 9)
|
|
,@(mapcar (lambda (i)
|
|
`(,(kbd (format "s-%d" i)) .
|
|
(lambda ()
|
|
(interactive)
|
|
(exwm-workspace-switch-create ,i))))
|
|
(number-sequence 0 9))))
|
|
(exwm-input-set-key (kbd "s-SPC") 'counsel-linux-app)
|
|
|
|
;; Enable EXWM
|
|
(exwm-enable)
|
|
;; Work around ido frame
|
|
(require 'exwm-config)
|
|
(exwm-config-ido)
|
|
(ido-mode nil))
|
|
|
|
;; Edit everthing in X windows with Emacs
|
|
(use-package! exwm-edit
|
|
:after exwm
|
|
:config
|
|
(exwm-input-set-key (kbd "s-e") #'exwm-edit--compose))
|
|
|
|
;; xbps but with Emacs
|
|
;;(use-package! system-packages
|
|
;; :config
|
|
;; (setq system-packages-use-sudo t))
|
|
|
|
;; EMMS
|
|
;;(use-package! emms
|
|
;; :init
|
|
;; (setq emms-seek-seconds 10)
|
|
;; :config
|
|
;; (require 'emms-setup)
|
|
;; (emms-all)
|
|
;; (emms-default-players)
|
|
;; ;; Play music with emms directly
|
|
;; (setq emms-source-file-default-directory "~/Music/"
|
|
;; emms-info-asynchronously 1
|
|
;; emms-playlist-buffer-name "*EMMS-Music*"
|
|
;; emms-source-file-directory-tree-function 'emms-source-file-directory-tree-find
|
|
;; emms-browser-covers 'emms-browser-cache-thumbnail-async)
|
|
;; ;; Or use mpd backend
|
|
;; ;;(require 'emms-player-mpd)
|
|
;; ;;(setq emms-player-mpd-server-name "localhost"
|
|
;; ;; emms-player-mpd-server-port "6600"
|
|
;; ;; emms-player-mpd-music-directory "~/Music")
|
|
;; ;;(add-to-list 'emms-player-list 'emms-player-mpd)
|
|
;; (add-to-list 'emms-info-functions
|
|
;; ;;'emms-info-mpd
|
|
;; 'emms-info-exiftool))
|
|
;; Key maps for emms
|
|
;;(map! :leader
|
|
;; :desc "Emms playlist"
|
|
;; "e a" #'emms-playlist-mode-go
|
|
;; :leader
|
|
;; :desc "Emms browse by album"
|
|
;; "e b" #'emms-browse-by-album
|
|
;; :leader
|
|
;; :desc "Emms pause track"
|
|
;; "e x" #'emms-pause
|
|
;; :leader
|
|
;; :desc "Emms stop track"
|
|
;; "e s" #'emms-stop
|
|
;; :leader
|
|
;; :desc "Emms previous track"
|
|
;; "e p" #'emms-previous
|
|
;; :leader
|
|
;; :desc "Emms next track"
|
|
;; "e n" #'emms-next)
|
|
;; Truncate emms module on mode line
|
|
;;(use-package! emms-mode-line-cycle
|
|
;; :after emms
|
|
;; :config
|
|
;; (emms-playing-time 1)
|
|
;; (emms-mode-line 1)
|
|
;; (emms-mode-line-cycle 1))
|
|
|
|
;; Function keys
|
|
(use-package! desktop-environment
|
|
:after exwm
|
|
:config (desktop-environment-mode)
|
|
:custom
|
|
;; Brightness
|
|
(desktop-environment-brightness-get-command "brightnessctl")
|
|
(desktop-environment-brightness-get-regexp "\\([0-9]+%\\)")
|
|
(desktop-environment-brightness-set-command "brightnessctl set %s")
|
|
(desktop-environment-brightness-small-increment "2%+")
|
|
(desktop-environment-brightness-small-decrement "2%-")
|
|
(desktop-environment-brightness-normal-increment "5%+")
|
|
(desktop-environment-brightness-normal-decrement "5%-")
|
|
;; Volume
|
|
(desktop-environment-volume-get-command "pulsemixer --get-volume")
|
|
(desktop-environment-volume-get-regexp "\\([0-9]+ \\)")
|
|
(desktop-environment-volume-toggle-command "pulsemixer --toggle-mute")
|
|
(desktop-environment-volume-toggle-microphone-command nil)
|
|
(desktop-environment-volume-set-command "pulsemixer --change-volume %s")
|
|
(desktop-environment-volume-small-increment "+2")
|
|
(desktop-environment-volume-small-decrement "-2")
|
|
(desktop-environment-volume-normal-increment "+5")
|
|
(desktop-environment-volume-normal-decrement "-5")
|
|
;; Screenshot
|
|
(desktop-environment-screenshot-directory "~/Screenshots")
|
|
(desktop-environment-screenshot-command "scrot -m -q 100 '%Y-%m-%d-%T_$wx$h.png'")
|
|
(desktop-environment-screenshot-partial-command
|
|
"scrot -s -f -l style=solid,width=2,color=\"red\" -q 100 '%Y-%m-%d-%T_$wx$h.png'")
|
|
;; Screenlock
|
|
(desktop-environment-screenlock-command "~/.local/bin/X11/i3lock.sh"))
|
|
|
|
;; Control dunst
|
|
(defun follie/disable-desktop-notifications ()
|
|
(interactive)
|
|
(start-process-shell-command "notify-send" nil "notify-send \"DUNST_COMMAND_PAUSE\""))
|
|
(defun follie/enable-desktop-notifications ()
|
|
(interactive)
|
|
(start-process-shell-command "notify-send" nil "notify-send \"DUNST_COMMAND_RESUME\""))
|
|
(defun follie/toggle-desktop-notifications ()
|
|
(interactive)
|
|
(start-process-shell-command "notify-send" nil "notify-send \"DUNST_COMMAND_TOGGLE\""))
|