mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-25 09:36:14 +01:00
Add new xmonad command for opening Emacs vterm
Signed-off-by: MagicRB <richard@brezak.sk>
This commit is contained in:
parent
689faa22e5
commit
cb2f0f93a0
|
@ -30,3 +30,19 @@ Disable window changing using the mouse, it saves me from accidental switches.
|
|||
(funcall fun event))))
|
||||
(advice-add 'mouse-set-region :around 'cv/mouse-set-region)
|
||||
#+end_src
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defun maybe-delete-frame-buffer (frame)
|
||||
"When a dedicated FRAME is deleted, also kill its buffer.
|
||||
A dedicated frame contains a single window whose buffer is not
|
||||
displayed anywhere else."
|
||||
(let ((windows (window-list frame)))
|
||||
(when (eq 1 (length windows))
|
||||
(let ((buffer (window-buffer (car windows))))
|
||||
(when (eq 1 (length (get-buffer-window-list buffer nil t)))
|
||||
(when (frame-parameter frame 'unsplittable)
|
||||
(with-current-buffer buffer
|
||||
(when (equal major-mode #'vterm-mode) (message "VTERM") (kill-process (get-buffer-process buffer)))
|
||||
(kill-buffer buffer))))))))
|
||||
(add-to-list 'delete-frame-functions #'maybe-delete-frame-buffer)
|
||||
#+end_src
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
{-# LANGUAGE BlockArguments
|
||||
#-}
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
|
||||
import XMonad
|
||||
import Data.Monoid
|
||||
|
@ -40,6 +41,8 @@ import XMonad.Actions.UpdatePointer
|
|||
import XMonad.Actions.FloatKeys
|
||||
import XMonad.Actions.Warp
|
||||
import XMonad.Actions.CopyWindow
|
||||
import XMonad.StackSet (Workspace, integrate', stack)
|
||||
import Foreign.C.String (peekCString)
|
||||
|
||||
import Control.Monad
|
||||
|
||||
|
@ -87,6 +90,21 @@ getCurrentLayout :: X String
|
|||
getCurrentLayout =
|
||||
gets windowset <&> description . W.layout . W.workspace . W.current
|
||||
|
||||
workspacesGrouped :: X [(WorkspaceId, Window, String)]
|
||||
workspacesGrouped = withDisplay \dpy -> do
|
||||
ws <- gets windowset
|
||||
let x = map W.workspace (W.current ws : W.visible ws)
|
||||
let y = W.hidden ws
|
||||
mapM (\v -> do
|
||||
let windows = getWorkspaceWindows v
|
||||
mapM (\win -> getWindowTitle win dpy <&> \title -> (W.tag v, win, title)) windows) (x ++ y) <&> concat
|
||||
|
||||
getWorkspaceWindows :: Workspace i l Window -> [Window]
|
||||
getWorkspaceWindows w = integrate' $ stack w
|
||||
|
||||
getWindowTitle :: Window -> Display -> X String
|
||||
getWindowTitle w d = liftIO $ getTextProperty d w wM_NAME >>= (peekCString . tp_value)
|
||||
|
||||
modm :: KeyMask
|
||||
modm = mod4Mask
|
||||
|
||||
|
@ -94,11 +112,9 @@ modm = mod4Mask
|
|||
-- Key bindings. Add, modify or remove key bindings here.
|
||||
--
|
||||
myKeymap c =
|
||||
-- launch a terminal
|
||||
[ ("M-S-<Return>", spawn "alacritty")
|
||||
|
||||
[
|
||||
-- launch dmenu
|
||||
, ("M-e", spawn "dmenu_run")
|
||||
("M-e", spawn "dmenu_run")
|
||||
|
||||
-- close focused window
|
||||
, ("M-S-q", io exitSuccess)
|
||||
|
@ -173,16 +189,20 @@ myKeymap c =
|
|||
, ("<XF86MonBrightnessUp>" , spawn "brightnessctl set +5%")
|
||||
, ("<XF86MonBrightnessDown>" , spawn "brightnessctl set 5%-")
|
||||
|
||||
, ("<XF86AudioPlay>" , spawn "notify -t 5000 \"Music: Play\"" >> spawn "playerctl play-pause")
|
||||
, ("<XF86AudioStop>" , spawn "notify -t 5000 \"Music: Stop\"" >> spawn "playerctl stop")
|
||||
, ("<XF86AudioPrev>" , spawn "notify -t 5000 \"Music: Prev\"" >> spawn "playerctl previous")
|
||||
, ("<XF86AudioNext>" , spawn "notify -t 5000 \"Music: Next\"" >> spawn "playerctl next")
|
||||
, ("<XF86AudioPlay>" , spawn "notify-send -t 5000 \"Music: Play\"" >> spawn "playerctl play-pause")
|
||||
, ("<XF86AudioStop>" , spawn "notify-send -t 5000 \"Music: Stop\"" >> spawn "playerctl stop")
|
||||
, ("<XF86AudioPrev>" , spawn "notify-send -t 5000 \"Music: Prev\"" >> spawn "playerctl previous")
|
||||
, ("<XF86AudioNext>" , spawn "notify-send -t 5000 \"Music: Next\"" >> spawn "playerctl next")
|
||||
|
||||
, ("<XF86TouchpadToggle>" , spawn "toggle-touchpad")
|
||||
|
||||
, ("M-<F1>", spawn "auxmenu")
|
||||
, ("M-<F2>", spawn "emacsclient -cn")
|
||||
, ("M-S-<Return>", spawn "emacs-vterm")
|
||||
, ("M-<Return>", spawn "alacritty")
|
||||
|
||||
, ("M-<F11>", withDisplay $ \dpy -> withFocused $ \window -> toggleFullscreen dpy window)
|
||||
, ("M-<F9>", (workspacesGrouped >>= \ws -> (liftIO . print $ ws)))
|
||||
]
|
||||
++
|
||||
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
auxmenu =
|
||||
pkgs.writeShellScriptBin "auxmenu"
|
||||
(builtins.readFile ./scripts/auxmenu.sh);
|
||||
emacs-vterm =
|
||||
pkgs.writeShellScriptBin "emacs-vterm"
|
||||
(builtins.readFile ./scripts/emacs-vterm.sh);
|
||||
in
|
||||
pkgs.buildEnv {
|
||||
name = "xmonad-runenv";
|
||||
|
@ -43,6 +46,7 @@
|
|||
reload
|
||||
toggle-touchpad
|
||||
auxmenu
|
||||
emacs-vterm
|
||||
libnotify
|
||||
x11_ssh_askpass
|
||||
];
|
||||
|
|
1
home-manager/modules/xmonad/scripts/emacs-vterm.sh
Normal file
1
home-manager/modules/xmonad/scripts/emacs-vterm.sh
Normal file
|
@ -0,0 +1 @@
|
|||
emacsclient -cn --eval "(progn (vterm t) (set-frame-parameter nil 'unsplittable t) (set-window-dedicated-p (selected-window) t))"
|
Loading…
Reference in a new issue