#!/bin/bash # pipe menu cache for OpenBox3 v0.10 # icons changes not tracked # param: generator command: ob3menu-cache(){ local cmd="${*:-/usr/bin/ob3menu --slow}" #local cmd="${*:-/usr/bin/mmaker -ci OpenBox3}" DSP=${DISPLAY//[\\\/*]/_} [[ "$DSP" == *:* && "$DSP" != *:*.* ]] && DSP+='.0' DSP1="${DSP%.*}" . "$HOME/.cache/ya/environment.$DSP" && cmd=${cmd/ob3menu --slow/ob3menu --autostart $YA_XDG_AUTOSTART --profile $YA_PROFILE --slow} local m="$HOME/.cache/ya/menu.xml" c1="/usr/share/applications /usr/share/applications/inputmethods /usr/share/desktop-directories" c="$0 ${cmd%% *} /etc/xdg/autostart" mm=true i m1=return mk mk1 XY x y k1= mk="$m.$DSP.key" mk1="${mk}1" if [ "$mk1" -ot "/var/log/Xorg.${DSP1#:}.log" ] && k1=`xrandr --current`; then XY=`echo $(echo "$k1"|grep -o ' current [0-9]* x [0-9]*\| connected [0-9x+]*'|sed -e 's: \|current\|connected::g')` if [ "$XY" = "$(< "$mk1")" ]; then touch "$mk1" else unlink "$mk" umask 077 echo "$XY" >"$mk1" fi else read XY <"$mk1" fi DSP3=${XY// /X} : ${DSP3:="$DSP"} case "$cmd" in *ob3menu*\ --autostart*)a="$HOME/.cache/ya/autostart";;& *ob3menu*\ --launcher*) x=" $HOME/.config/ya/tint2rc /etc/xdg/ya/tint2rc $HOME/.cache/ya/tint2rc.$DSP3" c+=" $x" cmd+=" --tint2 $x" x="$HOME/.cache/ya/desk-sh" y="$x.$DSP3" cmd=${cmd// $x / $y } # c+=" $y" local dsh='DSP=${DISPLAY//[\\\/*]/_} [[ "$DSP" == *:* && "$DSP" != *:*.* ]] && DSP+=.0 read DSP3 <~/.cache/ya/menu.xml.$DSP.key1 || DSP3="$DSP" . "$0.${DSP3// /X}"' [ -e "$y" -o "$dsh" = "$(< "$x")" ] || { unlink "$mk" echo "$dsh" >$x chmod 700 "$x" } ;;& *ob3menu*\ --slow*) c+=" $HOME/.config/ya/rc.xml $HOME/.config/ya/preferred-apps /etc/fstab" c1+=" /usr/share/mime/globs" # /usr/share/icons/*/*/* cmd+=" --mime $m.sh $HOME" cmd=${cmd/--slow --/--slow $HOME/.config/ya/rc.xml "$XY" --} m1= ;; *ob3menu*\ --mime\ *)c+=" /usr/share/mime/globs /etc/fstab";; *mmaker\ *)mm=echo;; esac local k="${cmd/ --init *--init}:$LANG:`stat --printf=%Z $c $c1 ${c1//\/usr\/share/$HOME/.local/share} 2>/dev/null`" k1 if ! (read k1 <"$mk" && [ "$k1" = "$k" ]); then umask 077 mkdir -p "${m%/*}" { $mm '' $cmd || unlink "$m" $mm '' } >"$m" echo "$k" >"$mk" fi cat "$m" && return unlink "$mk" $m1 notify-send 'Advanced menu error. Trying simple.' ${cmd%% *} } ob3menu-cache "${@}"