-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0de45cd
Showing
4 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# StumpWM Rofi | ||
|
||
Rofi module for StumpWM | ||
|
||
## Requrements | ||
|
||
- [Rofi](https://github.com/davatorium/rofi) installed | ||
|
||
## Installation | ||
|
||
```bash | ||
cd ~/.stumpwm.d/modules/ | ||
git clone https://github.com/Junker/stumpwm-rofi rofi | ||
``` | ||
|
||
```lisp | ||
(stumpwm:add-to-load-path "~/.stumpwm.d/modules/rofi") | ||
(load-module "rofi") | ||
``` | ||
|
||
## Usage | ||
|
||
```lisp | ||
;; list of pairs '(("name" . "command")) | ||
(defvar *my-menu* | ||
'(("Terminal" . "exec kitty") | ||
("Editor" . "exec featherpad") | ||
("Krusader" . "exec krusader") | ||
("💼 Work >" . (("Emacs" . "app-emacs") | ||
("DBeaver" . "app-dbeaver") | ||
("QOwnNotes" . "app-qownnotes"))) | ||
("🌍 Inet >" . (("Firefox" . "app-firefox") | ||
("Telegram" . "app-telegram") | ||
("Mail" . "exec thunderbird"))))) | ||
(defcommand my-menu () () | ||
(rofi:menu *my-menu*) | ||
;; or with rofi arguments | ||
(rofi:menu *my-menu* "-show-icons -theme gruvbox-dark-hard -cycle false")) | ||
(define-key *top-map* (kbd "s-x") "my-menu") | ||
;; windowlist | ||
(define-key *top-map* (kbd "s-Tab") "rofi-windowlist") | ||
;; custom list choose | ||
(message (cdr (rofi:choose '(("1" . "one") ("2" . "two") ("3" . "three")) | ||
"-theme fancy"))) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
;;;; package.lisp | ||
|
||
(defpackage :rofi | ||
(:use #:cl #:stumpwm #:alexandria) | ||
(:export #:menu | ||
#:choose)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
;;;; rofi.asd | ||
|
||
(asdf:defsystem #:rofi | ||
:description "Rofi module for StumpWM" | ||
:author "Dmitrii Kosenkov" | ||
:license "GPLv3" | ||
:version "0.1.0" | ||
:serial t | ||
:depends-on (#:stumpwm) | ||
:components ((:file "package") | ||
(:file "rofi"))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
(in-package :rofi) | ||
|
||
(defun run (items &optional (args "")) | ||
(uiop:run-program (format nil "echo \"~A\" | rofi -dmenu ~A" | ||
(prepare-items items) | ||
args) | ||
:ignore-error-status t | ||
:error-output '(:string :stripped t) | ||
:output '(:string :stripped t))) | ||
|
||
|
||
(defun choose (items args) | ||
(multiple-value-bind (out-text err-text err-code) | ||
(run items args) | ||
(declare (ignore err-text)) | ||
(when (eq err-code 0) | ||
(assoc out-text items :test #'string=)))) | ||
|
||
(defun menu (items &optional (args "")) | ||
(when-let ((item-val (cdr (choose items args)))) | ||
(if (stringp item-val) | ||
(run-commands item-val) | ||
(menu item-val args)))) | ||
|
||
(defun window-name (window) | ||
(format nil "~A (~A)" | ||
(stumpwm::window-class window) | ||
(stumpwm::window-name window))) | ||
|
||
(defcommand rofi-windowlist (&optional window-list) (:rest) | ||
(if-let ((window-list (mapcar (lambda (w) (cons (window-name w) w)) | ||
(or window-list | ||
(stumpwm::sort-windows-by-number | ||
(group-windows (current-group))))))) | ||
(if-let ((window (cdr (choose window-list "")))) | ||
(group-focus-window (current-group) window) | ||
(throw 'error :abort)) | ||
(message "No Managed Windows"))) | ||
|
||
(defun prepare-items (items) | ||
(format nil "~{~A~^~%~}" (mapcar #'car items))) |