From 941883c00c15031860a76e6761450019a0e0fb96 Mon Sep 17 00:00:00 2001 From: "Phyks (Lucas Verney)" Date: Wed, 10 Feb 2016 12:00:06 +0100 Subject: [PATCH 1/3] Fix non-UTF-8 characters segfault --- fmenu-rofi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fmenu-rofi b/fmenu-rofi index 8a0e7c4..e9d1bc7 100755 --- a/fmenu-rofi +++ b/fmenu-rofi @@ -64,7 +64,9 @@ do done function index_files { - find "$INPUT" \( ! -regex "$EXCLUDE" \) | sed 's/ /\\ /g' | sort -f > "$INDEX" + find "$INPUT" \( ! -regex "$EXCLUDE" \) | sed 's/ /\\ /g' | sort -f > "$INDEX.raw" + iconv -f utf-8 -t utf-8 -c "$INDEX.raw" -o "$INDEX" + rm "$INDEX.raw" } if [[ ! -a "$INDEX" ]] || ( test `find $INDEX -mmin $TIME` ) || ($FORCE) From cfbd18173d69aa665a5e8b6c127faaeac780250e Mon Sep 17 00:00:00 2001 From: "Phyks (Lucas Verney)" Date: Wed, 10 Feb 2016 16:48:45 +0100 Subject: [PATCH 2/3] Fix bad shift of arguments as well --- fmenu-rofi | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fmenu-rofi b/fmenu-rofi index e9d1bc7..1ee6421 100755 --- a/fmenu-rofi +++ b/fmenu-rofi @@ -26,6 +26,7 @@ TIME="+5" INPUT=$HOME EXCLUDE='.*/\..*' DRY=false +SHIFT=0 while getopts "ht:fd:o:i:x:u" OPTION do case $OPTION in @@ -35,34 +36,42 @@ do ;; f) FORCE=true + SHIFT=$((SHIFT + 1)) ;; d) DMENU=$OPTARG + SHIFT=$((SHIFT + 2)) ;; t) TIME=$OPTARG + SHIFT=$((SHIFT + 2)) ;; o) INDEX=$OPTARG + SHIFT=$((SHIFT + 2)) ;; i) INPUT=$OPTARG + SHIFT=$((SHIFT + 2)) ;; x) EXCLUDE=$OPTARG + SHIFT=$((SHIFT + 2)) ;; u) FORCE=true DRY=true + SHIFT=$((SHIFT + 1)) ;; ?) usage exit ;; esac - shift 1 done +shift $SHIFT + function index_files { find "$INPUT" \( ! -regex "$EXCLUDE" \) | sed 's/ /\\ /g' | sort -f > "$INDEX.raw" iconv -f utf-8 -t utf-8 -c "$INDEX.raw" -o "$INDEX" From e376d348cedbdb3df43094c02b66f96e7e3f1fdd Mon Sep 17 00:00:00 2001 From: "Phyks (Lucas Verney)" Date: Wed, 10 Feb 2016 17:05:43 +0100 Subject: [PATCH 3/3] Add an option to bypass index building --- fmenu-rofi | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/fmenu-rofi b/fmenu-rofi index 1ee6421..09e6dcf 100755 --- a/fmenu-rofi +++ b/fmenu-rofi @@ -16,6 +16,7 @@ OPTIONS: -f force reloading index [default: false] -t time [default: 5min] -u Just update the index + -n Prevent it from building the index EOF } @@ -26,8 +27,9 @@ TIME="+5" INPUT=$HOME EXCLUDE='.*/\..*' DRY=false +BUILD_INDEX=true SHIFT=0 -while getopts "ht:fd:o:i:x:u" OPTION +while getopts "ht:fd:o:i:x:un" OPTION do case $OPTION in h) @@ -63,6 +65,10 @@ do DRY=true SHIFT=$((SHIFT + 1)) ;; + n) + BUILD_INDEX=false + SHIFT=$((SHIFT + 1)) + ;; ?) usage exit @@ -78,16 +84,22 @@ function index_files { rm "$INDEX.raw" } -if [[ ! -a "$INDEX" ]] || ( test `find $INDEX -mmin $TIME` ) || ($FORCE) +if ( $BUILD_INDEX ) then - index_files + if [[ ! -a "$INDEX" ]] || ( test `find $INDEX -mmin $TIME` ) || ($FORCE) + then + index_files + fi fi if ( ! $DRY ) then if [ -z $@ ] then - cat "$INDEX" + if [[ -a "$INDEX" ]] + then + cat "$INDEX" + fi else xdg-open $@ > /dev/null & fi