Last active
December 5, 2022 06:18
-
-
Save deadcyclo/3f90899f658de6a6722e to your computer and use it in GitHub Desktop.
stumpwm configurations for the Stumpwm power quick guide
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
;; Configurations as seen in Stumpwm power quick guide TODO: URL | |
;; ommand to grab a regional screenshot | |
(defcommand printscreenregion() () | |
(message "Print screen region") | |
(run-shell-command "gnome-screenshot -a")) | |
;; command to copy clipboard to intellij | |
;; NOTE: This requires the special set up to get intellij working with | |
;; stumpwm found later in this file | |
(defcommand xclipin() () | |
(message "Copied clipboard to intellij") | |
(run-shell-command "xclip -o | DISPLAY=:1.0 xclip -i")) | |
;; command to copy from intellij to clipboard | |
;; NOTE: This requires the special set up to get intellij working with | |
;; stumpwm found later in this file | |
(defcommand xclipout() () | |
(message "Compied clipboard from intellij") | |
(run-shell-command "DISPLAY=:1.0 xclip -o | xclip -i")) | |
;; command to launch or if already running give focus to spotify | |
(defcommand spotify () () | |
(run-or-raise "spotify" '(:class "Spotify"))) | |
;; command to launch or if already running give focus to chrome | |
;; cycles through multiple instances of chrome when repeated if | |
;; multiple instances exist | |
(defcommand gc () () | |
(run-or-raise "google-chrome" '(:class "Google-chrome"))) | |
;; command to launch or if already running give focus to intellij | |
;; note this requires the special setup to get intellij working with stumpwm | |
;; found later in this file | |
(defcommand rr-intellij () () | |
(run-or-raise "~/configfiles/scripts/intellij-hack" '(:class "intellij"))) | |
;; command to launch or if already running give focus to firefox | |
;; cycles through multiple instances of firefox when repeated if | |
;; multiple instances exist | |
(defcommand rr-firefox () () | |
(run-or-raise "firefox" '(:class "Firefox"))) | |
;; command to launch or if already running give focus to skype | |
(defcommand rr-skype () () | |
(run-or-raise "skype" '(:class "Skype"))) | |
;; command to launch or if already running give focus to xterm | |
;; cycles through multiple instances of xterm when repeated if | |
;; multiple instances exist | |
(defcommand rr-xterm () () | |
(run-or-raise "xterm" '(:class "XTerm"))) | |
;; command to launch or if already running give focus to korganizer | |
(defcommand rr-korganizer () () | |
(run-or-raise "korganizer" '(:class "Korganizer"))) | |
;; command to show laptop battery status info | |
(defcommand battery () () | |
(message | |
(run-shell-command "acpi -b -a -t" t))) | |
;; command to open a field from pootle translate in emacs | |
;; NOTE: This command requires the firefox plug-in keysnail | |
(defcommand field-edit () () | |
(send-meta-key (current-screen) (kbd "M-RET")) | |
(fnext) | |
(sleep 1) | |
(send-meta-key (current-screen) (kbd "C-c")) | |
(send-meta-key (current-screen) (kbd "d")) | |
(send-meta-key (current-screen) (kbd "n"))) | |
;; command to save an opened pootle translate field from | |
;; emacs to firefox | |
;; NOTE: This command requires the firefox plug-in keysnail | |
(defcommand field-save () () | |
(send-meta-key (current-screen) (kbd "C-x")) | |
(send-meta-key (current-screen) (kbd "C-s")) | |
(send-meta-key (current-screen) (kbd "C-x")) | |
(send-meta-key (current-screen) (kbd "#")) | |
(fnext) | |
(send-meta-key (current-screen) (kbd "C-g")) | |
(send-meta-key (current-screen) (kbd "e"))) | |
;; command to send the content of the x clipboard to the | |
;; currently focused window | |
(defcommand cheatypaste () () | |
(window-send-string | |
(get-x-selection) | |
(screen-current-window (current-screen)))) | |
;; stumpwm doesn't handle us-intl-altgr keyboard properly | |
;; the below adds similar keyboard shortcuts for inserting | |
;; nordic characters in stumpwm inputs using the super key | |
;; instead of alt-gr | |
(define-key *input-map* (kbd "s-w") | |
#'(lambda (input c) | |
(declare (ignore c)) | |
(input-insert-char input #\Ã¥))) | |
(define-key *input-map* (kbd "s-W") | |
#'(lambda (input c) | |
(declare (ignore c)) | |
(input-insert-char input #\Ã…))) | |
(define-key *input-map* (kbd "s-l") | |
#'(lambda (input c) | |
(declare (ignore c)) | |
(input-insert-char input #\ø))) | |
(define-key *input-map* (kbd "s-L") | |
#'(lambda (input c) | |
(declare (ignore c)) | |
(input-insert-char input #\Ø))) | |
(define-key *input-map* (kbd "s-z") | |
#'(lambda (input c) | |
(declare (ignore c)) | |
(input-insert-char input #\æ))) | |
(define-key *input-map* (kbd "s-Z") | |
#'(lambda (input c) | |
(declare (ignore c)) | |
(input-insert-char input #\Æ))) | |
(define-key *input-map* (kbd "s-[") | |
#'(lambda (input c) | |
(declare (ignore c)) | |
(input-insert-char input #\«))) | |
(define-key *input-map* (kbd "s-]") | |
#'(lambda (input c) | |
(declare (ignore c)) | |
(input-insert-char input #\»))) | |
;; define a key binding map for application running commands | |
(defvar *run-app-map* | |
(let ((m (stumpwm:make-sparse-keymap))) | |
(stumpwm:define-key m (stumpwm:kbd "s") "spotify") | |
(stumpwm:define-key m (stumpwm:kbd "c") "rr-firefox") | |
(stumpwm:define-key m (stumpwm:kbd "i") "rr-intellij") | |
(stumpwm:define-key m (stumpwm:kbd "k") "rr-skype") | |
(stumpwm:define-key m (stumpwm:kbd "t") "rr-korganizer") | |
(stumpwm:define-key m (stumpwm:kbd "x") "rr-xterm") | |
m ; NOTE: this is important | |
)) | |
;; create a key binding map pootle commands | |
(defvar *field-edit-map* | |
(let ((m (stumpwm:make-sparse-keymap))) | |
(stumpwm:define-key m (stumpwm:kbd "e") "field-edit") | |
(stumpwm:define-key m (stumpwm:kbd "s") "field-save") | |
m ; NOTE: this is important | |
)) | |
;; create a key binding map for copy and paste commands | |
(defvar *paste-map* | |
(let ((m (stumpwm:make-sparse-keymap))) | |
(stumpwm:define-key m (stumpwm:kbd "C-d") "xclipin") | |
(stumpwm:define-key m (stumpwm:kbd "d") "xclipout") | |
m ; NOTE: this is important | |
)) | |
(stumpwm:define-key stumpwm:*root-map* (stumpwm:kbd "h") '*field-edit-map*) | |
;; (stumpwm:define-key stumpwm:*root-map* (stumpwm:kbd "C-u") "exec /home/nobrelee/Scripts/togglethinklight") | |
(defcommand battery () () | |
(message | |
(run-shell-command "acpi -b -a -t" t))) | |
;; key binding to start the run app key binding map | |
(stumpwm:define-key stumpwm:*root-map* (stumpwm:kbd "o") '*run-app-map*) | |
;; key binding to print screen region | |
(define-key *root-map* (kbd "SunPrint_Screen") "printscreenregion") | |
;; key binding to suspend computer | |
;; NOTE: Make sure you have enabled passwordless sudo for pm-suspend | |
(define-key *root-map* (kbd "q") "exec /usr/bin/sudo pm-suspend") | |
;; key binding to hibernate computer | |
;; NOTE: Make sure you have enabled passwordless sudo for pm-hibernate | |
(define-key *root-map* (kbd "C-q") "exec /usr/bin/sudo pm-hibernate") | |
;; key binding to toggle the mode line or the panel (for example gnome panel) you have running | |
(define-key *root-map* (kbd "u") "mode-line") | |
;; key binding to display battery status | |
(define-key *root-map* (kbd "b") "battery") | |
;; key binding to open the unity control panel | |
(define-key *root-map* (kbd "c") "exec /usr/bin/unity-control-center") | |
;; force C-m to act as return | |
(define-key *top-map* (kbd "C-m") "meta Return") | |
(define-key *root-map* (kbd "C-m") "meta C-m") | |
(defin e-key *input-map* (kbd "C-m") 'input-submit) | |
;; keybinding to start a new xterm instance | |
(define-key *root-map* (kbd "t") "exec xterm") | |
;; key binding to lock screen | |
(define-key *root-map* (kbd "C-z") "exec gnome-screensaver-command -l") | |
;; key binding to paste x clipboard to focused window | |
(define-key *root-map* (kbd "v") "cheatypaste") | |
;; key binding to start key binding map for copy paste | |
(stumpwm:define-key stumpwm:*root-map* (stumpwm:kbd "j") '*paste-map*) | |
;; Intellij does not play nice with stumpwm. You can find more information | |
;; about this issue on my blog here: http://gsmblog.net/blog/intellij-idea-loosing-focus/ | |
;; However, as stated in the blog post, I have found a work around that alows the use | |
;; of Intellij in stumpwm by starting it in metacity in a new embedded x-server | |
;; instance using devilspie and Xephyr | |
;; | |
;; Read about this on my blog and create a shell script named intellij somewhere in your | |
;; path with the following content, or use the gist below: | |
;; | |
;; killall -9 devilspie & killall -9 Xephyr & xterm -class intellij -name intellij & sleep 1 && Xephyr -keybd ephyr,,,xkbmodel=pc105,xkblayout=us,xkbvariant=altgr-intl,xkboptions=ctrl:nocaps -ac -br :1.0 -parent `xprop -notype -name intellij WM_CLIENT_LEADER | awk '{ print $5 }'` & sleep 2 && DISPLAY=:1.0 /usr/bin/metacity & sleep 3 && DISPLAY=:1.0 /usr/bin/devilspie & sleep 4 && DISPLAY=:1.0 /usr/bin/intellij | |
;; | |
;; make sure you have devilspie, Xephyr, intellij and metacity installed | |
;; adapt the command to use what ever keyboard layout you wish |
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
#!/bin/sh | |
# Intellij does not play nice with stumpwm. You can find more information | |
# about this issue on my blog here: http://gsmblog.net/blog/intellij-idea-loosing-focus/ | |
# However, as stated in the blog post, I have found a work around that alows the use | |
# of Intellij in stumpwm by starting it in metacity in a new embedded x-server | |
# instance using devilspie and Xephyr | |
# | |
# make sure you have devilspie, Xephyr, intellij and metacity installed | |
# adapt the command to use what ever keyboard layout you wish | |
killall -9 devilspie & killall -9 Xephyr & xterm -class intellij -name intellij & sleep 1 && Xephyr -keybd ephyr,,,xkbmodel=pc105,xkblayout=us,xkbvariant=altgr-intl,xkboptions=ctrl:nocaps -ac -br :1.0 -parent `xprop -notype -name intellij WM_CLIENT_LEADER | awk '{ print $5 }'` & sleep 2 && DISPLAY=:1.0 /usr/bin/metacity & sleep 3 && DISPLAY=:1.0 /usr/bin/devilspie & sleep 4 && DISPLAY=:1.0 /usr/bin/intellij | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment