jgbrowser 30 times faster directory listing in places panel

master
Daniel Napora 2020-02-08 09:36:18 +01:00
parent 7c31b714a4
commit 54326f88be
3 changed files with 60 additions and 57 deletions

34
bin/jgbrowser 100755
View File

@ -0,0 +1,34 @@
#!/usr/bin/env bash
# Read a directory to an array and sort it directories first.
: ${JGMENU_RESOURCE_OPENER=xdg-open}
DIRECTORY=${1:-$HOME}
# If '$PWD' is '/', unset it to avoid '//'.
[[ $DIRECTORY == / ]] && DIRECTORY=
for item in "$DIRECTORY"/*; do
if [[ -d $item ]]; then
dirs+=("${item##*/},^pipe(jgbrowser \"$DIRECTORY/${item##*/}\")")
#((item_index++))
# Find the position of the child directory in the
# parent directory list.
#[[ $item == "$OLDPWD" ]] &&
# ((previous_index=item_index))
else
files+=("${item##*/},xdg-open \"$DIRECTORY/${item##*/}\"")
fi
done
printf "%b\n" "^sep(<small><i>${DIRECTORY}</i></small>)"
printf "%b\n" "  Otwórz w menadżerze plików,${JGMENU_RESOURCE_OPENER} \"${DIRECTORY:-/}\""
printf "%b\n" "  Otwórz w termianlu,terminator --working-directory=\"${DIRECTORY:-/}\""
printf "%b\n" "^sep()"
printf "%b\n" "^sep(Katalogi)"
printf '%s\n' "${dirs[@]}"
printf "%b\n" "^sep(Pliki)"
printf '%s\n' "${files[@]}"
#list=("${dirs[@]}" "${files[@]}")

View File

@ -3,7 +3,7 @@
# Get colors from config file
#. $HOME/.config/mb-jgtools/mb-jgtools.colorrc
JGWIDTH="322"
JGWIDTH="300"
[ $(pidof picom) ] && RADIUS="12"
@ -90,6 +90,14 @@ CONFIG_FILE=$(mktemp)
MENU_ITEMS=$(mktemp)
trap "rm -f ${CONFIG_FILE} ${MENU_ITEMS}" EXIT
## WAŻNE
#monitor = integer (default 0)
#Specify a particular monitor as an index starting from 1.
#If 0, the menu will be launched on the monitor where the mouse is.
#Liczba onitorów
#xrandr --listmonitors | grep Monitors |awk '{print $2}'
if [ $(xrandr --listmonitors | grep Monitors |awk '{print $2}') -gt "1" ]
@ -120,13 +128,13 @@ MENU_HEIGHT_MIN=$(xdpyinfo | awk '/^ +dimensions/ {print $2}' | cut -d 'x' -f2)
mkconfigfile
cat <<EOF > ${MENU_ITEMS}
@icon,,270,10,48,48,4,left,top,,,/usr/share/icons/hicolor/48x48/apps/distributor-logo-mabox.png
@text,,10,10,200,20,4,left,top,#EEEEEE,#111111,<big>$OSNAME $OSVERSION</big> <sup> $OSCODE</sup>
@text,,10,30,200,20,4,left,top,#666666,#444444,<small>Jądro:</small> $KERNEL $HOSTTYPE
@text,,10,50,200,20,4,left,top,#666666,#444444,<small>$USER@$HOSTNAME</small>
@icon,,245,10,48,48,4,left,top,,,/usr/share/icons/hicolor/48x48/apps/distributor-logo-mabox.png
@text,,20,10,200,20,4,left,top,#EEEEEE,#111111,<big>$OSNAME $OSVERSION</big> <sup> $OSCODE</sup>
@text,,20,30,200,20,4,left,top,#666666,#444444,<small>Jądro:</small> $KERNEL $HOSTTYPE
@text,,20,50,200,20,4,left,top,#666666,#444444,<small>$USER@$HOSTNAME</small>
#@rect,,40,70,262,20,0,left,top,#666666,#262626,
@text,,14,70,20,20,0,left,top,auto,#222222,<big></big>
@search,,30,70,292,20,4,left,top,auto,#262626,""" <i>pisz, aby wyszukać</i>"""
@text,,74,70,20,20,0,left,top,auto,#222222,<big></big>
@search,,90,70,292,20,4,left,top,auto,#262626,""" <i>pisz, aby wyszukać</i>"""
. $HOME/.config/mabox/right-prepend.csv
@ -243,7 +251,7 @@ MENU_ITEMS=$(mktemp)
trap "rm -f ${CONFIG_FILE} ${MENU_ITEMS}" EXIT
MENU_HEIGHT_MIN=$(xdpyinfo | awk '/^ +dimensions/ {print $2}' | cut -d 'x' -f2)
JGWIDTH=280
mkconfigfile
cat <<EOF > ${MENU_ITEMS}
@ -255,17 +263,17 @@ cat <<EOF > ${MENU_ITEMS}
. $HOME/.config/mabox/places-prepend.csv
^sep(Szybka nawigacja)
 Katalog główny,^pipe(places "/")
 Katalog domowy,^pipe(places)
 Katalog główny,^pipe(jgbrowser /)
 Katalog domowy,^pipe(jgbrowser)
 $(basename $(xdg-user-dir DESKTOP)),^pipe(places $(xdg-user-dir DESKTOP))
 $(basename $(xdg-user-dir DOWNLOAD)),^pipe(places $(xdg-user-dir DOWNLOAD))
#  $(basename $(xdg-user-dir TEMPLATES)),^pipe(places $(xdg-user-dir TEMPLATES))
#  $(basename $(xdg-user-dir PUBLICSHARE)),^pipe(places $(xdg-user-dir PUBLICSHARE))
 $(basename $(xdg-user-dir DOCUMENTS)),^pipe(places $(xdg-user-dir DOCUMENTS))
 $(basename $(xdg-user-dir MUSIC)),^pipe(places $(xdg-user-dir MUSIC))
 $(basename $(xdg-user-dir PICTURES)),^pipe(places $(xdg-user-dir PICTURES))
 $(basename $(xdg-user-dir VIDEOS)),^pipe(places $(xdg-user-dir VIDEOS))
 $(basename $(xdg-user-dir DESKTOP)),^pipe(jgbrowser $(xdg-user-dir DESKTOP))
 $(basename $(xdg-user-dir DOWNLOAD)),^pipe(jgbrowser $(xdg-user-dir DOWNLOAD))
#  $(basename $(xdg-user-dir TEMPLATES)),^pipe(jgbrowser $(xdg-user-dir TEMPLATES))
#  $(basename $(xdg-user-dir PUBLICSHARE)),^pipe(jgbrowser $(xdg-user-dir PUBLICSHARE))
 $(basename $(xdg-user-dir DOCUMENTS)),^pipe(jgbrowser $(xdg-user-dir DOCUMENTS))
 $(basename $(xdg-user-dir MUSIC)),^pipe(jgbrowser $(xdg-user-dir MUSIC))
 $(basename $(xdg-user-dir PICTURES)),^pipe(jgbrowser $(xdg-user-dir PICTURES))
 $(basename $(xdg-user-dir VIDEOS)),^pipe(jgbrowser $(xdg-user-dir VIDEOS))
#^sep(Zakładki)
^sep()
<big></big> Wyszukiwarka plików, fsearch

View File

@ -1,39 +0,0 @@
#!/bin/sh
#
# Inspired by the {a,b}l-places-pipemenu scripts found in
# ArchLabs and BunsenLabs
#
: ${JGMENU_RESOURCE_OPENER=xdg-open}
path=${1:-$HOME}
[ $path != "/" ] && path=${path%/}
test -d "$path" || { echo "$0: '$path' is not a directory" >&2 ; exit 1 ; }
for i in "$path"/*
do
test -e "$i" || continue
shortname=${i##*/}
if test -d "$i"
then
directories_menu="${directories_menu}
${shortname},^pipe(places \"${path}/${shortname}\")"
else
files_menu="$files_menu
${shortname},${JGMENU_RESOURCE_OPENER} \"${path}/${shortname}\""
fi
done
printf "%b\n" "^sep(<small><i>${path}</i></small>)"
printf "%b\n" "  Otwórz w menadżerze plików,${JGMENU_RESOURCE_OPENER} \"${path}\""
printf "%b\n" "  Otwórz w termianlu,terminator --working-directory=\"${path}\""
printf "%b\n" "^sep()"
#printf "%b\n" "^sep(Katalogi)"
printf "%b\n" "${directories_menu}"
#printf "%b\n" "^sep(Pliki)"
printf "%b\n" "${files_menu}"
if test -z "${directories_menu}" && test -z "${files_menu}"
then
printf "%b\n" '<empty>'
fi