(General)~loads of commits, getting ready to port dotfiles to another machine

This commit is contained in:
2021-07-06 19:02:25 +01:00
parent 9fa164dc11
commit 325d8b4ef7
10 changed files with 168 additions and 25 deletions

View File

@@ -1,3 +1,2 @@
alias clear clear;clear;
alias l ls -la alias l ls -la
alias d dired-other-frame . alias d dired-other-frame .

View File

@@ -316,6 +316,7 @@ Setup the evil package, with some opinionated keybindings:
"zC" #'hs-hide-level "zC" #'hs-hide-level
"'" #'evil-goto-mark "'" #'evil-goto-mark
"`" #'evil-goto-mark-line "`" #'evil-goto-mark-line
"C-w" #'evil-window-map
"gu" #'evil-upcase "gu" #'evil-upcase
"gU" #'evil-downcase) "gU" #'evil-downcase)
(general-def (general-def
@@ -537,8 +538,12 @@ helpful counterparts.
counsel-describe-function-function #'helpful-callable counsel-describe-function-function #'helpful-callable
counsel-describe-variable-function #'helpful-variable counsel-describe-variable-function #'helpful-variable
ivy-re-builders-alist '((swiper . ivy--regex-plus) ivy-re-builders-alist '((swiper . ivy--regex-plus)
(counsel-grep-or-swiper . ivy--regex-plus)
(counsel-rg . ivy--regex-plus) (counsel-rg . ivy--regex-plus)
(t . orderless-ivy-re-builder))) (t . orderless-ivy-re-builder)))
(with-eval-after-load "org-mode"
(general-def
[remap org-goto] #'counsel-org-goto))
(counsel-mode)) (counsel-mode))
#+end_src #+end_src
**** Ivy Core **** Ivy Core
@@ -1325,9 +1330,15 @@ integrate it into my workflow just a bit better.
"Sync mail via mbsync." "Sync mail via mbsync."
(interactive) (interactive)
(start-process-shell-command "" nil "mbsync -a")) (start-process-shell-command "" nil "mbsync -a"))
(defun +mail/trash-junk ()
"Delete any mail in junk"
(interactive)
(start-process-shell-command "" nil "notmuch search --output=files --format=text0 tag:deleted tag:spam tag:trash tag:junk | xargs -r0 rm"))
:custom :custom
(notmuch-show-logo nil) (notmuch-show-logo nil)
(notmuch-search-oldest-first nil)
(notmuch-hello-sections '(notmuch-hello-insert-saved-searches notmuch-hello-insert-alltags)) (notmuch-hello-sections '(notmuch-hello-insert-saved-searches notmuch-hello-insert-alltags))
(notmuch-archive-tags '("-inbox" "-unread" "+archive"))
(mail-signature +mail/signature) (mail-signature +mail/signature)
(mail-default-directory +mail/local-dir) (mail-default-directory +mail/local-dir)
(mail-source-directory +mail/local-dir) (mail-source-directory +mail/local-dir)
@@ -1338,6 +1349,8 @@ integrate it into my workflow just a bit better.
;; sync mail after refresh ;; sync mail after refresh
(advice-add #'notmuch-poll-and-refresh-this-buffer :before (advice-add #'notmuch-poll-and-refresh-this-buffer :before
#'+mail/sync-mail) #'+mail/sync-mail)
(advice-add #'notmuch-poll-and-refresh-this-buffer :after
#'+mail/trash-junk)
(with-eval-after-load "evil-collection" (with-eval-after-load "evil-collection"
(evil-collection-notmuch-setup))) (evil-collection-notmuch-setup)))
#+end_src #+end_src
@@ -1716,6 +1729,7 @@ Along with that I setup the package =proced-narrow= which allows
further filtering of the process list. further filtering of the process list.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package proced-narrow (use-package proced-narrow
:straight t
:after proced :after proced
:general :general
(general-def (general-def
@@ -2009,6 +2023,13 @@ use the current buffer?) but it works out.
:keymaps 'pdf-view-mode-map :keymaps 'pdf-view-mode-map
"M-g" #'pdfgrep)) "M-g" #'pdfgrep))
#+end_src #+end_src
** SQL
#+begin_src emacs-lisp
(use-package sql
:straight nil
:init
(setq sql-display-sqli-buffer-function nil))
#+end_src
** Ada ** Ada
Check out [[file:ada-mode.el][ada-mode*]], my custom ada-mode that replaces the default one. Check out [[file:ada-mode.el][ada-mode*]], my custom ada-mode that replaces the default one.
This mode just colourises stuff, and uses eglot to do the heavy This mode just colourises stuff, and uses eglot to do the heavy
@@ -2124,14 +2145,7 @@ vanilla =org-goto=. Also records for auto insertion.
"#+latex: \clearpage\n" "#+latex: \clearpage\n"
"#+toc: headlines\n" "#+toc: headlines\n"
"#+latex: \clearpage\n\n" "#+latex: \clearpage\n\n"
"* " _))) "* " _))))
:config
(with-eval-after-load "swiper"
(defun +org/swiper-goto ()
(interactive)
(counsel-grep-or-swiper "^\\* "))
(general-def
[remap org-goto] #'+org/swiper-goto)))
#+end_src #+end_src
*** Org Core Bindings *** Org Core Bindings
Some bindings for org mode. Some bindings for org mode.
@@ -2202,13 +2216,6 @@ look is nice to have.
(use-package org-fragtog (use-package org-fragtog
:hook (org-mode-hook . org-fragtog-mode)) :hook (org-mode-hook . org-fragtog-mode))
#+end_src #+end_src
*** Org pretty tables
Make the default ASCII tables of org mode pretty with
#+begin_src emacs-lisp
(use-package org-pretty-table
:straight (org-pretty-table-mode :type git :host github :repo "Fuco1/org-pretty-table")
:hook (org-mode-hook . org-pretty-table-mode))
#+end_src
*** Org pretty tags *** Org pretty tags
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package org-pretty-tags (use-package org-pretty-tags
@@ -2381,6 +2388,25 @@ this.
(clang-format-region (region-beginning) (region-end)) (clang-format-region (region-beginning) (region-end))
(clang-format-buffer)))) (clang-format-buffer))))
#+end_src #+end_src
** Racket
A scheme with lots of stuff inside it. Using it for a language design
book so it's useful to have some Emacs binds for it.
#+begin_src emacs-lisp
(use-package racket-mode
:straight t
:hook (racket-mode-hook . racket-xp-mode)
:display
("\\*Racket.*"
(display-buffer-at-bottom)
(window-height . 0.25))
:general
(local-leader
:keymaps 'racket-mode-map
"r" #'racket-run
"i" #'racket-repl
"sr" #'racket-send-region
"sd" #'racket-send-definition))
#+end_src
** CSharp ** CSharp
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package csharp-mode (use-package csharp-mode
@@ -2488,7 +2514,7 @@ Here I configure the REPL for Haskell via the
(leader (leader
"th" #'+shell/toggle-haskell-repl) "th" #'+shell/toggle-haskell-repl)
:display :display
("\\*haskell\\*" ("\\*haskell.**\\*"
(display-buffer-at-bottom) (display-buffer-at-bottom)
(window-height . 0.25)) (window-height . 0.25))
:config :config

View File

@@ -19,6 +19,9 @@ super + a
dmenu_run dmenu_run
super + e super + e
$HOME/.local/scripts/emacs_curl;
super + E
$HOME/.emacs_anywhere/bin/run $HOME/.emacs_anywhere/bin/run
super + s super + s
@@ -68,6 +71,23 @@ XF86AudioMute
kill -43 $(pidof dwmblocks); \ kill -43 $(pidof dwmblocks); \
pactl set-sink-mute 41 toggle; pactl set-sink-mute 41 toggle;
Pause
playerctl --player=spotify play-pause
Print
conn=$(nmcli | grep "connected to" | sed 's/.*connected to //g' | head -1); \
nmcli c down "$conn"; \
notify-send -u low "Turning off wifi"; \
nmcli c up "$conn"; \
notify-send -u low "Reset " $conn;
Scroll_Lock
conn=$(nmcli | grep "connected to" | sed 's/.*connected to //g' | head -1); \
nmcli c down "$conn"; \
notify-send -u low "Turning off wifi"; \
nmcli c up "$conn"; \
notify-send -u low "Reset " $conn;
XF86MonBrightness{Down,Up} XF86MonBrightness{Down,Up}
light -{U,A} 15; \ light -{U,A} 15; \
notify-send -u low "Brightness: $(light)"; notify-send -u low "Brightness: $(light)";

View File

@@ -0,0 +1,4 @@
#!/bin/sh
x=`xclip -o`
emacsclient --socket-name=MAIN -c --alternate-editor=emacs --eval "(eww \"$x\")";

View File

@@ -1,3 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo  "$(playerctl --player=spotify metadata title)" title=$(playerctl --player=spotify metadata title)
echo "${title::40}"

View File

@@ -1,5 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
sinks="$(pactl list sinks)" sinks="$(pactl list sinks)"
vol="$(echo "$sinks" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")" vol="$(echo "$sinks" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")"
mute="$(echo "$sinks" | grep "Mute: " | sed "s/.*Mute: //g")"
echo " $vol%" case "$mute" in
"no")
printf "";;
"yes")
printf "";;
esac
echo " $vol%"

88
Scripts/.local/scripts/umpv Executable file
View File

@@ -0,0 +1,88 @@
#!/usr/bin/env python3
"""
This script emulates "unique application" functionality on Linux. When starting
playback with this script, it will try to reuse an already running instance of
mpv (but only if that was started with umpv). Other mpv instances (not started
by umpv) are ignored, and the script doesn't know about them.
This only takes filenames as arguments. Custom options can't be used; the script
interprets them as filenames. If mpv is already running, the files passed to
umpv are appended to mpv's internal playlist. If a file does not exist or is
otherwise not playable, mpv will skip the playlist entry when attempting to
play it (from the GUI perspective, it's silently ignored).
If mpv isn't running yet, this script will start mpv and let it control the
current terminal. It will not write output to stdout/stderr, because this
will typically just fill ~/.xsession-errors with garbage.
mpv will terminate if there are no more files to play, and running the umpv
script after that will start a new mpv instance.
Note: you can supply custom mpv path and options with the MPV environment
variable. The environment variable will be split on whitespace, and the
first item is used as path to mpv binary and the rest is passed as options
_if_ the script starts mpv. If mpv is not started by the script (i.e. mpv
is already running), this will be ignored.
"""
import sys
import os
import socket
import errno
import subprocess
import fcntl
import stat
import string
files = sys.argv[1:]
# this is the same method mpv uses to decide this
def is_url(filename):
parts = filename.split("://", 1)
if len(parts) < 2:
return False
# protocol prefix has no special characters => it's an URL
allowed_symbols = string.ascii_letters + string.digits + '_'
prefix = parts[0]
return all(map(lambda c: c in allowed_symbols, prefix))
# make them absolute; also makes them safe against interpretation as options
def make_abs(filename):
if not is_url(filename):
return os.path.abspath(filename)
return filename
files = [make_abs(f) for f in files]
SOCK = os.path.join(os.getenv("HOME"), ".umpv_socket")
sock = None
try:
sock = socket.socket(socket.AF_UNIX)
sock.connect(SOCK)
except socket.error as e:
if e.errno == errno.ECONNREFUSED:
sock = None
pass # abandoned socket
elif e.errno == errno.ENOENT:
sock = None
pass # doesn't exist
else:
raise e
if sock:
# Unhandled race condition: what if mpv is terminating right now?
for f in files:
# escape: \ \n "
f = f.replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n")
f = "\"" + f + "\""
sock.send(("raw loadfile " + f + " append\n").encode("utf-8"))
else:
# Let mpv recreate socket if it doesn't already exist.
opts = (os.getenv("MPV") or "mpv").split()
opts.extend(["--no-terminal", "--force-window", "--input-ipc-server=" + SOCK,
"--"])
opts.extend(files)
subprocess.check_call(opts)

View File

@@ -21,4 +21,3 @@ export XDG_RUNTIME_DIR=/run/user/`id -u`
# Run some programs # Run some programs
/usr/bin/pfetch /usr/bin/pfetch
eval `ssh-agent`; eval `ssh-agent`;
ssh-add ~/.ssh/id_rsa

View File

@@ -9,7 +9,7 @@ xrandr --output HDMI1 --primary;
xrandr --output eDP1 --right-of HDMI1; xrandr --output eDP1 --right-of HDMI1;
$(xss-lock --transfer-sleep-lock -- lock) & $(xss-lock --transfer-sleep-lock -- lock) &
feh --randomize --bg-scale $HOME/Pictures/Backgrounds & $HOME/.local/scripts/background &
systemctl --user start emacs & systemctl --user start emacs &
$HOME/.local/scripts/status/music_update_bar & $HOME/.local/scripts/status/music_update_bar &