diff options
author | jao <jao@gnu.org> | 2022-09-15 01:04:08 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2022-09-15 01:04:08 +0100 |
commit | eb51942061c05705858aa1740e9486bf8c13c127 (patch) | |
tree | a36f4c7a0cfc09472b9e3eec9e8d8b36dd6d7da2 | |
parent | f9f4e70278e2052900c70965dcf9099087565a1a (diff) | |
download | elibs-eb51942061c05705858aa1740e9486bf8c13c127.tar.gz elibs-eb51942061c05705858aa1740e9486bf8c13c127.tar.bz2 |
moving code around, no changes
-rw-r--r-- | init.el | 499 |
1 files changed, 250 insertions, 249 deletions
@@ -395,239 +395,6 @@ ;;;; man pages (setq Man-notify-method 'pushy) ;; pushy - same window -;;; Window manager and window system helpers -;;;; transparency -(defvar jao-transparent-only-bg (> emacs-major-version 28)) - -(defvar jao-frames-default-alpha - (cond ((eq window-system 'pgtk) 80) - (jao-transparent-only-bg 88) - (t 85))) - -(defvar jao-transparent-frame (< jao-frames-default-alpha 100)) - -(defun jao-transparent-p () jao-transparent-frame) - -(defun jao-alpha-parameters (&optional level) - (let ((level (or level jao-frames-default-alpha))) - (if jao-transparent-only-bg - `((alpha-background . ,level) (alpha)) - `((alpha . ,(cons level level)) (alpha-background))))) - -(defun jao-set-transparency (&optional level all) - (interactive "nOpacity (0-100): ") - (let ((level (or level jao-frames-default-alpha))) - (setq jao-transparent-frame (< level 100)) - (if all - (modify-all-frames-parameters (jao-alpha-parameters level)) - (modify-frame-parameters nil (jao-alpha-parameters level))))) - -(defun jao-toggle-transparency (&optional all) - (interactive "P") - (let ((level (if jao-transparent-frame 100 jao-frames-default-alpha))) - (jao-set-transparency level all))) - -;;;; x11 utils -(defun jao-xdotool (arg-or-wait &rest args) - (apply 'jao-shell-exec* - (if (stringp arg-or-wait) "xdotool" arg-or-wait) - (if (stringp arg-or-wait) arg-or-wait "xdotool") - args)) - -(defsubst jao-xdotool-string (&rest args) - (apply 'jao-shell-string "xdotool" args)) - -(defsubst jao-x11-focused-id () (jao-xdotool-string "getwindowfocus")) - -(defsubst jao-x11-window-name (&optional wid) - (jao-xdotool-string "getwindowname" (or wid (jao-x11-focused-id)))) - -(defsubst jao-x11-search-window (title) - (jao-xdotool-string "search" "--name" title)) - -(defsubst jao-x11-goto-ws (n) (jao-xdotool t "set_desktop" (format "%s" n))) - -;;;; exwm -(defvar jao-exwm-enabled nil) -(defun jao-exwm-enabled-p () jao-exwm-enabled) - -(defun jao-exwm-enable () - (require 'jao-custom-exwm) - (setq jao-exwm-enabled t) - (display-time-mode -1) - (exwm-enable) - (setq jao-frames-default-alpha 88) - (jao-set-transparency) - (x-change-window-property "_XMONAD_TRAYPAD" "" nil nil nil nil 0) - (if (> emacs-major-version 28) - (xmobar-mode 1) - (jao-xmobar-restart)) - (jao-trisect t)) - -;;;; xmonad -(defvar jao-xmonad-enabled (string= "xmonad" (or (getenv "wm") ""))) -(defun jao-xmonad-enabled-p () jao-xmonad-enabled) - -(defun jao-xmonad-enable () - (setq jao-browse-doc-use-emacs-p (display-graphic-p)) - (setq jao-wallpaper-random-wake t) - (display-battery-mode -1) - (jao-set-transparency) - (jao-trisect) - (message "Welcome to xmonad")) - -(when jao-xmonad-enabled - (add-hook 'after-init-hook #'jao-xmonad-enable t)) - -;;;; wayland - -(use-package jao-wayland :demand t) - -(defun jao-wayland-enable () - (interactive) - (defalias 'x-change-window-property #'ignore) - (when (eq 'pgtk window-system) (jao-set-transparency 85)) - (jao-themes-setup) - (jao-trisect) - (message "Welcome to wayland")) - -(defun jao-river-enable () - (jao-wayland-enable) - (when (jao-shell-running-p "i3bar-river") - (jao-tracking-set-log "")) - (message "Welcome to river")) - -(when jao-river-enabled - (add-hook 'after-init-hook #'jao-river-enable)) - -(when jao-sway-enabled - (add-hook 'after-init-hook #'jao-wayland-enable)) - -;;;; wallpaper -(defvar jao-wallpaper-dir "~/.wallpapers/") - -(defvar jao-wallpaper-random-candidates - '("wallpaper.jpg" "wallpaper2.jpg")) - -(defvar jao-wallpaper-random-candidates-light - '("wallpaper.jpg" "wallpaper2.jpg")) - -(defvar jao-wallpaper-random-wake t - "Set to t for getting a new wallpaper on awaking from sleep") - -(defun jao-set-wallpaper (&optional path) - (interactive) - (let ((current (format "~/.wallpaper.%s" (jao-colors-scheme)))) - (when-let ((f (or (expand-file-name path) - (read-file-name "Image: " - jao-wallpaper-dir - (file-symlink-p current) - t)))) - (make-symbolic-link f current t) - (cond (jao-river-enabled (jao-river-set-wallpaper f)) - (jao-sway-enabled (jao-sway-set-wallpaper f)) - (t (shell-command-to-string (format "xwallpaper --zoom %s" f))))))) - -(defun jao-set-random-wallpaper () - (interactive) - (when (or (called-interactively-p 'interactive) - jao-wallpaper-random-wake) - (let* ((ws (if (jao-colors-scheme-dark-p) - jao-wallpaper-random-candidates - jao-wallpaper-random-candidates-light)) - (f (seq-random-elt ws))) - (jao-set-wallpaper (expand-file-name f jao-wallpaper-dir)) - (message "%s" f)))) - -(add-to-list 'jao-sleep-awake-functions #'jao-set-random-wallpaper) - -;;;; screensaver and lock -(defun jao-screensaver-enabled () - (string= (jao-shell-string "xdg-screensaver status") "enabled")) - -(defun jao-screensaver-toggle () - (interactive) - (let ((wid (jao-x11-focused-id))) - (if (jao-screensaver-enabled) - (jao-shell-exec* "xdg-screensaver" "suspend" wid) - (jao-shell-exec* "xdg-screensaver" wid)) - (jao-notify (format "Using '%s'" (jao-x11-window-name wid)) - (format "Screensaver %s" - (jao-shell-string "xdg-screensaver status"))))) - -(jao-shell-def-exec jao-xlock-screen "xdg-screensaver" "activate") -(jao-shell-def-exec jao-suspend "sudo" "systemctl" "suspend") -(jao-shell-def-exec jao-poweroff "sudo" "systemctl" "poweroff") - -(defun jao-lock-screen () - (interactive) - (if jao-wayland-enabled - (shell-command "swaylock -i ~/.lockimage") - (jao-xlock-screen))) - -(transient-define-prefix jao-transient-sleep () - ["Sleep" - ("l" "lock screen" jao-lock-screen) - ("z" "sleep" jao-suspend) - ("u" "enable/disable screensaver" jao-screensaver-toggle) - ("poof" "power-off" jao-poweroff)]) - -;;;; mouse -(use-package disable-mouse - :ensure t - :diminish ((disable-mouse-global-mode . ""))) - -(global-disable-mouse-mode) - -;;;; X clipboard -(setq select-enable-clipboard t - select-enable-primary t - selection-timeout 100 - xterm-select-active-regions t) - -(use-package xclip - :ensure t - :init (setq xclip-method (if jao-wayland-enabled 'wl-copy 'xclip))) - -(unless (display-graphic-p) (xclip-mode 1)) - -;;;; pop-up frames -(defun jao-open-in-x-frame (&optional width height) - (interactive) - (make-frame `((window-system . x) - (name . "emacs popup") - (width . ,(or width (window-width))) - (height . ,(or height (window-height))))) - (define-key (current-local-map) "q" #'delete-frame)) - -;;;; xmobar -(defun jao-xmobar-kill () - (interactive) - (shell-command "killall xmobar-single")) - -(defun jao-xmobar-restart () - (interactive) - (jao-xmobar-kill) - (start-process "" nil "xmobar-single" "-d")) - -(use-package tab-bar - :init (setq tab-bar-close-button-show nil - tab-bar-show (> emacs-major-version 28) - tab-bar-format ())) - -(use-package xmobar - :init (setq xmobar-tab-bar t - xmobar-tab-split "*" - xmobar-tab-bar-format - (if window-system - '(xmobar-left-string - tab-bar-format-align-right - xmobar-right-string) - '(xmobar-left-string - xmobar-elastic-space - xmobar-right-string)) - xmobar-command "xmobar-emacs")) - ;;; Minibuffer (use-package jao-minibuffer :init @@ -650,28 +417,29 @@ (jao-minibuffer-mode 1) ;;; Mode line -;;;; config and jao-mode-line -(defvar jao-modeline-in-minibuffer (and window-system t)) - -(setq line-number-display-limit-width 250) -(setq mode-line-position-column-format '(" %c") - mode-line-position-line-format '(" %l,%c")) -(setq mode-line-percent-position +;;;; config +(setq line-number-display-limit-width 250 + mode-line-position-column-format '(" %c") + mode-line-position-line-format '(" %l,%c") + mode-line-end-spaces nil + mode-line-percent-position '(" %l" (:eval (format "/%d" (line-number-at-pos (point-max)))))) + (line-number-mode -1) (column-number-mode 1) +;;;; jao-mode-line +(defvar jao-modeline-in-minibuffer (and window-system t)) + (use-package jao-mode-line :commands (jao-mode-line-add-to-minibuffer jao-mode-line-remove-from-minibuffer)) -(when jao-modeline-in-minibuffer - ;; (add-hook 'display-time-hook #'jao-minibuffer-refresh) - (add-hook 'after-init-hook - (lambda () (jao-mode-line-add-to-minibuffer 90)))) +(add-hook 'after-init-hook + (lambda () + (when jao-modeline-in-minibuffer + (jao-mode-line-add-to-minibuffer 90)))) -;;;; format tweaks -(setq mode-line-end-spaces nil) ;;;; time display (setq display-time-world-list '(("Europe/Paris" "Barcelona") @@ -1195,8 +963,6 @@ (define-key other-window-repeat-map "p" 'jao-prev-window) -(global-set-key (kbd "C-x p") 'jao-prev-window) -(global-set-key (kbd "C-x o") 'other-window) (mapc (lambda (n) (global-set-key (format "\C-c%s" (1+ n)) (jao-nth-window n))) '(0 1 2 3 4 5 6 7 8)) @@ -2907,7 +2673,8 @@ ;;;; ement (use-package ement :ensure t - :init (setq ement-save-sessions t) + :init (setq ement-save-sessions t + ement-room-avatars nil) :config (defun jao-ement-track (event room session) @@ -3237,6 +3004,238 @@ (global-set-key (kbd "s-m") #'jao-transient-media) +;;; Graphical window system +;;;; transparency +(defvar jao-transparent-only-bg (> emacs-major-version 28)) + +(defvar jao-frames-default-alpha + (cond ((eq window-system 'pgtk) 80) + (jao-transparent-only-bg 88) + (t 85))) + +(defvar jao-transparent-frame (< jao-frames-default-alpha 100)) + +(defun jao-alpha-parameters (&optional level) + (let ((level (or level jao-frames-default-alpha))) + (if jao-transparent-only-bg + `((alpha-background . ,level) (alpha)) + `((alpha . ,(cons level level)) (alpha-background))))) + +(defun jao-set-transparency (&optional level all) + (interactive "nOpacity (0-100): ") + (let ((level (or level jao-frames-default-alpha))) + (setq jao-transparent-frame (< level 100)) + (if all + (modify-all-frames-parameters (jao-alpha-parameters level)) + (modify-frame-parameters nil (jao-alpha-parameters level))))) + +(defun jao-toggle-transparency (&optional all) + (interactive "P") + (let ((level (if jao-transparent-frame 100 jao-frames-default-alpha))) + (jao-set-transparency level all))) + +;;;; x11 utils +(defun jao-xdotool (arg-or-wait &rest args) + (apply 'jao-shell-exec* + (if (stringp arg-or-wait) "xdotool" arg-or-wait) + (if (stringp arg-or-wait) arg-or-wait "xdotool") + args)) + +(defsubst jao-xdotool-string (&rest args) + (apply 'jao-shell-string "xdotool" args)) + +(defsubst jao-x11-focused-id () (jao-xdotool-string "getwindowfocus")) + +(defsubst jao-x11-window-name (&optional wid) + (jao-xdotool-string "getwindowname" (or wid (jao-x11-focused-id)))) + +(defsubst jao-x11-search-window (title) + (jao-xdotool-string "search" "--name" title)) + +(defsubst jao-x11-goto-ws (n) (jao-xdotool t "set_desktop" (format "%s" n))) + +;;;; exwm +(defvar jao-exwm-enabled nil) +(defun jao-exwm-enabled-p () jao-exwm-enabled) + +(defun jao-exwm-enable () + (require 'jao-custom-exwm) + (setq jao-exwm-enabled t) + (display-time-mode -1) + (exwm-enable) + (setq jao-frames-default-alpha 88) + (jao-set-transparency) + (x-change-window-property "_XMONAD_TRAYPAD" "" nil nil nil nil 0) + (if (> emacs-major-version 28) + (xmobar-mode 1) + (jao-xmobar-restart)) + (jao-trisect t)) + +;;;; xmonad +(defvar jao-xmonad-enabled (string= "xmonad" (or (getenv "wm") ""))) +(defun jao-xmonad-enabled-p () jao-xmonad-enabled) + +(defun jao-xmonad-enable () + (setq jao-browse-doc-use-emacs-p (display-graphic-p)) + (setq jao-wallpaper-random-wake t) + (setq jao-modeline-in-minibuffer nil) + (display-battery-mode -1) + ;; (jao-set-transparency) + (jao-trisect) + (message "Welcome to xmonad")) + +(when jao-xmonad-enabled + (add-hook 'after-init-hook #'jao-xmonad-enable t)) + +;;;; wayland + +(use-package jao-wayland :demand t) + +(defun jao-wayland-enable () + (interactive) + (defalias 'x-change-window-property #'ignore) + (when (eq 'pgtk window-system) (jao-set-transparency 85)) + (jao-themes-setup) + (jao-trisect) + (message "Welcome to wayland")) + +(defun jao-river-enable () + (jao-wayland-enable) + (when (jao-shell-running-p "i3bar-river") + (jao-tracking-set-log "")) + (message "Welcome to river")) + +(when jao-river-enabled + (add-hook 'after-init-hook #'jao-river-enable t)) + +(when jao-sway-enabled + (add-hook 'after-init-hook #'jao-wayland-enable t)) + +;;;; wallpaper +(defvar jao-wallpaper-dir "~/.wallpapers/") + +(defvar jao-wallpaper-random-candidates + '("wallpaper.jpg" "wallpaper2.jpg")) + +(defvar jao-wallpaper-random-candidates-light + '("wallpaper.jpg" "wallpaper2.jpg")) + +(defvar jao-wallpaper-random-wake t + "Set to t for getting a new wallpaper on awaking from sleep") + +(defun jao-set-wallpaper (&optional path) + (interactive) + (let ((current (format "~/.wallpaper.%s" (jao-colors-scheme)))) + (when-let ((f (or (expand-file-name path) + (read-file-name "Image: " + jao-wallpaper-dir + (file-symlink-p current) + t)))) + (make-symbolic-link f current t) + (cond (jao-river-enabled (jao-river-set-wallpaper f)) + (jao-sway-enabled (jao-sway-set-wallpaper f)) + (t (shell-command-to-string (format "xwallpaper --zoom %s" f))))))) + +(defun jao-set-random-wallpaper () + (interactive) + (when (or (called-interactively-p 'interactive) + jao-wallpaper-random-wake) + (let* ((ws (if (jao-colors-scheme-dark-p) + jao-wallpaper-random-candidates + jao-wallpaper-random-candidates-light)) + (f (seq-random-elt ws))) + (jao-set-wallpaper (expand-file-name f jao-wallpaper-dir)) + (message "%s" f)))) + +(add-to-list 'jao-sleep-awake-functions #'jao-set-random-wallpaper) + +;;;; screensaver and lock +(defun jao-screensaver-enabled () + (string= (jao-shell-string "xdg-screensaver status") "enabled")) + +(defun jao-screensaver-toggle () + (interactive) + (let ((wid (jao-x11-focused-id))) + (if (jao-screensaver-enabled) + (jao-shell-exec* "xdg-screensaver" "suspend" wid) + (jao-shell-exec* "xdg-screensaver" wid)) + (jao-notify (format "Using '%s'" (jao-x11-window-name wid)) + (format "Screensaver %s" + (jao-shell-string "xdg-screensaver status"))))) + +(jao-shell-def-exec jao-xlock-screen "xdg-screensaver" "activate") +(jao-shell-def-exec jao-suspend "sudo" "systemctl" "suspend") +(jao-shell-def-exec jao-poweroff "sudo" "systemctl" "poweroff") + +(defun jao-lock-screen () + (interactive) + (if jao-wayland-enabled + (shell-command "swaylock -i ~/.lockimage") + (jao-xlock-screen))) + +(transient-define-prefix jao-transient-sleep () + ["Sleep" + ("l" "lock screen" jao-lock-screen) + ("z" "sleep" jao-suspend) + ("u" "enable/disable screensaver" jao-screensaver-toggle) + ("poof" "power-off" jao-poweroff)]) + +;;;; mouse +(use-package disable-mouse + :ensure t + :diminish ((disable-mouse-global-mode . ""))) + +(global-disable-mouse-mode) + +;;;; X clipboard +(setq select-enable-clipboard t + select-enable-primary t + selection-timeout 100 + xterm-select-active-regions t) + +(use-package xclip + :ensure t + :init (setq xclip-method (if jao-wayland-enabled 'wl-copy 'xclip))) + +(unless (display-graphic-p) (xclip-mode 1)) + +;;;; pop-up frames +(defun jao-open-in-x-frame (&optional width height) + (interactive) + (make-frame `((window-system . x) + (name . "emacs popup") + (width . ,(or width (window-width))) + (height . ,(or height (window-height))))) + (define-key (current-local-map) "q" #'delete-frame)) + +;;;; xmobar +(defun jao-xmobar-kill () + (interactive) + (shell-command "killall xmobar-single")) + +(defun jao-xmobar-restart () + (interactive) + (jao-xmobar-kill) + (start-process "" nil "xmobar-single" "-d")) + +(use-package tab-bar + :init (setq tab-bar-close-button-show nil + tab-bar-show (> emacs-major-version 28) + tab-bar-format ())) + +(use-package xmobar + :init (setq xmobar-tab-bar t + xmobar-tab-split "*" + xmobar-tab-bar-format + (if window-system + '(xmobar-left-string + tab-bar-format-align-right + xmobar-right-string) + '(xmobar-left-string + xmobar-elastic-space + xmobar-right-string)) + xmobar-command "xmobar-emacs")) + ;;; Global transients (defun jao-list-packages () (interactive) @@ -3301,6 +3300,8 @@ ;;; Global key bindings (global-set-key (kbd "<f2>") #'magit-status) +(global-set-key (kbd "C-x p") 'jao-prev-window) +(global-set-key (kbd "C-x o") 'other-window) (global-set-key "\C-cj" #'join-line) (global-set-key "\C-cn" #'next-error) (global-set-key "\C-cq" #'auto-fill-mode) |