File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,11 +34,7 @@ has() {
3434}
3535
3636_pemx () {
37- if has ' rofi' ; then
38- rofi -e " error: $1 "
39- else
40- >&2 printf ' \033[31;1merror :\033[m %s\n' " $1 "
41- fi
37+ rofi -e " error: $1 "
4238 exit 1
4339}
4440
@@ -299,27 +295,35 @@ main(){
299295
300296 # BANGS
301297 " !" * )
302- if [ -f " ${NBROWSER_CONFIG_DIR} /bangs/${1/ ?} " ] ; then
303- source " ${NBROWSER_CONFIG_DIR} /bangs/${1/ ?} "
304- has nbrowser_bang || _pemx " couldn't find nbrowser_bang() function in ${NBROWSER_CONFIG_DIR} /bangs/${1/ ?} "
298+ local bang=" ${1/ ?} "
299+ if [ -f " ${NBROWSER_CONFIG_DIR} /bangs/${bang} " ] ; then
305300 shift
301+ source " ${NBROWSER_CONFIG_DIR} /bangs/${bang} "
302+ has nbrowser_bang || _pemx " couldn't find nbrowser_bang() function in ${NBROWSER_CONFIG_DIR} /bangs/${bang} "
306303 nbrowser_bang " $* "
307304 else
308- url_handler " https://duckduckgo.com/?q= $* "
305+ _pemx " bang ' ${bang} ' not found! "
309306 fi
310307 ;;
311308
312309 # Search Engines
313310 " ?" * )
314311 local engine=" ${1/ ?} "
315312 if [ -f " ${NBROWSER_CONFIG_DIR} /engines/${engine} " ] ; then
313+ echo 1
316314 source " ${NBROWSER_CONFIG_DIR} /engines/${engine} "
317315 has nbrowser_search || _pemx " couldn't find nbrowser_search() function in ${NBROWSER_CONFIG_DIR} /engines/${engine} "
318316 shift
319317 [ -n " $1 " ] && url_handler " $( nbrowser_search $* ) "
320318 elif [ -n " ${ENGINES[$engine]} " ]; then
319+ echo 2
321320 shift
322321 url_handler " ${ENGINES[$engine]} $* "
322+ elif [ -f " $NBROWSER_CONFIG_DIR /engines/engines.json" ]; then
323+ shift
324+ local url=$( jq -r " .[]|select( .t == \" $engine \" )|.u" " $NBROWSER_CONFIG_DIR /engines/engines.json" | sed " s/{{{s}}}/$* /g" )
325+ [ -z " $url " ] && _pemx " engine '${engine} ' not found!"
326+ url_handler " $url "
323327 else
324328 _pemx " search engine '${engine} ' not found!"
325329 fi
You can’t perform that action at this time.
0 commit comments