257 lines
6.7 KiB
EmacsLisp
257 lines
6.7 KiB
EmacsLisp
|
|
|
|
|
|
|
|
;;; relative line numbers
|
|
(setq display-line-numbers 'relative)
|
|
|
|
|
|
;;; set my org directory
|
|
(setq org-directory "~/work/things/org")
|
|
|
|
|
|
;;; set my name and email
|
|
(setq user-full-name "Sebastian Moser"
|
|
user-mail-address "c2vi.dev@gmail.com")
|
|
|
|
|
|
;;; theme
|
|
(setq doom-theme 'doom-one)
|
|
|
|
|
|
;;; C-p to be M-x
|
|
(map! "C-p" #'execute-extended-command)
|
|
;;(map! :leader "a" #'execute-extended-command)
|
|
;;(map! :nv ":" #'execute-extended-command)
|
|
(after! evil
|
|
;;(map! :nv ":" #'execute-extended-command)
|
|
(map! :gnv "C-p" #'execute-extended-command)
|
|
)
|
|
|
|
|
|
|
|
;;; projectile find file - quick switcher
|
|
(after! evil
|
|
(map! :gnv "C-e" #'projectile-find-file)
|
|
)
|
|
(after! 'better-jumper
|
|
(map! :gnv "C-i" #'projectile-find-file)
|
|
)
|
|
(with-eval-after-load 'projectile
|
|
(add-to-list 'projectile-globally-ignored-directories "node_modules")
|
|
(add-to-list 'projectile-globally-ignored-directories ".obsidian")
|
|
(setq projectile-indexing-method 'native)
|
|
)
|
|
|
|
|
|
|
|
;;; obsidian
|
|
(after! obsidian
|
|
(setq obsidian-directory "~/work/things"
|
|
obsidian-inbox-directory "semi-public"
|
|
markdown-enable-wiki-links t
|
|
)
|
|
(global-obsidian-mode t)
|
|
)
|
|
|
|
|
|
|
|
|
|
;;; clipboard
|
|
(after! evil
|
|
(setq interprogram-cut-function nil
|
|
interprogram-paste-function nil)
|
|
)
|
|
(defun my/clipboard-copy (beg end)
|
|
"Copy region to the OS clipboard (bypassing the kill-ring)."
|
|
(interactive "r")
|
|
(let ((text (buffer-substring-no-properties beg end))
|
|
(inhibit-message t))
|
|
(gui-select-text text)
|
|
(deactivate-mark)
|
|
(when (called-interactively-p 'any)
|
|
(message "Copied to clipboard: %d chars" (length text)))))
|
|
|
|
(defun my/clipboard-paste ()
|
|
"Paste from the OS clipboard, replacing the region if active."
|
|
(interactive)
|
|
(let ((text (gui-get-selection 'CLIPBOARD)))
|
|
(unless text
|
|
(user-error "OS clipboard is empty"))
|
|
(when (use-region-p)
|
|
(delete-region (region-beginning) (region-end)))
|
|
(insert-for-yank text)))
|
|
(map! :v "C-c" #'my/clipboard-copy
|
|
:v "C-v" #'my/clipboard-paste
|
|
:i "C-v" #'my/clipboard-paste) ; insert-state paste, terminal-style
|
|
|
|
|
|
|
|
;;; in buffer completions
|
|
(setq tab-always-indent 'complete)
|
|
(after! corfu
|
|
; possible: basic, initials, orderless, partial-completion substring, flex
|
|
(setq completion-styles '(orderless flex partial-completion substring))
|
|
(setq corfu-cycle t
|
|
corfu-preview-current nil
|
|
corfu-min-width 20
|
|
corfu-on-exact-match 'insert
|
|
corfu-quit-no-match t
|
|
corfu-quit-at-boundary t
|
|
corfu-popupinfo-delay '(1.25 . 0.5))
|
|
(corfu-popupinfo-mode 1)
|
|
;; history-based sorting, persisted across restarts
|
|
(corfu-history-mode 1)
|
|
(after! savehist
|
|
(add-to-list 'savehist-additional-variables 'corfu-history)))
|
|
|
|
|
|
|
|
;;; C-i to pick first completion thing
|
|
(after! corfu
|
|
(defun my/corfu-insert-first ()
|
|
"Insert the first candidate immediately."
|
|
(interactive)
|
|
(corfu-next)
|
|
(corfu-insert)
|
|
)
|
|
(map! :map corfu-map
|
|
"<insert-state> C-i" #'my/corfu-insert-first
|
|
)
|
|
)
|
|
|
|
|
|
;;; better eval mappings
|
|
(map! :leader "m e" #'eval-last-sexp)
|
|
(map! :leader "m r" #'eval-print-last-sexp)
|
|
|
|
|
|
|
|
;;;; font/zoom
|
|
(setq doom-font (font-spec
|
|
;:family "Hack Mono"
|
|
:size 23 :weight 'regular))
|
|
|
|
|
|
;;; have authinfo file in my $SECRETS_DIR
|
|
(setq auth-sources '("~/secrets/authinfo"))
|
|
|
|
|
|
|
|
;;; empv
|
|
(after! empv
|
|
(customize-set-variable 'empv-subsonic-username "c2vi")
|
|
(customize-set-variable 'empv-subsonic-url "https://tunes.c2vi.dev")
|
|
(customize-set-variable 'empv-subsonic-password (f-read-text "~/secrets/tunes-password"))
|
|
)
|
|
|
|
|
|
|
|
;;; supersonic
|
|
(after! supersonic
|
|
(customize-set-variable 'supersonic-host "https://tunes.c2vi.dev")
|
|
)
|
|
|
|
|
|
;;; emms
|
|
(use-package! emms
|
|
:config
|
|
(emms-all) ;; Loads stable EMMS features
|
|
(setq emms-source-file-default-directory "~/work/music/"
|
|
emms-player-list '(emms-player-vlc))
|
|
)
|
|
|
|
;;; infrasonic
|
|
(use-package! infrasonic)
|
|
(defvar my-subsonic-client
|
|
(infrasonic-make-client :url "tunes.c2vi.dev")
|
|
)
|
|
(defun my-play-playlist (playlist-id)
|
|
"Fetch a Subsonic playlist by PLAYLIST-ID using infrasonic.el and load it into EMMS."
|
|
(interactive "sEnter Subsonic Playlist ID: ")
|
|
(message "Fetching Subsonic playlist %s..." playlist-id)
|
|
|
|
(let* (
|
|
(playlist-id "6I9sKLo2NfnyzdtShKwreO")
|
|
(playlist (infrasonic-get-playlist
|
|
my-subsonic-client
|
|
playlist-id
|
|
))
|
|
(entries (cdr (assoc 'entry playlist)))
|
|
(track-count 0)
|
|
)
|
|
|
|
(dolist (track entries)
|
|
(let* (
|
|
(track-id (cdr (assoc 'id track)))
|
|
(stream-url (infrasonic-get-stream-url my-subsonic-client track-id))
|
|
)
|
|
;(emms-add-url stream-url)
|
|
;(emms-add-track
|
|
;(emms-track 'url stream-url))
|
|
;(setq track-count (1+ track-count))
|
|
;(emms-playlist-select-first)
|
|
;(emms-start)
|
|
)
|
|
)
|
|
entries
|
|
(infrasonic-get-stream-url my-subsonic-client "7id7XzpofiHmnJPqfORA0O")
|
|
)
|
|
|
|
(lambda (playlist-data)
|
|
;; This callback executes on a successful API response
|
|
(let*
|
|
(
|
|
|
|
;; Ensure EMMS is ready and clear old queue if desired
|
|
(emms-playlist-ensure-playlist-buffer)
|
|
|
|
;; 3. Loop through every track returned by the API
|
|
(dolist (track entries)
|
|
(let* ((track-id (plist-get track :id))
|
|
;; Generate the authenticated streaming URL using infrasonic
|
|
(stream-url (infrasonic-stream-url client track-id)))
|
|
|
|
;; 4. Insert the URL track directly into the EMMS track ecosystem
|
|
(emms-add-track
|
|
(emms-track 'url stream-url))
|
|
(setq track-count (1+ track-count))))
|
|
|
|
(message "Successfully loaded %d tracks into EMMS from playlist!" track-count)
|
|
|
|
;; 5. Start playback immediately if nothing is playing
|
|
(unless emms-player-playing-p
|
|
(emms-playlist-select-first)
|
|
(emms-start))))
|
|
|
|
;; Error callback handling
|
|
(lambda (error-data)
|
|
(error "Infrasonic playlist fetch failed: %S" error-data)))
|
|
)
|
|
(defun my-play-work () (interactive)(my-play-playlist "6I9sKLo2NfnyzdtShKwreO"))
|
|
|
|
|
|
|
|
|
|
|
|
;;; scratch
|
|
(defun my/scratch ()
|
|
(lookup-key corfu-map (kbd "C-u"))
|
|
(lookup-key corfu-map (kbd "C-i"))
|
|
(define-key corfu-map (kbd "C-i") 'my/corfu-insert-first)
|
|
|
|
(plz 'get "https://tunes.c2vi.dev")
|
|
(infrasonic-get-playlist
|
|
my-subsonic-client
|
|
"6I9sKLo2NfnyzdtShKwreO"
|
|
)
|
|
(infrasonic-ping my-subsonic-client)
|
|
(infrasonic-api-call my-subsonic-client "ping" nil (lambda () (message "hi")) (lambda (e) (message e)))
|
|
(shell-command-to-string "curl https://tunes.c2vi.dev")
|
|
|
|
(emms-play-url "https://tunes.c2vi.dev/rest/stream.view?u=c2vi&t=618e0d04594b0e72c865d7989b6dad38&s=5b08708ee057af16caab55db98c3dd03&v=1.16.1&c=infrasonic&f=json&id=7id7XzpofiHmnJPqfORA0O")
|
|
|
|
|
|
|
|
)
|