From 33868cd3d3f42ce4310285154dd006f9e378b18a Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 9 Dec 2019 02:54:42 -0500 Subject: [PATCH] Add rofi-filemenu & st-calc These are dummy applications for rofi's dmenu launcher. --- config/bspwm/bspwmrc | 1 + config/rofi/bin/rofi-filemenu | 10 +++++++ modules/desktop/bspwm.nix | 54 +++++++++++++++++++++++------------ modules/desktop/rofi.nix | 29 +++++++++++++++---- 4 files changed, 70 insertions(+), 24 deletions(-) create mode 100755 config/rofi/bin/rofi-filemenu diff --git a/config/bspwm/bspwmrc b/config/bspwm/bspwmrc index 7db9428d..d96f8163 100755 --- a/config/bspwm/bspwmrc +++ b/config/bspwm/bspwmrc @@ -23,6 +23,7 @@ bspc rule -a feh state=fullscreen bspc rule -a 'Emacs:org*' state=floating bspc rule -a 'Emacs:scratch' state=floating bspc rule -a st-scratch state=floating sticky=on center=on +bspc rule -a st-calc state=floating sticky=on center=on # diff --git a/config/rofi/bin/rofi-filemenu b/config/rofi/bin/rofi-filemenu new file mode 100755 index 00000000..2d6f32ae --- /dev/null +++ b/config/rofi/bin/rofi-filemenu @@ -0,0 +1,10 @@ +#!/usr/bin/env sh +DIR="$(fd -L --type d . $HOME | rofi -dmenu -i -columns 1 -theme theme/appmenu.rasi)" +if [ -d "$DIR" ]; then + cd "$DIR" + if [[ $1 == "-x" ]]; then + st-scratch + else + xst + fi +fi diff --git a/modules/desktop/bspwm.nix b/modules/desktop/bspwm.nix index 21af690b..869b4008 100644 --- a/modules/desktop/bspwm.nix +++ b/modules/desktop/bspwm.nix @@ -18,24 +18,6 @@ }) xst # st + nice-to-have extensions - (writeScriptBin "st-scratch" '' - #!${stdenv.shell} - SCRID=st-scratch - focused=$(xdotool getactivewindow) - scratch=$(xdotool search --onlyvisible --classname $SCRID) - if [[ -n $scratch ]]; then - if [[ $focused == $scratch ]]; then - xdotool windowkill $scratch - else - xdotool windowactivate $scratch - fi - else - xst -t $SCRID -n $SCRID -c $SCRID \ - -f "$(xrdb -query | grep 'st-scratch\.font' | cut -f2)" \ - -g 100x26 \ - -e $SHELL - fi - '') (makeDesktopItem { name = "xst"; desktopName = "Suckless Terminal"; @@ -44,6 +26,42 @@ exec = "${xst}/bin/xst"; categories = "Development;System;Utility"; }) + + (writeScriptBin "st-scratch" '' + #!${stdenv.shell} + SCRID=st-scratch + focused=$(xdotool getactivewindow) + scratch=$(xdotool search --onlyvisible --classname $SCRID) + if [[ -n $scratch ]]; then + if [[ $focused == $scratch ]]; then + xdotool windowkill $scratch + else + xdotool windowactivate $scratch + fi + else + xst -t $SCRID -n $SCRID -c $SCRID \ + -f "$(xrdb -query | grep 'st-scratch\.font' | cut -f2)" \ + -g 100x26 \ + -e $SHELL + fi + '') + (writeScriptBin "st-calc" '' + #!${stdenv.shell} + SCRID=st-calc + scratch=$(xdotool search --onlyvisible --classname $SCRID) + [ -n "$scratch" ] && xdotool windowkill $scratch + xst -t $SCRID -n $SCRID -c $SCRID \ + -f "$(xrdb -query | grep 'st-scratch\.font' | cut -f2)" \ + -g 80x12 \ + -e $SHELL -c qalc + '') + (makeDesktopItem { + name = "st-calc"; + desktopName = "Calculator"; + icon = "calc"; + exec = "st-calc"; + categories = "Development"; + }) ]; }; diff --git a/modules/desktop/rofi.nix b/modules/desktop/rofi.nix index 1db276fa..6ed42e61 100644 --- a/modules/desktop/rofi.nix +++ b/modules/desktop/rofi.nix @@ -9,20 +9,37 @@ '') rofi + # Fake rofi dmenu entries (makeDesktopItem { - name = "browsermenu"; + name = "rofi-browsermenu"; desktopName = "Open Bookmark in Firefox"; icon = "firefox"; - exec = "rofi-browsermenu"; - categories = "Network"; + exec = "${}/bin/rofi-browsermenu"; + categories = "Network;Utility"; + }) + (makeDesktopItem { + name = "rofi-filemenu"; + desktopName = "Open Directory in Terminal"; + icon = "folder"; + exec = "${}/bin/rofi-filemenu"; + categories = "System;Utility"; + }) + (makeDesktopItem { + name = "rofi-filemenu-scratch"; + desktopName = "Open Directory in Scratch Terminal"; + icon = "folder"; + exec = "${}/bin/rofi-filemenu -x"; + categories = "System;Utility"; }) - ]; - # shellAliases = {}; + ]; }; home-manager.users.hlissner.xdg.configFile = { # link recursively so other modules can link files in its folder - "rofi" = { source = ; recursive = true; }; + "rofi" = { + source = ; + recursive = true; + }; }; }