From 2f78d852e6691acfe1e6847186b42602a341254b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Thu, 15 Dec 2016 15:35:16 +0100 Subject: [PATCH] Add filemenu to i3 --- i3/.config/i3/config | 3 ++- scripts/.bin/filemenu | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100755 scripts/.bin/filemenu diff --git a/i3/.config/i3/config b/i3/.config/i3/config index f56a869..1ff0f80 100644 --- a/i3/.config/i3/config +++ b/i3/.config/i3/config @@ -30,7 +30,7 @@ bindsym Control+Mod1+l exec --no-startup-id i3-exit.sh lock bindsym Control+Mod1+w exec --no-startup-id i3-one-instance firefox bindsym Control+Mod1+g exec --no-startup-id i3-one-instance gvim bindsym Control+Mod1+e exec --no-startup-id myemacs -c -bindsym $mod+o exec --no-startup-id winmenu.sh +bindsym $mod+Tab exec --no-startup-id winmenu.sh bindsym $mod+p [class="Nemo"] scratchpad show bindsym $mod+period [instance="emacs" title="^(?!myagenda$)"] scratchpad show bindsym $mod+shift+comma exec --no-startup-id myemacs -nc --eval '(progn (find-file "~/Dropbox/Todo/org/rules.org") (org-agenda-list) (set-frame-name "myagenda"))' @@ -57,6 +57,7 @@ bindsym $mod+q kill # start dmenu (a program launcher) #bindsym $mod+Space exec --no-startup-id dmenu_run bindsym $mod+space exec --no-startup-id runmenu +bindsym $mod+o exec --no-startup-id filemenu $HOME # Arandr magic bindsym Mod1+F5 exec --no-startup-id monitors single diff --git a/scripts/.bin/filemenu b/scripts/.bin/filemenu new file mode 100755 index 0000000..1559646 --- /dev/null +++ b/scripts/.bin/filemenu @@ -0,0 +1,32 @@ +#!/bin/sh + +if [ "$#" -le 0 ]; then + echo "Usage: $0 " + exit 1 +else + input="$@" +fi + +echo "Input: "$input + +if [ -f "$input" ]; then + xdg-open "$input" + exit $? +else + if [ -d "$input" ]; then + echo "This is a folder" $input + else + >&2 echo 'Invalid argument:"'$input'"' + exit 1 + fi +fi + +if command -v rofi >/dev/null 2>&1; +then + launcher="rofi -dmenu -i -mesg '""$input""'" +else + launcher="dmenu -fn "-*-cure-medium-*-*-*-11-*-*-*-*-*-*-*" -nb "#101010" -nf "#5f5f5f" -sb "#191 +fi + + # find "$input" -maxdepth 1 ! -path "$input" -print | sh -c "$launcher" | xargs $0 +ls -t1 "$input" | sh -c "$launcher" | xargs -I '{}' $0 "$input/{}"