Compare commits
5 Commits
69f82668f1
...
9f32648119
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f32648119 | ||
|
|
9eb7582eff | ||
|
|
7337d56786 | ||
|
|
93be55b00a | ||
|
|
711cdf555b |
@@ -137,28 +137,72 @@ lambda with the first form of the lambda being (INTERACTIVE)."
|
|||||||
#+end_src
|
#+end_src
|
||||||
** Clean buffer list
|
** Clean buffer list
|
||||||
If you've got a particularly long running Emacs instance, as I usually
|
If you've got a particularly long running Emacs instance, as I usually
|
||||||
do, sometimes you just want to clean all those scratch and temporary
|
do, sometimes you want to clean it all up. Perhaps all of the buffers
|
||||||
buffers up. Here I define a function which kills all buffers except
|
or just the ones in your current project. Here I define a function
|
||||||
for those which have a name in ~clean-buffers-keep~.
|
which allows you to do so - ~clean-buffers~.
|
||||||
|
|
||||||
|
By default, it will kill all buffers associated with the directory of
|
||||||
|
your current buffer. Using ~C-u~ will provide a list of directories
|
||||||
|
for buffers available, which you can select from. ~C-u C-u~ will kill
|
||||||
|
all buffers period.
|
||||||
|
|
||||||
|
Please note ~clean-buffers-keep~, which defines a list of buffers that
|
||||||
|
must be preserved in any form of the operation above.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(defconst clean-buffers-keep
|
(defconst clean-buffers-keep
|
||||||
(list "config.org" "*scratch*"
|
(list "*scratch*" "*dashboard*"
|
||||||
"*dashboard*" "*Messages*"
|
"*Messages*" "*Warnings*"
|
||||||
"*Warnings*" "*eshell*"
|
"*eshell*" "*ChatGPT*")
|
||||||
"*ChatGPT*")
|
|
||||||
"List of buffer names to preserve.")
|
"List of buffer names to preserve.")
|
||||||
|
|
||||||
(defun clean-buffers ()
|
(defun --get-dir-or-project-dir (buffer)
|
||||||
|
(with-current-buffer buffer
|
||||||
|
(expand-file-name
|
||||||
|
(if (project-current)
|
||||||
|
(project-root (project-current))
|
||||||
|
default-directory))))
|
||||||
|
|
||||||
|
(defun --make-clean-buffer-alist ()
|
||||||
|
(cl-loop with assoc-list = nil
|
||||||
|
for buffer in (buffer-list)
|
||||||
|
for dir = (--get-dir-or-project-dir buffer)
|
||||||
|
if (assoc dir assoc-list #'string=)
|
||||||
|
do (setf (cdr (assoc dir assoc-list #'string=))
|
||||||
|
(cons buffer (cdr (assoc dir assoc-list #'string=))))
|
||||||
|
else do (setf assoc-list (cons (list dir buffer) assoc-list))
|
||||||
|
finally (return assoc-list)))
|
||||||
|
|
||||||
|
(defun clean-buffers (&optional arg)
|
||||||
"Kill all buffers except any with names in CLEAN-BUFFERS-KEEP."
|
"Kill all buffers except any with names in CLEAN-BUFFERS-KEEP."
|
||||||
(interactive)
|
(interactive "P")
|
||||||
(let ((should-not-kill
|
(let ((buffer-alist (--make-clean-buffer-alist))
|
||||||
#'(lambda (buf)
|
(items nil)
|
||||||
(member (buffer-name buf)
|
(should-not-kill
|
||||||
clean-buffers-keep))))
|
#'(lambda (buf) (member (buffer-name buf) clean-buffers-keep))))
|
||||||
(->> (buffer-list)
|
|
||||||
|
(cond
|
||||||
|
((null arg)
|
||||||
|
(let ((choice (completing-read "Choose directory to kill: "
|
||||||
|
(mapcar #'car buffer-alist)
|
||||||
|
nil t)))
|
||||||
|
(setq items (cdr (assoc choice buffer-alist #'string=)))))
|
||||||
|
((and (listp arg)
|
||||||
|
(eq 4 (car arg)))
|
||||||
|
(setq items
|
||||||
|
(thread-first (current-buffer)
|
||||||
|
(--get-dir-or-project-dir )
|
||||||
|
(assoc buffer-alist #'string=)
|
||||||
|
(cdr))))
|
||||||
|
((and (listp arg)
|
||||||
|
(eq 16 (car arg)))
|
||||||
|
(setq items (buffer-list))))
|
||||||
|
|
||||||
|
(message "[clean-buffers]: Cleaning %d buffers" (length items))
|
||||||
|
(if items
|
||||||
|
(thread-last items
|
||||||
(cl-remove-if should-not-kill)
|
(cl-remove-if should-not-kill)
|
||||||
(mapc #'kill-buffer))))
|
(mapc #'kill-buffer)))))
|
||||||
#+end_src
|
#+end_src
|
||||||
** Custom window management
|
** Custom window management
|
||||||
Emacs has a window management system unlike any other piece of
|
Emacs has a window management system unlike any other piece of
|
||||||
@@ -270,6 +314,27 @@ the PATH variable with the shell to avoid any silly issues.
|
|||||||
(when (member window-system '(mac ns x))
|
(when (member window-system '(mac ns x))
|
||||||
(exec-path-from-shell-initialize)))
|
(exec-path-from-shell-initialize)))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
** Reset font size
|
||||||
|
Font size is best left unfixed: depending on the display size and the
|
||||||
|
machine, I will usually need to adjust it so it looks just right.
|
||||||
|
This function sets the font size using both those variables. It is
|
||||||
|
also added to `enable-theme-functions` such that loading a theme will
|
||||||
|
forcefully adjust the font size.
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(defvar +oreo/font-size-alist
|
||||||
|
'((1920 140)
|
||||||
|
(2560 160)))
|
||||||
|
|
||||||
|
(defun +oreo/font-reset (&optional _)
|
||||||
|
(let ((font-size (or (car (alist-get (display-pixel-width) +oreo/font-size-alist))
|
||||||
|
(cadar +oreo/font-size-alist))))
|
||||||
|
(set-face-attribute 'default nil :height font-size)
|
||||||
|
(set-face-attribute 'mode-line nil :height font-size)))
|
||||||
|
|
||||||
|
(add-to-list 'enable-theme-functions #'+oreo/font-reset)
|
||||||
|
(add-to-list 'after-make-frame-functions #'+oreo/font-reset)
|
||||||
|
#+end_src
|
||||||
* Essential packages
|
* Essential packages
|
||||||
External and internal packages absolutely necessary for the rest of
|
External and internal packages absolutely necessary for the rest of
|
||||||
this configuration.
|
this configuration.
|
||||||
@@ -1560,8 +1625,8 @@ Here I setup dired with a few niceties
|
|||||||
:general
|
:general
|
||||||
(nmmap
|
(nmmap
|
||||||
:keymaps 'dired-mode-map
|
:keymaps 'dired-mode-map
|
||||||
"SPC" nil
|
"SPC" #'nil
|
||||||
"SPC ," nil
|
"SPC ," #'nil
|
||||||
"M-k" #'dired-prev-subdir
|
"M-k" #'dired-prev-subdir
|
||||||
"M-j" #'dired-next-subdir
|
"M-j" #'dired-next-subdir
|
||||||
"q" #'quit-window
|
"q" #'quit-window
|
||||||
@@ -1593,7 +1658,7 @@ Here I setup dired with a few niceties
|
|||||||
"&" #'dired-do-async-shell-command
|
"&" #'dired-do-async-shell-command
|
||||||
"{" #'dired-prev-marked-file
|
"{" #'dired-prev-marked-file
|
||||||
"}" #'dired-next-marked-file
|
"}" #'dired-next-marked-file
|
||||||
"%" nil
|
"%" #'nil
|
||||||
"%u" #'dired-upcase
|
"%u" #'dired-upcase
|
||||||
"%l" #'dired-downcase
|
"%l" #'dired-downcase
|
||||||
"%d" #'dired-flag-files-regexp
|
"%d" #'dired-flag-files-regexp
|
||||||
@@ -1605,7 +1670,7 @@ Here I setup dired with a few niceties
|
|||||||
"%R" #'dired-do-rename-regexp
|
"%R" #'dired-do-rename-regexp
|
||||||
"%S" #'dired-do-symlink-regexp
|
"%S" #'dired-do-symlink-regexp
|
||||||
"%&" #'dired-flag-garbage-files
|
"%&" #'dired-flag-garbage-files
|
||||||
"*" nil
|
"*" #'nil
|
||||||
"**" #'dired-mark-executables
|
"**" #'dired-mark-executables
|
||||||
"*/" #'dired-mark-directories
|
"*/" #'dired-mark-directories
|
||||||
"*@" #'dired-mark-symlinks
|
"*@" #'dired-mark-symlinks
|
||||||
@@ -2327,9 +2392,8 @@ playing.
|
|||||||
:general
|
:general
|
||||||
(app-leader
|
(app-leader
|
||||||
"e" #'empv-hydra/body)
|
"e" #'empv-hydra/body)
|
||||||
|
|
||||||
:init
|
:init
|
||||||
(setq empv-audio-dir (list (expand-file-name "~/Media/audio"))
|
(setq empv-audio-dir (list (expand-file-name "~/Media/music"))
|
||||||
empv-video-dir (list (expand-file-name "~/Media/videos")
|
empv-video-dir (list (expand-file-name "~/Media/videos")
|
||||||
(expand-file-name "~/Media/anime"))
|
(expand-file-name "~/Media/anime"))
|
||||||
empv-playlist-dir (expand-file-name "~/Media/playlists")
|
empv-playlist-dir (expand-file-name "~/Media/playlists")
|
||||||
@@ -2979,7 +3043,8 @@ felt good. Doom Emacs was very helpful here.
|
|||||||
'((emacs-lisp . t)
|
'((emacs-lisp . t)
|
||||||
(lisp . t)
|
(lisp . t)
|
||||||
(shell . t)
|
(shell . t)
|
||||||
(python . t))))
|
(python . t)
|
||||||
|
(C . t))))
|
||||||
#+end_src
|
#+end_src
|
||||||
*** Org Functionality
|
*** Org Functionality
|
||||||
Hooks, prettify-symbols and records for auto insertion.
|
Hooks, prettify-symbols and records for auto insertion.
|
||||||
@@ -3036,7 +3101,7 @@ write the code.
|
|||||||
"d" #'org-deadline
|
"d" #'org-deadline
|
||||||
"s" #'org-schedule
|
"s" #'org-schedule
|
||||||
"t" #'org-todo
|
"t" #'org-todo
|
||||||
"r" #'org-list-repair
|
"r" #'org-refile
|
||||||
"," #'org-priority
|
"," #'org-priority
|
||||||
"n" #'org-narrow-to-subtree
|
"n" #'org-narrow-to-subtree
|
||||||
"w" #'widen
|
"w" #'widen
|
||||||
@@ -3047,7 +3112,7 @@ write the code.
|
|||||||
"o" #'org-edit-special
|
"o" #'org-edit-special
|
||||||
"T" #'org-babel-tangle
|
"T" #'org-babel-tangle
|
||||||
"S" #'org-property-action
|
"S" #'org-property-action
|
||||||
"R" #'org-refile
|
"R" #'org-list-repair
|
||||||
"O" #'org-open-at-point-global)
|
"O" #'org-open-at-point-global)
|
||||||
|
|
||||||
(local-leader
|
(local-leader
|
||||||
@@ -3087,8 +3152,10 @@ a very tidy way to manage your time.
|
|||||||
org-agenda-start-with-entry-text-mode nil
|
org-agenda-start-with-entry-text-mode nil
|
||||||
org-agenda-span 'week
|
org-agenda-span 'week
|
||||||
org-agenda-custom-commands
|
org-agenda-custom-commands
|
||||||
'(("n" "Agenda and all TODOs" ((agenda "") (alltodo "")))
|
'(("n" "Agenda (no reading)" ((agenda "-reading") (alltodo "")))
|
||||||
("w" todo "WIP")))
|
("r" "Reading" agenda ""
|
||||||
|
((org-agenda-skip-function
|
||||||
|
(org-agenda-skip-entry-if 'regexp "reading.*"))))))
|
||||||
:config
|
:config
|
||||||
(evil-set-initial-state 'org-agenda-mode 'normal)
|
(evil-set-initial-state 'org-agenda-mode 'normal)
|
||||||
:general
|
:general
|
||||||
@@ -3442,7 +3509,7 @@ a regular expression which captures file names and digits
|
|||||||
:config
|
:config
|
||||||
(add-to-list 'compilation-error-regexp-alist-alist
|
(add-to-list 'compilation-error-regexp-alist-alist
|
||||||
`(fsan ,(rx (and
|
`(fsan ,(rx (and
|
||||||
line-start " #" digit " 0x" (1+ hex) " in "
|
line-start " #" (1+ digit) " 0x" (1+ hex) " in "
|
||||||
(1+ (or word "_")) " "
|
(1+ (or word "_")) " "
|
||||||
(group (seq (* any) (or ".c" ".cpp" ".h" ".hpp"))) ":"
|
(group (seq (* any) (or ".c" ".cpp" ".h" ".hpp"))) ":"
|
||||||
(group (+ digit))))
|
(group (+ digit))))
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
"NeoSolarized": { "branch": "master", "commit": "b94b1a9ad51e2de015266f10fdc6e142f97bd617" },
|
"NeoSolarized": { "branch": "master", "commit": "b94b1a9ad51e2de015266f10fdc6e142f97bd617" },
|
||||||
"lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" },
|
"lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" },
|
||||||
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
||||||
"telescope.nvim": { "branch": "master", "commit": "0294ae3eafe662c438addb8692d9c98ef73a983e" },
|
"telescope.nvim": { "branch": "master", "commit": "3a12a853ebf21ec1cce9a92290e3013f8ae75f02" },
|
||||||
"vim-tmux-navigator": { "branch": "master", "commit": "c45243dc1f32ac6bcf6068e5300f3b2b237e576a" }
|
"vim-tmux-navigator": { "branch": "master", "commit": "c45243dc1f32ac6bcf6068e5300f3b2b237e576a" }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,10 +81,10 @@ super + shift + Escape
|
|||||||
|
|
||||||
# Media
|
# Media
|
||||||
super + F{6,7,8}
|
super + F{6,7,8}
|
||||||
playerctl --player=spotify {previous,play-pause,next};
|
playerctl --player=mpv {previous,play-pause,next};
|
||||||
|
|
||||||
XF86Audio{Prev,Play,Next}
|
XF86Audio{Prev,Play,Next}
|
||||||
playerctl --player=spotify {previous,play-pause,next};
|
playerctl --player=mpv {previous,play-pause,next};
|
||||||
|
|
||||||
XF86Audio{Lower,Raise}Volume
|
XF86Audio{Lower,Raise}Volume
|
||||||
kill -42 $(pidof dwmblocks); \
|
kill -42 $(pidof dwmblocks); \
|
||||||
|
|||||||
@@ -13,9 +13,7 @@ if (len(argv) > 1):
|
|||||||
if (len(argv) > 2):
|
if (len(argv) > 2):
|
||||||
name = argv[2]
|
name = argv[2]
|
||||||
|
|
||||||
duration *= 3600
|
run(["notify-send", f"Starting alarm {name}, duration of {duration}s"])
|
||||||
|
|
||||||
print("Starting alarm '%s'" % name, "of duration %ds" % duration)
|
|
||||||
|
|
||||||
current = time()
|
current = time()
|
||||||
end = current + duration
|
end = current + duration
|
||||||
|
|||||||
4
Scripts/.local/scripts/data_waiting
Executable file
4
Scripts/.local/scripts/data_waiting
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
mem_left_kb=$(awk -F'[ ]*' '/Dirty/ { print $2 }' /proc/meminfo)
|
||||||
|
echo "$(date)": $(echo "$mem_left_kb / 1000" | bc -l)
|
||||||
64
Scripts/.local/scripts/kgrep
Executable file
64
Scripts/.local/scripts/kgrep
Executable file
@@ -0,0 +1,64 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import List, Dict
|
||||||
|
from subprocess import run, PIPE
|
||||||
|
|
||||||
|
def strip_comments(line: str):
|
||||||
|
if (line[0] == ';'):
|
||||||
|
return ""
|
||||||
|
elif (comment_start := line.find("#")) >= 0:
|
||||||
|
line = line[:comment_start]
|
||||||
|
return line.rstrip()
|
||||||
|
|
||||||
|
def parse_keybind(lines: List[str]):
|
||||||
|
keybind = lines[0]
|
||||||
|
commands = []
|
||||||
|
end = len(lines) - 1
|
||||||
|
for i, line in enumerate(lines[1:]):
|
||||||
|
if line.startswith(" "):
|
||||||
|
commands.append(line)
|
||||||
|
else:
|
||||||
|
end = i
|
||||||
|
break
|
||||||
|
end += 1
|
||||||
|
return keybind, commands, lines[end:]
|
||||||
|
|
||||||
|
def parse_all_keybinds(lines: list[str]) -> Dict[str, list[str]]:
|
||||||
|
binds = dict()
|
||||||
|
while len(lines) != 0:
|
||||||
|
binding, commands, lines = parse_keybind(lines)
|
||||||
|
binds[binding] = commands
|
||||||
|
return binds
|
||||||
|
|
||||||
|
def get_config_data(filepath: str):
|
||||||
|
with open(filepath, "r") as fp:
|
||||||
|
lines = fp.readlines()
|
||||||
|
lines = map(strip_comments, lines)
|
||||||
|
lines = filter(lambda x : x != "", lines)
|
||||||
|
bindings = parse_all_keybinds(list(lines))
|
||||||
|
return bindings
|
||||||
|
|
||||||
|
|
||||||
|
def dmenu(prompt: str, items: list) -> str:
|
||||||
|
return run(["dmenu", "-p", "Choose binding: "],
|
||||||
|
input="\n".join(items),
|
||||||
|
capture_output=True,
|
||||||
|
text=True).stdout.strip()
|
||||||
|
|
||||||
|
def get_keybind(keybinds: Dict[str, list[str]]) -> str:
|
||||||
|
return dmenu("Choose binding: ", list(keybinds.keys())).replace("\n", "")
|
||||||
|
|
||||||
|
def get_command(keybinds: Dict[str, list[str]]) -> str:
|
||||||
|
reverse_map = dict()
|
||||||
|
for key in keybinds:
|
||||||
|
value = keybinds[key]
|
||||||
|
if reverse_map.get(value) is not None:
|
||||||
|
continue
|
||||||
|
reverse_map[value] = key
|
||||||
|
return dmenu("Choose binding: ", list(reverse_map.keys())).replace("\n", "")
|
||||||
|
|
||||||
|
bindings = get_config_data("/home/oreo/.config/sxhkd/sxhkdrc")
|
||||||
|
choice = get_command(bindings)
|
||||||
|
|
||||||
|
print(choice, bindings[choice])
|
||||||
@@ -4,4 +4,4 @@ prev=$(notmuch count)
|
|||||||
mbsync -a
|
mbsync -a
|
||||||
notmuch new
|
notmuch new
|
||||||
new=$(notmuch count)
|
new=$(notmuch count)
|
||||||
notify-send "mail_fetch: Fetched $(echo $new - $prev | bc -l) mail"
|
notify-send "Fetched $(echo $new - $prev | bc -l) mail"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ processes="st btop
|
|||||||
emacsclient -c -a emacs
|
emacsclient -c -a emacs
|
||||||
$HOME/.local/scripts/browser
|
$HOME/.local/scripts/browser
|
||||||
steam
|
steam
|
||||||
|
discord
|
||||||
spotify"
|
spotify"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ Description=Run mail sync every hour
|
|||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnBootSec=1min
|
OnBootSec=1min
|
||||||
OnUnitActiveSec=3600
|
OnUnitActiveSec=1800
|
||||||
Unit=mail.service
|
Unit=mail.service
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
|||||||
Reference in New Issue
Block a user