From b97281bca6c7e9c10c20e93cc0f61d86618d6594 Mon Sep 17 00:00:00 2001 From: Valentin Boettcher Date: Sat, 2 Apr 2022 16:18:19 +0200 Subject: [PATCH] emacs updates + monitor management --- config.sh | 9 ++-- dots/bspwm/bspwmrc.template | 18 +------- dots/bspwm/montitor_laptop.py | 83 ++++++++++++++++++++++++++++++++++ dots/emacs/emacs.org | 84 ++++++++++++++++++----------------- dots/home/.emacs | 3 +- dots/xournal/config | 6 +-- 6 files changed, 138 insertions(+), 65 deletions(-) create mode 100644 dots/bspwm/montitor_laptop.py diff --git a/config.sh b/config.sh index e540cae..646094b 100644 --- a/config.sh +++ b/config.sh @@ -7,11 +7,12 @@ zMAIN_FONT="Source Code Pro 8" SCREEN_LAYOUT="xrandr --output eDP-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output DP-1 --off --output HDMI-1 --off --output DP-2 --off --output HDMI-2 --off --output DP-2-1 --off --output DP-2-2 --off --output DP-2-3 --off" SCREEN_LAYOUT_DOCKED="xrandr --output eDP-1 --off --output DP-1 --off --output HDMI-1 --off --output DP-2 --off --output HDMI-2 --off --output DP-2-1 --primary --mode 2560x1440 --pos 1920x0 --rotate normal --output DP-2-2 --mode 1920x1200 --pos 4480x0 --rotate normal --output DP-2-3 --mode 1920x1080 --pos 0x0 --rotate normal" #SCREEN_LAYOUT_DOCKED="xrandr --output eDP-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output DP-1 --off --output HDMI-1 --off --output DP-2 --off --output HDMI-2 --mode 1920x1080 --pos 1920x0 --rotate normal" -MONITORS=(DP-2-1 DP-2-3 DP-2-2) +#MONITORS=(DP-2-1 DP-2-3 DP-2-2) #MONITORS=(eDP-1 HDMI-2) -MAIN_MONITOR=DP-2-1 -#MAIN_MONITOR=eDP-1 +#MAIN_MONITOR=DP-2-1 +MAIN_MONITOR=eDP-1 SIDE_MONITORS=($(xrandr | rg -i "\sconnected" | rg -v eDP | cut -d" " -f1 | grep -v $MAIN_MONITOR)) BAR_POS="top" LAPTOP=1 -TERM_FONT_SIZE=6 +TERM_FONT_SIZE=10 +DPI=157.35 diff --git a/dots/bspwm/bspwmrc.template b/dots/bspwm/bspwmrc.template index 2a396fe..8d0ffc0 100755 --- a/dots/bspwm/bspwmrc.template +++ b/dots/bspwm/bspwmrc.template @@ -35,20 +35,4 @@ bspc config remove_unplugged_monitors true # Scripts # ############################################################################### -{{ #SCREENLAYOUT }} -sh {{ SCREENLAYOUT }} -{{ /SCREENLAYOUT }} - -{{ #laptop }} -bash ~/.config/bspwm/monitor_laptop.sh & -{{ /laptop }} - -{{ #LAPTOP }} -bash ~/.config/bspwm/monitor_laptop.sh & -{{ /LAPTOP }} - -{{ ^LAPTOP }} -bash ~/.config/bspwm/monitor_desktop.sh & -{{ /LAPTOP }} - -bash ~/.config/polybar/launch.sh & +python ~/.config/bspwm/montitor_laptop.py & diff --git a/dots/bspwm/montitor_laptop.py b/dots/bspwm/montitor_laptop.py new file mode 100644 index 0000000..ef8b56b --- /dev/null +++ b/dots/bspwm/montitor_laptop.py @@ -0,0 +1,83 @@ +import os + +all_workspaces = set(range(1, 11)) + +# generically on main +on_main = {1, 5, 6} +rest = all_workspaces - on_main + +workspace_distribution = { + 1: [all_workspaces], + 2: [on_main, rest], + 3: [on_main, {2, 4, 9}, rest - {2, 4, 9}], +} + +os.system("autorandr --change") + + +main_monitor = os.popen("bspc query -M -m primary").read().strip() +monitors = os.popen("bspc query -M").readlines() + +monitors = map(lambda mon: mon.strip(), monitors) +monitors = filter(lambda mon: mon != main_monitor, monitors) +monitors = [main_monitor] + list(monitors) +monitor_names = { + id: os.popen(f"bspc query -M -m {id} --names").read().strip() for id in monitors +} + +active_mons = [ + l.strip() + for l in os.popen( + "xrandr | awk '/ connected/ && /[[:digit:]]x[[:digit:]].*+/{print $1}' " + ) + .read() + .splitlines() +] + +monitors = list(filter(lambda mon: monitor_names[mon] in active_mons, monitors)) +num_mon = len(monitors) + +os.system(f"bspc monitor -d {' '.join(str(ws) for ws in all_workspaces)}") + +workspace_mapping = [] +if num_mon in workspace_distribution: + workspace_mapping = workspace_distribution[num_mon] +else: + workspace_mapping = [on_main] + list(map(lambda _: set(), monitors[1:])) + + for i, ws in enumerate(rest): + workspace_mapping[i % (num_mon - 1) + 1].add(ws) + + +def ws_to_monitor(ws, monitor): + os.system(f"bspc desktop {ws} -m {monitor}") + + +for monitor, ws_set in zip(monitors, workspace_mapping): + for ws in ws_set: + ws_to_monitor(ws, monitor) + +for ws in os.popen("bspc query -D").readlines(): + name = os.popen(f"bspc query -D -d {ws.strip()} --names").read().strip() + if not name.isnumeric(): + print(f"Removing weird desktop {name}.") + children = os.popen(f"bspc query -N -d {ws.strip()}").readlines() + for child in children: + os.system(f"bspc node {child} -d 1") + + os.system(f"bspc desktop {ws.strip()} -r") + + +os.system("bspc wm -o") + +os.system("~/.scripts/wallp") +# os.system("sleep 1 && ~/.config/polybar/launch.sh") + +current_config = os.popen("autorandr --detect").read().strip() + +if current_config == "docked": + os.system("setxkbmap us") + +if current_config == "mobile": + os.system("setxkbmap us -v workman") + os.system("xmodmap ~/.xmodmaprc") diff --git a/dots/emacs/emacs.org b/dots/emacs/emacs.org index e64f709..f107930 100644 --- a/dots/emacs/emacs.org +++ b/dots/emacs/emacs.org @@ -455,23 +455,23 @@ Swiper and rg alternative. ("C-c b" . consult-bookmark) ("C-c k" . consult-kmacro) ;; C-x bindings (ctl-x-map) - ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command - ("C-x b" . consult-buffer) ;; orig. switch-to-buffer + ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command + ("C-x b" . consult-buffer) ;; orig. switch-to-buffer ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window - ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame + ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame ;; Custom M-# bindings for fast register access ("M-#" . consult-register-load) - ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) + ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) ("C-M-#" . consult-register) ;; Other custom bindings - ("M-y" . consult-yank-pop) ;; orig. yank-pop - (" a" . consult-apropos) ;; orig. apropos-command + ("M-y" . consult-yank-pop) ;; orig. yank-pop + (" a" . consult-apropos) ;; orig. apropos-command ;; M-g bindings (goto-map) ("M-g e" . consult-compile-error) - ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck - ("M-g g" . consult-goto-line) ;; orig. goto-line - ("M-g M-g" . consult-goto-line) ;; orig. goto-line - ("M-g o" . consult-outline) ;; Alternative: consult-org-heading + ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck + ("M-g g" . consult-goto-line) ;; orig. goto-line + ("M-g M-g" . consult-goto-line) ;; orig. goto-line + ("M-g o" . consult-outline) ;; Alternative: consult-org-heading ("M-g m" . consult-mark) ("M-g k" . consult-global-mark) ("M-g i" . consult-imenu) @@ -493,10 +493,10 @@ Swiper and rg alternative. :map boon-command-map ("w" . consult-line) :map isearch-mode-map - ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string - ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string - ("M-s l" . consult-line) ;; needed by consult-line to detect isearch - ("M-s L" . consult-line-multi)) ;; needed by consult-line to detect isearch + ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s l" . consult-line) ;; needed by consult-line to detect isearch + ("M-s L" . consult-line-multi)) ;; needed by consult-line to detect isearch ;; Enable automatic preview at point in the *Completions* buffer. ;; This is relevant when you use the default completion UI, @@ -539,7 +539,6 @@ Swiper and rg alternative. :preview-key '(:debounce 0.2 any) consult-ripgrep consult-git-grep consult-grep consult-bookmark consult-recent-file consult-xref - consult--source-file consult--source-project-file consult--source-bookmark :preview-key (kbd "M-.")) ;; Optionally configure the narrowing key. @@ -552,17 +551,17 @@ Swiper and rg alternative. ;; Optionally configure a function which returns the project root directory. ;; There are multiple reasonable alternatives to chose from. - ;;;; 1. project.el (project-roots) + ;;;; 1. project.el (project-roots) ;; (setq consult-project-root-function ;; (lambda () ;; (when-let (project (project-current)) ;; (car (project-roots project))))) - ;;;; 2. projectile.el (projectile-project-root) + ;;;; 2. projectile.el (projectile-project-root) (autoload 'projectile-project-root "projectile") (setq consult-project-root-function #'projectile-project-root) - ;;;; 3. vc.el (vc-root-dir) + ;;;; 3. vc.el (vc-root-dir) ;; (setq consult-project-root-function #'vc-root-dir) - ;;;; 4. locate-dominating-file + ;;;; 4. locate-dominating-file ;; (setq consult-project-root-function (lambda () (locate-dominating-file "." ".git"))) ) #+end_src @@ -1071,22 +1070,22 @@ Multiple major modes in one buffer. **** Bars Add pretty bars to the org indent. #+begin_src emacs-lisp :tangle yes - (use-package org-bars - :straight (:host github :repo "tonyaldon/org-bars") - :hook (org-mode . org-bars-mode) - :config - (setq org-bars-color-options '(:desaturate-level-faces 30 :darken-level-faces 15))) + ;; (use-package org-bars + ;; :straight (:host github :repo "tonyaldon/org-bars") + ;; :hook (org-mode . org-bars-mode) + ;; :config + ;; (setq org-bars-color-options '(:desaturate-level-faces 30 :darken-level-faces 15))) #+end_src And disable the ellipsis. #+begin_src emacs-lisp :tangle yes - (defun org-no-ellipsis-in-headlines () - "Remove use of ellipsis in headlines. - See `buffer-invisibility-spec'." - (remove-from-invisibility-spec '(outline . t)) - (add-to-invisibility-spec 'outline)) + ;; (defun org-no-ellipsis-in-headlines () + ;; "Remove use of ellipsis in headlines. + ;; See `buffer-invisibility-spec'." + ;; (remove-from-invisibility-spec '(outline . t)) + ;; (add-to-invisibility-spec 'outline)) - (add-hook 'org-mode-hook 'org-no-ellipsis-in-headlines) + ;; (add-hook 'org-mode-hook 'org-no-ellipsis-in-headlines) #+end_src **** Refile @@ -2205,17 +2204,22 @@ Support for sphinx style docstrings. :ID: db24f115-910d-4f9f-ba13-4dd9855c0b7d :END: #+begin_src emacs-lisp :tangle yes - (use-package ansi-color) + (use-package ansi-color + :config + (defun jupyter-ansi-color-apply-on-region (begin end) + (ansi-color-apply-on-region begin end t))) + (use-package popup) (use-package jupyter - :config - (require 'jupyter-python) - (require 'jupyter-julia) - ;(require 'jupyter-wolfram-language) - (org-babel-do-load-languages - 'org-babel-load-languages - '((python . t) - (jupyter . t))) - (setq jupyter-eval-short-result-display-function 'popup-tip)) + :config + (require 'jupyter-python) + (require 'jupyter-julia) + ;(require 'jupyter-wolfram-language) + (org-babel-do-load-languages + 'org-babel-load-languages + '((python . t) + (jupyter . t))) + (setq jupyter-eval-use-overlays t) + (setq jupyter-eval-short-result-display-function #'popup-tip)) #+end_src diff --git a/dots/home/.emacs b/dots/home/.emacs index 9ac4b04..5c7ccaa 100644 --- a/dots/home/.emacs +++ b/dots/home/.emacs @@ -11,5 +11,6 @@ (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage)) (straight-use-package 'use-package) -(straight-use-package 'org) +(straight-use-package '(org :host github :repo "yantar92/org" :branch "feature/org-fold-universal-core" + :files (:defaults "contrib/lisp/*.el"))) (org-babel-load-file "~/.emacs.d/emacs.org") diff --git a/dots/xournal/config b/dots/xournal/config index 3077ddc..9b25d07 100644 --- a/dots/xournal/config +++ b/dots/xournal/config @@ -11,11 +11,11 @@ initial_zoom=269.67 # maximize the window at startup (true/false) window_maximize=false # start in full screen mode (true/false) -window_fullscreen=true +window_fullscreen=false # the window width in pixels (when not maximized) -window_width=1920 +window_width=2560 # the window height in pixels -window_height=2160 +window_height=1440 # scrollbar step increment (in pixels) scrollbar_speed=30 # the step increment in the zoom dialog box