unixporn / ideas

a place to dump project ideas
10 stars 0 forks source link

[Patch] [Functionality] A patch for dmenu that lets you quickly search the web #6

Closed mushchlo closed 3 years ago

mushchlo commented 3 years ago

So maybe an !f bang at the beginning of a string in dmenu_run to search something in a new firefox window.

eepykate commented 3 years ago

I personally think this would be a better script idea.

You might be able to make a script with the name f and put this in it, since dmenu supports passing args to commands.

#!/bin/sh
firefox "https://duckduckgo.com/?q=$*"

then you can do f this is what i want to search

mushchlo commented 3 years ago

I personally think this would be a better script idea.

You might be able to make a script with the name f and put this in it, since dmenu supports passing args to commands.

#!/bin/sh
firefox "https://duckduckgo.com/?q=$*"

then you can do f this is what i want to search

this is much simpler and better, I'll make a full script in a sec, thanks gk!

mushchlo commented 3 years ago

made a small addition, sometimes I like to open with a specific web address, so I'm using

#!/bin/sh [ -z "$(echo $* | grep \\.)" ] && firefox "https://duckduckgo.com/?q=$*" || firefox "$*"

thanks gk!

eepykate commented 3 years ago

Might I suggest this instead?

grep -q makes grep not output anything and just return a success or failure and exec replaces the script'd pid so if firefox fails it doesn't continue on to run firefox a second time.

#!/bin/sh
echo $* | grep -q '\.' && exec firefox "$*" ||
firefox "https://duckduckgo.com/?q=$*"
mushchlo commented 3 years ago

Much cleaner, thanks!