Psearch - Puppy web search utility

Browsers, email, chat, etc.
Message
Author
PaulR
Posts: 249
Joined: Wed 04 May 2005, 18:45
Location: UK

Psearch - Puppy web search utility

#1 Post by PaulR »

Here's Psearch my first proper Puppy program so go easy on me!

This utility takes your search terms prepends them with 'puppy linux' takes note of your choice of search target then launches Firefox (or a new tab if it's already open) with a ready made Google search.

The archive includes the executable (psearch) which has been packed with UPX - it's around 46K in size - and the BaCon source code.

If you use a different browser or search engine it should be easy to modify a couple of lines in the source and recompile to suit you needs.

The program doesn't have any other requirements so should run on any recent version of Puppy (I think/hope!).

Thanks to Mobeus and L18L here on the forum for their help :D

Paul
Attachments
psearch-screen.png
(14.38 KiB) Downloaded 528 times
psearch.tar.gz
(41.04 KiB) Downloaded 437 times

User avatar
nilsonmorales
Posts: 972
Joined: Fri 15 Apr 2011, 14:39
Location: El Salvador

#2 Post by nilsonmorales »

!Awesome. Have locales?

PaulR
Posts: 249
Joined: Wed 04 May 2005, 18:45
Location: UK

#3 Post by PaulR »

Sorry I don't know how to do that yet, I'll read up on it on Barry's BaCon guide.

Paul

PaulR
Posts: 249
Joined: Wed 04 May 2005, 18:45
Location: UK

#4 Post by PaulR »

Here's an updated version (only 19K now :D ) which offers a choice of search engines.

If anyone would like to suggest a search engine or site to add feel free to shout.

Localisation is on the way... thanks again to L18L for pointing me in the right direction.

Paul
Attachments
screen.png
(16.29 KiB) Downloaded 480 times
psearch1.03.tar.gz
(17.92 KiB) Downloaded 458 times

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#5 Post by 8-bit »

I downloaded this utility into Puppy Lucid 5.20.
I also have BaCon installed.
But when I tried to run this program from a terminal, I got a file not found in /usr/lib/hug.so not being found.
Maybe my BaCon install is not current enough.
I did not try to use the source you had posted in another thread.

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#6 Post by vovchik »

Dear PaulR,

Thanks for the utility. I tried the first version and it works fine. Version 1.03 complains about not finding /usr/lib/hug/so. To avoid compatibility problems of the type 8-bit and I are experiencing, I always just use hug and my compile line:

Code: Select all

bacon -o -s -o -Os -o -fdata-sections -o -ffunction-sections -o -Wl,--gc-sections mybconfile
and then UPX the binary. This gives me GTK binaries of about 19k, without the hug.so dependency. That means the binary will run on nearly all recent systems. Please post the source...so that I can recompile.

With kind regards,
vovchik

PaulR
Posts: 249
Joined: Wed 04 May 2005, 18:45
Location: UK

#7 Post by PaulR »

Sorry about that, I'd been using :

Code: Select all

INCLUDE "/usr/share/BaCon/hug_imports.bac"
INIT
for speed of compilation when testing and forgot to switch it back to:

Code: Select all

INCLUDE "/usr/share/BaCon/hug.bac"


...which also explains the reduction in size :oops:

Here's the re-compiled program, source to follow :D

Paul
Attachments
psearch1-03.tar.gz
(39.38 KiB) Downloaded 393 times

PaulR
Posts: 249
Joined: Wed 04 May 2005, 18:45
Location: UK

#8 Post by PaulR »

Source attached. L18L is reporting some font issues but it looks ok on my system... not sure what I've done to mess it up? :(
Attachments
psearch1-03-source.tar.gz
(1.76 KiB) Downloaded 397 times

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#9 Post by vovchik »

Dear PaulR,

Thanks. I compiled in Lucid and it works fine and IS USEFUL. Just used hug.bac and got rid of the USEC/END USEC stuff. Not needed. You could just use 0.0 at the end of SETPROPERTY or DECLARE that ALIGNLEFT var as a FLOATING or CONST.

With kind regards,
vovchik

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Psearch - Puppy web search utility

#10 Post by L18L »

PaulR wrote:Source attached. L18L is reporting some font issues but it looks ok on my system... not sure what I've done to mess it up? :(
BarryK on http://bkhome.org/bacon/hug/layout.htm wrote:REM fix window font layout regardless of dpi...
REM 78 is the Xft.dpi in /root/.Xresources when I designed the layout...
HUGOPTIONS("BASEXFTDPI 78")

Code: Select all

HUGOPTIONS("BASEXFTDPI 66")
has fixed it :lol:

PaulR
Posts: 249
Joined: Wed 04 May 2005, 18:45
Location: UK

#11 Post by PaulR »

OK, if I understand correctly I need to put

Code: Select all

HUGOPTIONS("BASEXFTDPI 78")
in the source as my system has "Xft.dpi: 78" in /root/.Xresources. If someone else has a different dpi setting or screen size (resolution?) the window will then automatically scale on their system to maintain the correct appearance (or they could re-compile and manually change the value as you have done).

That right? :)

Paul
Last edited by PaulR on Tue 26 Mar 2013, 20:27, edited 1 time in total.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

#12 Post by L18L »

(or they could re-compile and manually change the value as you have done).
Of course, not :)

Now I don't understand anything anymore.
My
Xft.dpi: 96
the default, see also http://bkhome.org/blog2/?viewDetailed=00190

I have inserted
HUGOPTIONS("BASEXFTDPI 66")
and compiled.

See the result, your original and mine :roll:
Attachments
psearch1.03_66.png
(59.94 KiB) Downloaded 405 times

PaulR
Posts: 249
Joined: Wed 04 May 2005, 18:45
Location: UK

#13 Post by PaulR »

My Slacko 5.5 has 78 DPI as the setting.

I've recompiled with:

Code: Select all

HUGOPTIONS("BASEXFTDPI 78")
The executable is attached, does that look right on your system L18L now that I've explicitly set the DPI?

Paul
Attachments
psearch1-03-testdpi.tar.gz
(39.59 KiB) Downloaded 445 times

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#14 Post by seaside »

PaulR.

Here's the recompile on precise 5.4.3 at Xft.dpi: 96.

I remember this being a problem when bacon was first introduced, and I'm hoping vovchik knows the fix. :)

Cheers,
s
Attachments
psearch.png
Recompile at 78dpi
(17.33 KiB) Downloaded 388 times

PaulR
Posts: 249
Joined: Wed 04 May 2005, 18:45
Location: UK

#15 Post by PaulR »

Thanks for that seaside - what if you run the executable in my last post without recompiling?

Paul

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#16 Post by seaside »

PaulR wrote:Thanks for that seaside - what if you run the executable in my last post without recompiling?

Paul
Paul,

That is a pic of your last posted executable :)
It was run on precise 5.4.3 at Xft.dpi: 96.

Cheers,
s

PaulR
Posts: 249
Joined: Wed 04 May 2005, 18:45
Location: UK

#17 Post by PaulR »

Sorry seaside I misunderstood.

I tried setting my dpi to 96 in xwindows and recompiling with this value in the code
- I ended up with similar overlapping fonts!

Anyway, here's version 1.1 which includes the option for users to define the two sites used in the site-specific search - just edit psearch.sites and change the two lines in the format:

site name,site search url
site name,site search url

As it stands the program has a fallback if this config file doesn't exist, if less than two lines are present, or if there are spurious characters either side of the separator ','.

The archive includes source, *.pot, upx'ed executable and the little config file.

(Compiled at 78 dpi again :) )

Paul
Attachments
psearch1-1.png
(12.88 KiB) Downloaded 513 times
psearch1-1.tar.gz
(83.71 KiB) Downloaded 401 times

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#18 Post by seaside »

PaulR.

I just downloaded the new version and ran the executable at 96 and at 78 on Precise 5.4.3 resulting in skewed fonts on both.

I think this might be a Gtk version level issue :idea:

Cheers,
s

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#19 Post by vovchik »

Dear PaulR,

Scaling can be a real PITA in HUG, as you, Barry and others have observed. Recently, I solved the problem of calculating required pixels for width and height using libpango: http://basic-converter.proboards.com/in ... 314&page=3. It is towards the bottom of the page. You would have to get the user's current DPI settings (there are routines somewhere), set those in a HUGOPTION and then dynamically set your other w and h dimensions using the results of my function. I have a demo there on the BaCon site. It can be surely done, but it ain't that easy and transparent.

And you can use the following code snippet to get some info about the user's settings:

Code: Select all

REM try to set font size to fit window... ex: xdpy=107 xftdpi=78
xdpi=VAL(EXEC$("xdpyinfo | grep -o 'resolution: .*' | tr -s ' ' | cut -f 2 -d ' ' | cut -f 1 -d 'x'"))
xftdpi=VAL(EXEC$("grep '^Xft.dpi:.*' /root/.Xresources | tr -s ' ' | cut -f 2 -d ' '"))
REM my weird formula...
fontsize=INT(12.0*(78.0/xftdpi)*(107.0/xdpi))
fontsize_mono=fontsize
fontsize$=STR$(fontsize)
fontsize_mono$=STR$(fontsize_mono)
font_sans$=CONCAT$("DejaVu Sans ",fontsize$)
font_mono$=CONCAT$("Monospace ",fontsize_mono$)

PRINT xdpi
PRINT xftdpi
PRINT fontsize
PRINT font_mono$
PRINT font_sans$
I also did a kind of brute force method here:

Code: Select all

' *****************
' DECLARATIONS
' *****************

GLOBAL hres, vres, dsize, dpi, mydpi TYPE FLOATING
GLOBAL version$ TYPE STRING

' *****************
' END DECLARATIONS
' *****************

' *****************
' INIT VARS
' *****************

version$ = "v. 0.1"

' *****************
' END INIT VARS
' *****************


' *****************
' FUNCTIONs
' *****************

FUNCTION CALCDPI(FLOATING hres, FLOATING vres, FLOATING dsize)
        dpi = hres/(hres / SQR(POW(hres,2) + POW(vres,2)) * dsize)
        RETURN dpi
END FUNCTION

FUNCTION USAGE()
        PRINT NL$,"BaCon DPI Calculator - ", version$,NL$
        PRINT "Usage: dpicalc hres vres size", NL$
        PRINT "Where:"
        PRINT "  hres = horizontal resolution in pixels"
        PRINT "  vres = vertical resolution in pixels"
        PRINT "  size = diag. size of screen in inches",NL$
        PRINT "Example: dpicalc 1280 1024 19", NL$
        END
        RETURN TRUE
END FUNCTION

FUNCTION GETARGS()
        SPLIT ARGUMENT$ BY " " TO array$ SIZE dimension
        IF dimension < 4 THEN
                USAGE
        ELSE
                IF VAL(array$[1]) > 0 AND VAL(array$[2]) > 0 AND VAL(array$[3]) > 0 THEN
                        hres   = VAL(array$[1])
                        vres   = VAL(array$[2])
                        dsize  = VAL(array$[3])
                ELSE
                        PRINT NL$, "DPI Calculator: Input arguments contain bad values."
                        USAGE
                END IF
        END IF
        RETURN TRUE
END FUNCTION

FUNCTION SHOWRESULTS()
        STR1$ = "Calculated DPI for screen resolution of "
        PRINT NL$, STR1$, hres,"x",vres,"pixels and ",dsize, " in."," diagonal = ", mydpi, NL$
        RETURN TRUE
END FUNCTION

' *****************
' END FUNCTIONS
' *****************


' *****************
' MAIN
' *****************

GETARGS
mydpi = CALCDPI(hres, vres, dsize)
SHOWRESULTS
END

' *****************
' END MAIN
' *****************
Lastly, you can use some combination of gdk and pango calls, which I have in the past, but can't right now find to give you an example. :(

With kind regards,
vovchik

linuxcbon
Posts: 1312
Joined: Thu 09 Aug 2007, 22:54

#20 Post by linuxcbon »

L18L wrote:I have inserted HUGOPTIONS("BASEXFTDPI 66") and compiled. See the result, your original and mine :roll:
Why 66 ?

Post Reply