Ralphie

Created: Apr 08, 2021Last modified: Apr 24, 2023
Word count: 565Backlinks: 7

Ralphie is a library for useful clojure / babashka apis.

It provides namespaces and functions for integrating with whatever tools I use.

The gist: bash-like scripting and automation libraries via babashka and repl -driven development.

Originally targetted linux cli helpers, but expanded to some osx use-cases as well.

Example namespaces: emacs, tmux, browser, git, spotify, rofi.

Ralphie's name connects babashka to rofi

Ralphie because of 'A Christmas Story's Ralphie's wish for a bb-gun (i.e. a babashka gun).

And not too far from Rofi, sound-wise.

The idea was to easily provide a list of useful automation tasks in a rofi-interface.

Ralphie is many small namespaces

Ralphie could be a number of separate libs, but I prefer a low barrier-to-entry for new ideas, and so it's a monorepo for now.

Perhaps some of the pieces of ralphie could be broken out into separate libs or releases - for now the namespaces can be required adhoc, so there's not much to gain from that.

Ralphie is part of clawe 's monorepo

It is contained within clawe's monorepo to support easier development alongside clawe.

Features

Not all, but some functions that might be useful.

> awesome/fnl, awesome/lua

Fire some arbitrary fennel or lua via AwesomeWM

Useful for automating window-manager commands in Awesome.

> awesome/*

Misc useful awesomeWM commands

> bb/tasks

Returns the babashka tasks for the passed directory.

Not much more than reading and parsing the bb.edn

> browser/open, browser/open-dev

Open a browser, or a passed URL in that browser.

Hardcoded to some browser choices for now, but could be improved/abstracted.

> clipboard/get-all, clipboard/values, clipboard/set-clip

Setting and fetching from the clipboard.

> emacs/fire

Similar to tmux/fire and awesome/fnl, but quite simple.

(defn fire
  "Expects a string, passes it to emacsclient --eval."
  [form]
  (-> ($ emacsclient --eval ~form)
      check))

Could evolve to handle backtick quoting similarly to awesome/fnl.

> emacs/open

Open a new emacs frame. Supports a passed workspace name and file.

> emacs/open-in-emacs

Supports 'remotely' controlling an existing emacs frame - opens the passed file

detail in the last-used emacs frame (depends on emacsclient 's behavior)

> git/clone

Clone a github repo into ~/<git-user>/<git-repo> on your machine.

> git/fetch

Fetch (update from remote) a git dir.

> git/status

Return the current status (needs push? needs pull? dirty?) for a repo.

> git/commits-for-dir, git/commit-stats-for-dir

Parses commits into useful edn for the passed dir.

> notify/notify

Send an OS-level notification.

>> Has some python send-notify depenedency on Linux.

>> Fails to handle non-string bodies on OSX.

> rofi/rofi

Expects a list of maps with :rofi/label strings.

Opens the passed list of labels via Rofi on linux, or Choose on osx.

If an entry has :rofi/on-select set, that function will be called upon selection. Otherwise the whole input map is returned.

> sh/expand, sh/expand-many

Expand a string via zsh expansion.

> tmux/fire

Fire an arbitrary command via tmux.

Specify a new or existing tmux session, window, or pane. Specify a directory to first switch to.

Supports optional interrupt, for cancelling a running process in the specified pane.

> tmux/open-session

Open a new or existing tmux session in a terminal. Useful at the window-manager level.

Currently hard-coded to use Alacritty.

> yabai/*

Misc useful yabaiWM commands

> zsh/history

Ralphie Assumptions/Dependencies

Some of these are opinions, others are deps expected to be available on the PATH, typically accessed via bb/process.

> emacs in client/server mode

> some autoload emacs funcs

russ/open-workspace

> browser choices

>> web: ff on linux, safari on osx

>> devweb: ff dev edition

> terminal choice

>> Alacritty

> linux wm: awesomeWM

> osx wm: yabaiWM

> notify-send.py on linux

> brotab on linux

More MRU

A rofi MRU concept would be very cool.

maybe it consumes ralphie-history, which can be written to?


Backlinks

I'm finally sponsoring some folks for their open source work with (small) monthly donations - just a way to say thanks for tools I use all day, every day.

A video overview of the components that make up the clawe monorepo.

Relevant April 2023.

I'll post a link here once it exists! For now, if you're reading this, I could stream this any day, so take a look at my schedule or ping me to see when it's going to happen.

Starting early today (12:01am)

working through clawe.org, pulling in some content, writing some new ideas

garden tending

Welcome to the Clawe garden doc! This file is for thinking and organizing the work on the clawe repo.

  • Clawe Repo link

Clawe lets you use clojure and babashka to write wm-level keybindings and manage apps and workspaces.