stumpwm/applications.lisp @ 4ffd09c459f6
More
author |
Steve Losh <steve@stevelosh.com> |
date |
Thu, 28 Aug 2025 15:30:29 -0400 |
parents |
2e41ef790dc8 |
children |
(none) |
(in-package :stumpwm-user)
(defcommand igv () ()
(run-or-raise "igv" '(:class "org-broad-igv-ui-Main")))
(defcommand spotify () ()
(run-or-raise "spotify" '(:class "Spotify")))
(defcommand zoom-meeting () ()
(run-or-raise "echom 'No meeting running.'" '(:class "zoom" :title "Meeting")))
(defcommand files () ()
(run-shell-command "open $HOME"))
(defcommand browser () ()
(run-or-raise "firefox" '(:class "firefox")))
(defcommand vlc () ()
(run-or-raise "vlc" '(:class "vlc")))
(defcommand terminal () ()
(run-shell-command (format nil "st -f 'Ubuntu Mono:size=~D'" *terminal-font-size*)))
(defcommand terminal-in (path) ((:string "Working directory: "))
(run-shell-command
(format nil "st -f 'Ubuntu Mono:size=~D' env -C '~A' fish" ; todo actually escape this
*terminal-font-size* path)))
(defun window-pid (&optional (window (current-window)))
(let ((window-id (xlib:window-id (window-xwin (current-window)))))
(first (xlib:get-property (window-xwin window) :_net_wm_pid))))
(defclass* process ()
(pid command-line cwd children))
(defmethod print-object ((o process) s)
(print-unreadable-object (o s :type t)
(format s "~D ~S (~D child(ren))" (pid o) (command-line o) (length (children o)))))
(defun process-info (pid)
(make-instance 'process
:pid pid
:command-line (_ (format nil "/proc/~D/cmdline" pid)
alexandria:read-file-into-string
(str:split #\nul _ :end (1- (length _))))
:cwd (sb-posix:readlink (format nil "/proc/~D/cwd" pid))
:children (gathering
(dolist (thread (list-directory (format nil "/proc/~D/task" pid)))
(dolist (child (_ thread
namestring
(format nil "~A/children" _)
alexandria:read-file-into-string
(str:split #\space _ :omit-nulls t)
(mapcar #'parse-integer _)))
(gather (process-info child)))))))
(defun dwim-cwd (&optional (window (current-window)))
(recursively ((proc (process-info (window-pid window)))
(depth 0))
(or (first (mapcar (lambda (child)
(recur child (1+ depth)))
(children proc)))
(cwd proc))))
(defcommand terminal-here () ()
(terminal-in (dwim-cwd)))
(defcommand terminal-apl () ()
(run-shell-command "st -f 'BQN386 Unicode:style=Regular:size=12'"))
(defcommand gcontrol () ()
(run-or-raise "gcontrol" '(:class "Gnome-control-center")))
(defcommand papers () ()
(run-or-raise "jabref" '(:class "org.jabref.gui.MainApplication")))