Trying to work on emacs/stumpwm config.

This commit is contained in:
Lord_Devi 2024-07-17 23:25:24 -04:00
parent e571440775
commit a6d7878229
7 changed files with 370 additions and 23 deletions

View file

@ -2661,7 +2661,8 @@ fonts and their attributes as determined by any context you care to.
(set-face-attribute 'default nil
;;:font "TerminessTTF Nerd Font Mono"
;;:font "JetBrainsMono Nerd Font Mono"
:font "Iosevka Comfy"
;;:font "Iosevka Comfy"
:font "Lexend Nerd Font"
:width 'regular
:weight 'regular
:height 140)
@ -2677,9 +2678,10 @@ fonts and their attributes as determined by any context you care to.
;; Set variable pitch face.
(set-face-attribute 'variable-pitch nil
:font "Iosevka Comfy Duo"
;;:font "Iosevka Comfy Duo"
;;:font "Iosevka Comfy"
;;:font "TerminessTTF Nerd Font"
:font "Lexend Nerd Font"
:width 'regular
:weight 'regular
:height 1.0)
@ -3122,9 +3124,9 @@ please.
(setup (:straight org-superstar)
(:hook-into org-mode)
(:option
org-superstar-headline-bullets-list
;;org-superstar-headline-bullets-list
;;'(127761 127762 127763 127764 127765 127766 127767 127768) ;; Phases of the moon
'(127765 127766 127767 127768 127761 127762 127763 127764) ;; Phases of the moon
;;'(127765 127766 127767 127768 127761 127762 127763 127764) ;; Phases of the moon
;;'(19904 19937 19958 19954 19964 19932 19939 19935) ;; I-Ching
;;'(128608 128609 128610 128611 128612 128613 128614 128615) ;; Vines
;;'(128592 128593 128594 128595 128596 128597 128598 128599) ;; Leafs
@ -3957,6 +3959,55 @@ Of course I have to find a way to play muds with Emacs too.
(goto-address-mode t)))) ;; ... clickable links
#+end_src
** Slime / Swank / StumpWM
This is for interacting with StumpWM.
#+name: slime-swank-stumpwm
#+begin_src emacs-lisp
;;(load (expand-file-name "~/.local/opt/quicklisp/slime-helper.el"))
;; ;; Replace "sbcl" with the path to your implementation
;; (setq inferior-lisp-program "/usr/local/bin/sbcl")
(load (expand-file-name "~/.local/opt/quicklisp/slime-helper.el"))
;; Replace "sbcl" with the path to your implementation
(setq inferior-lisp-program "sbcl")
;; In my case /path/to/quicklisp is ~/quicklisp
;; (defvar quicklisp-path "~/.local/opt/quicklisp")
;; ;;
;; ;; Load slime-helper, this sets up various autoloads:
;; ;;
;; (load (concat quicklisp-path "/slime-helper"))
;; ;;
;; ;; Set up slime with whatever modules you decide to use:
;; ;;
;; (slime-setup '(slime-fancy slime-mrepl slime-banner slime-tramp
;; slime-xref-browser slime-highlight-edits
;; slime-sprof))
;; ;;
;; ;; Decide where to put a slime scratch file, if you want one, and set
;; ;; it up with:
;; ;;
;; (setf slime-scratch-file "~/.local/opt/quicklisp/.slime-scratch.lisp")
;; ;;
;; ;; Unfortunately there is no hook for the slime-scratch mode so if you
;; ;; want to automatically enable/disable various minor modes in the
;; ;; slime scratch buffer you must do something like:
;; ;;
;; (defadvice slime-scratch
;; (after slime-scratch-adjust-modes () activate compile)
;; (turn-some-mode-off)
;; (turn-some-other-mode-on))
#+end_src
** Emacs Client / Server
Without this, emacs can take a while to start. We definitely want this.
#+name: server-start
#+begin_src emacs-lisp
(server-start)
#+end_src
* Tangle The Emacs Config
Here is the central tangle. I organize all the tangles together here
for easy load order control and visualization.
@ -4109,6 +4160,7 @@ name: tangle_early-init.el
<<undo-tree>>
<<vagrant-tramp>>
<<magit>>
<<slime-swank-stumpwm>>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Terminals
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -4121,6 +4173,10 @@ name: tangle_early-init.el
;; Usefull Functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
<<insert-zero-width-space>>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Emacs Client / Server
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
<<server-start>>
#+end_src
#+RESULTS: tangle_init.el

View file

@ -5,6 +5,20 @@
(in-package :stumpwm)
(ql:quickload :clx-truetype)
(load-module "ttf-fonts")
(setq clx-truetype::*font-dirs*
(append (list (namestring (merge-pathnames ".local/share/fonts" (user-homedir-pathname))))
clx-truetype::*font-dirs*))
(xft:cache-fonts)
(set-font (make-instance 'xft:font
:family "Lexend Nerd Font"
:subfamily "Regular"
:size 32
:antialias t))
;; change the prefix key to something else
;;(set-prefix-key (kbd "C-z"))
@ -38,7 +52,8 @@
;;(define-key *root-map* (kbd "i") "imdb")
;; Message window font
(set-font "-xos4-terminus-medium-r-normal--14-140-72-72-c-80-iso8859-15")
;;(set-font "-xos4-terminus-medium-r-normal--14-140-72-72-c-80-iso8859-15")
;;(set-font "-*-lucida-*-*-*-*-34-*-*-*-*-*-*-*")
;;; Define window placement policy...
@ -89,31 +104,53 @@ run-or-raise with group search t."
(run-or-raise cmd `(:class ,win-cls) nil T)
(run-or-raise cmd `(:class ,win-cls) T T))))
;;(defcommand run-or-raise-emacsclient () ()
;; (run-or-raise-prefer-group "emacs" "Emacs"))
(defcommand run-or-raise-emacs () ()
(run-or-raise-prefer-group "emacs" "Emacs"))
(defcommand run-or-raise-emacsclient () ()
(run-or-raise-prefer-group "emacs" "Emacs"))
(defcommand decide-on-emacsclient () ()
(if (equal (run-shell-command "pgrep \"emacsclient\"" t) "")
(run-shell-command "emacsclient -c")
(run-or-raise-emacsclient)))
;;(defcommand decide-on-emacsclient () ()
;; (if (equal (run-shell-command "pgrep \"emacsclient\"" t) "")
;; (run-shell-command "emacsclient -c")
;; (run-or-raise-emacsclient)))
;;
;;(define-key *root-map* (kbd "s-e") "decide-on-emacsclient")
;;(define-key *root-map* (kbd "C-e") "decide-on-emacsclient")
;;(define-key *root-map* (kbd "e") "decide-on-emacsclient")
(define-key *root-map* (kbd "e") "decide-on-emacsclient")
(define-key *root-map* (kbd "e") "run-or-raise-emacs")
;;(define-key *root-map* (kbd "e") "run-or-raise-emacs")
;;(defcommand emacsclient-launch () ()
;; (run-shell-command "emacsclient -c"))
(defcommand emacsclient-launch () ()
(run-shell-command "emacsclient -c"))
;;
;;(define-key *root-map* (kbd "s-E") "emacsclient-launch")
;;(define-key *root-map* (kbd "C-E") "emacsclient-launch")
;;(define-key *root-map* (kbd "E") "emacsclient-launch")
(define-key *root-map* (kbd "E") "emacsclient-launch")
;; Slime
;; This is how we interact with StumpWM using emacs.
;; Load swank.
;; *prefix-key* ; swank will kick this off
;;(load "/path/to/slime/swank-loader.lisp")
;;(swank-loader:init)
;; Autostart apps
;;(ql:quickload :swank)
;;(defcommand swank () ()
;; (swank:create-server :port 4005
;; :style swank:*communication-style*
;; :dont-close t)
;; (echo-string (current-screen)
;; "Starting swank. M-x slime-connect RET RET, then (in-package stumpwm)."))
;;(swank)
;;
;;;; Autostart apps
(run-shell-command "picom")
(run-shell-command "reset-kb")
;;(run-shell-command "emacs --daemon")
(run-shell-command "emacs --daemon")
;; Wallpaper stuff
;; Function to run the background setting script
(defun run-bg-script ()
(run-shell-command "~/.local/bin/mgk-bg"))
;; Set up a timer to call run-bg-script every 10 seconds
(run-with-timer 10 10 'run-bg-script)

View file

@ -1,5 +1,4 @@
#!/usr/bin/env bash
_location=".config/yadm/workstation-minimal.d/01-install-fedora-packages.sh"
# {{{ <mordu debug system>
_debug=y # Comment this out to disable debuging.
@ -32,7 +31,7 @@ _mordu "Starting script."
# {{{ <define packages>
_define_packages() {
_packages=(blueman firefox ffmpeg vlc-plugin-pipewire vlc-plugin-ffmpeg \
feh mpv awesome kitty nitrogen)
feh mpv awesome kitty nitrogen xscreensaver)
}
# }}} </define packages>

View file

@ -1,5 +1,7 @@
#!/usr/bin/env bash
_location=".config/yadm/shell-extras.d/06-install-sbcl-and-quicklisp-stuff.sh"
export GHQ_ROOT="${HOME}/.local/opt/git"
_ghq="${HOME}/.local/opt/go/bin/ghq"
# {{{ <mordu debug system>
_debug=y # Comment this out to disable debuging.
@ -156,6 +158,10 @@ _quicklisp_install_function() {
--eval '(ql:quickload "clx")' \
--eval '(ql:quickload "cl-ppcre")' \
--eval '(ql:quickload "alexandria")' \
--eval '(ql:quickload "xembed")' \
--eval '(ql:quickload "swank")' \
--eval '(ql:quickload "quicklisp-slime-hel")' \
--eval '(ql:quickload "zpng")' \
--eval '(quit)'
}
# }}} </quicklisp install function>
@ -197,6 +203,33 @@ _install_quicklisp() {
}
# }}} </install quicklisp>
# {{{ <clone and make install clx-truetype>
_install_clx-truetype() {
local __repo="git.mgk.one/common-lisp/goose121.clx-truetype"
if $_ghq list | grep -q "$__repo" ; then
_mordu "${__repo} already cloned. Updating."
$_ghq get -u "$__repo"
else
_mordu "Cloning ${__repo}."
$_ghq get "$__repo" \
|| $_ghq get "$__repo" \
|| $_ghq get "$__repo" \
|| _mordu "Failed to download ${__repo} three times."
fi
_mordu "Linking clx-truetype."
ln -s "${GHQ_ROOT}/${__repo}" \
"${HOME}/.local/opt/quicklisp/local-projects/clx-truetype"
#ln -s /home/ld/.local/opt/git/git.mgk.one/common-lisp/goose121.clx-truetype /home/ld/.local/opt/quicklisp/local-projects/clx-truetype
sbcl --eval '(ql:quickload :clx-truetype)' \
--eval '(xft:cache-fonts)' \
--eval '(quit)'
}
# }}} </clone and make install clx-truetype>
# {{{ <main loop>
_main() {
# Prep install area.
@ -212,6 +245,7 @@ _main() {
# Install Quicklisp
_download_quicklisp
_install_quicklisp
_install_clx-truetype
}
_main
# }}} </main loop>

73
.local/bin/mgk-bg Executable file
View file

@ -0,0 +1,73 @@
#!/usr/bin/env bash
# Set DEBUG variable
# Uncomment the following line to enable debug output
# DEBUG=y
# Function to print debug information
debug() {
if [ ! -z "$DEBUG" ]; then
echo "$@"
fi
}
# Variables
display_info=($(xrandr --listactivemonitors | grep x | awk '{print $1 "," $3 "," $4}' | sed s/:// | sed 's|/[0-9]\+x|x|' | sed 's|/[^,]*,|,|'))
monitorCount=${#display_info[@]}
# Directories for wallpapers
wide_dir="$HOME/.local/share/mgk-bg/wide"
tall_dir="$HOME/.local/share/mgk-bg/tall"
# Function to set background for each monitor
setmonitors_bg() {
if [ ! -d "$wide_dir" ] || [ -z "$(ls -A $wide_dir)" ]; then
echo "Wide directory $wide_dir does not exist or is empty."
exit 1
fi
if [ ! -d "$tall_dir" ] || [ -z "$(ls -A $tall_dir)" ]; then
echo "Tall directory $tall_dir does not exist or is empty."
exit 1
fi
for (( count=0; count<monitorCount; count++ )); do
# Extract head number, resolution, and display identifier
head_number=$(echo "${display_info[count]}" | cut -d',' -f1)
resolution=$(echo "${display_info[count]}" | cut -d',' -f2)
display_id=$(echo "${display_info[count]}" | cut -d',' -f3)
width=$(echo $resolution | cut -d'x' -f1)
height=$(echo $resolution | cut -d'x' -f2)
# Debugging: print width and height
debug "Debug: Display $head_number - $display_id has resolution $resolution (Width: $width, Height: $height)"
# Determine the directory based on display orientation
if [ $width -gt $height ]; then
image_dir=$wide_dir
orientation="wide"
else
image_dir=$tall_dir
orientation="tall"
fi
# Echo the detected display and resolution for verification
debug "Display $head_number: $display_id with resolution $resolution (Width: $width, Height: $height)"
debug "Using directory: $image_dir for $orientation display"
# Select a random background file, follow symbolic links
bg=$(find -L "$image_dir" -type f | shuf -n 1)
if [ -z "$bg" ]; then
echo "No background file found in $image_dir."
exit 1
fi
# Set the wallpaper using nitrogen and suppress errors
debug "Setting background for $display_id (head=$head_number): $bg"
nitrogen "$bg" --set-zoom --head=$head_number 2>/dev/null
done
}
# Run the function to set wallpapers
setmonitors_bg

132
.local/bin/sort-papez Executable file
View file

@ -0,0 +1,132 @@
#!/usr/bin/env bash
# Configuration
CONFIG_FILE="$HOME/.config/mgk-bg/mgk-bg.conf"
SOURCE_DIR="$HOME/pix/papez"
TALL_DIR="$HOME/.local/share/mgk-bg/tall"
WIDE_DIR="$HOME/.local/share/mgk-bg/wide"
# Create directories if they don't exist
mkdir -p "$TALL_DIR" "$WIDE_DIR"
# Function to read the config file
read_config() {
if [[ -f "$CONFIG_FILE" ]]; then
source "$CONFIG_FILE"
else
echo "Config file not found: $CONFIG_FILE"
exit 1
fi
}
# Function to get the active theme
get_theme() {
local theme=""
while [[ $# -gt 0 ]]; do
case $1 in
--theme)
theme="$2"
shift
;;
*)
;;
esac
shift
done
if [[ -z "$theme" ]]; then
theme=$theme_config
fi
echo "$theme"
}
# Function to clear existing links
clear_links() {
rm -f "$TALL_DIR"/*
rm -f "$WIDE_DIR"/*
}
# Spinner function
spinner() {
local pid=$!
local delay=0.1
local spinstr='|/-\'
while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do
local temp=${spinstr#?}
printf " [%c] " "$spinstr"
spinstr=$temp${spinstr%"$temp"}
sleep $delay
printf "\b\b\b\b\b\b"
done
printf " \b\b\b\b"
}
# Function to link images based on their dimensions
link_images() {
local theme=$1
local directories=("${!2}")
local total_images=0
# Calculate the total number of images to process
for dir in "${directories[@]}"; do
total_images=$((total_images + $(find "$SOURCE_DIR/$dir" -type f | wc -l)))
done
echo "Total images to process: $total_images"
local processed_images=0
for dir in "${directories[@]}"; do
for img in "$SOURCE_DIR/$dir"/*; do
if [[ -f "$img" ]]; then
dimensions=$(identify -format "%wx%h" "$img" 2>/dev/null)
if [[ -n "$dimensions" ]]; then
width=${dimensions%x*}
height=${dimensions#*x}
if (( height > width )); then
ln -sf "$img" "$TALL_DIR"
elif (( width > height )); then
ln -sf "$img" "$WIDE_DIR"
else
ln -sf "$img" "$TALL_DIR"
ln -sf "$img" "$WIDE_DIR"
fi
processed_images=$((processed_images + 1))
printf "\rProcessing images... %d/%d" "$processed_images" "$total_images"
fi
fi
done
done
echo -e "\nImage processing complete."
}
# Main script execution
read_config
theme=$(get_theme "$@")
echo "Selected theme: $theme"
# Clear existing links
echo "Clearing existing links..."
clear_links
case "$theme" in
sfw)
directories=("${sfw_dirs[@]}")
;;
nsfw)
directories=("${nsfw_dirs[@]}")
;;
*)
echo "Unknown theme: $theme"
exit 1
;;
esac
# Link images with a spinner and progress indicator
link_images "$theme" directories[@] & spinner
echo "Images sorted for theme: $theme"

16
.local/bin/stumpish Executable file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env bash
#
# `fake' stumpish.
# This loads the latest version of `real' stumpish
# In my case /path/to/quicklisp is ${HOME}/quicklisp; your mileage may be different!
stump_start="${HOME}/.local/opt/quicklisp"
stump_middle=$(cat ${stump_start}/dists/quicklisp/installed/releases/stumpwm.txt)
stump_end="contrib/stumpish"
stumpish=${stump_start}/${stump_middle}${stump_end}
# Note the `.' - the `real' stumpish must be sourced!
. ${stumpish}