You are not logged in.

#51 2013-03-31 03:21:02

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,510
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

What would you want interrobang to read from the stdin?  What should it do with what is read from the stdin?  All the completion work is offloaded to other tools - so you can use whatever tool you wish to generate completion options.

You could send whatever you would feed into dmenu's stdin into a temp file, then use a completion tool that compares against that temp file.

For example, you could have the completion tool either do the following commands, or envoke a script with these commands:

while read line; do [[ "$line" =~ ^$2 ]] && echo $1$line; done </tmp/interrobang_options

Specifically, that could be in ~/.interrobangrc as

completion        prefix="%s" pattern=%s; while read line; do [[ "$line" =~ ^$pattern ]] && echo $prefix$line; done </tmp/interrobang_options

or as `completion      myscript "%s" %s` where that code is in a script called myscript.

Then invoke interrobang as follows.

echo -e "one\ntwo\nthree" > /tmp/interrobang_options && interrobang

I've just looked into surf - you can send a url to the current window by setting the _SURF_URI property with xprop.

Last edited by Trilby (2013-03-31 03:38:35)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#52 2013-03-31 07:54:25

megadriver
Member
From: Spain
Registered: 2010-02-03
Posts: 58
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Thanks for the Unicode support! It's working great here.

Now this is officially the best launcher ever! smile

Offline

#53 2013-03-31 08:07:19

kaszak696
Member
Registered: 2009-05-26
Posts: 543

Re: Interrobang: a tiny menu packing a big bang (syntax)

A small bug here, unicode chars like ąść have to be deleted by pressing backspace twice.


'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard

Offline

#54 2013-03-31 10:48:04

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,510
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Yup, that's the minor bug I mentioned above that made me not want to push the new code.  It will be an easy fix - I just hadn't gotten around to it yet.

Edit: got around to it.  That should be fixed now.

Last edited by Trilby (2013-03-31 11:11:26)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#55 2013-03-31 11:42:10

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,510
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Coming soon: bang-specific completion options.

A potential use would be with a script like the following, call the script "netbang" (so far completely untested, but I'll update this as it starts to work):

#!/bin/bash

iface=wlan0
bang="!net"
search="$1$2"
search="${search#$bang }"

## code here to generate list of networks:
if [[ ! -f /tmp/netbang.run ]]
	while read line; do
		echo $line >> /tmp/netbang.run
	done < <(iwlist $iface scan | awk '/ESSID:/ {$1=""; print $0;}')  
fi

## code here to match and provide completion options
while read line; do
	[[ "$line" =~ "^$search" ]] && echo "$bang $line"
done </tmp/netbang.run

Then in ~/.interrobangrc, you could have the following lines

completion-!net    netbang "%s" %s
!net               net-tool-connect %s

So when you run interrobang and type !net<TAB> you will be provided with a list of available essids, as you type and hit <TAB> it will provide only those options that match.  When you hit enter, it will run "net-tool-connect" passing the selected essid.  (net-tool-connect is just a placeholder for your favorite network connection tool/script).

------

I've just pushed this bang-dependent tab completion to github.  It is brand new and not well tested, so be patient.  Also note the change to the interrobangrc file - "TAB()" should replace "completion".

Last edited by Trilby (2013-03-31 12:53:18)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#56 2013-04-01 08:36:22

Baryon
Member
Registered: 2011-08-12
Posts: 63

Re: Interrobang: a tiny menu packing a big bang (syntax)

Hi,
Just been playing with interrobang and the new bang-specific completions don't seem to work for me. As a simple test:

TAB(pdf)  compgen -P "%s" -cf Downloads/%s

That doesn't work, although

TAB()  compgen -P "%s" -cf Downloads/%s

does work.

Offline

#57 2013-04-01 09:59:59

megadriver
Member
From: Spain
Registered: 2010-02-03
Posts: 58
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

I can also confirm the above.

Offline

#58 2013-04-01 10:46:28

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,510
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Oops, one little typo in code can sure throw things off.  That should be fixed now.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#59 2013-04-01 15:07:41

megadriver
Member
From: Spain
Registered: 2010-02-03
Posts: 58
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Yes, it's working perfectly here now.

Offline

#60 2013-04-02 03:16:16

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,058

Re: Interrobang: a tiny menu packing a big bang (syntax)

I am having trouble setting the font to Terminus size 12. Using the commented size 14 works fine:

-*-terminus-medium-r-normal--14-140-72-72-c-*-*-*

However either of the following two result in interrobang not working (appearing):

font		-*-terminus-medium-r-normal--12-*-*-*-c-*-*-*
font		-*-terminus-*-*-*-*-12-*-*-*-*-*-*-*

Offline

#61 2013-04-02 04:00:47

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,510
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

That is odd, but I can confirm that those font strings fail.  I use terminus 12 on my netbook and this font string works:

font		-*-terminus-medium-r-normal--12-120-72-72-c-*-*-*

I'm not sure why the more general ones wouldn't though.  I'm still learning about font sets, which are loaded a bit differently in Xlib than just loading a single font.  Hopefully I'll figure out *why* it works this way, but for now see if my font string works for you too.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#62 2013-04-02 04:10:22

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,058

Re: Interrobang: a tiny menu packing a big bang (syntax)

Thanks that string works.

Offline

#63 2013-04-02 06:55:35

Richjn
Member
From: Perth (Australia)
Registered: 2004-03-22
Posts: 32

Re: Interrobang: a tiny menu packing a big bang (syntax)

Trilby wrote:

What would you want interrobang to read from the stdin?

Probably just me misunderstanding how surf currently handles url input which seems to pipe xprop into dmenu so I was hoping to just substitute interrobang if stdin was ever added. Sorry if I have just got this wrong.

#define SETPROP(p, q) { \
	.v = (char *[]){ "/bin/sh", "-c", \
		"prop=\"`xprop -id $2 $0 | cut -d '\"' -f 2 | dmenu`\" &&" \
		"xprop -id $2 -f $1 8s -set $1 \"$prop\"", \
		p, q, winid, NULL \
	} 
Trilby wrote:

I've just looked into surf - you can send a url to the current window by setting the _SURF_URI property with xprop.

I have tried and failed with xprop directly i.e

 xprop -id <window id> -f _surf_URL 8s -set _SURF_URL

This works, however the problem is getting the window id as it seems ttwm is not setting the window name  i.e

 xprop -root _NET_WM_NAME

returns "not found"

Maybe I'm just missing the obvious but I can't see how it currently works with the surf / xprop code.

Richard

Offline

#64 2013-04-02 11:10:05

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,510
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

I did install surf to tinker with it a bit.  You should not need a _NET_WM_NAME for anything with surf.

The following works for me to change the surf url:

xprop -id <windowID> -f _SURF_URL 8s -set _SURF_URL "bbs.archlinux.org"

The only limitation is that this *sets* the url, but it seems surf does not refresh itself upon receiving propertychange events.  So if you just run the above command from a terminal (or eventually interrobang) you'd also need to do something in surf to trigger a page refresh.

I see two solutions to this: 1) call interrobang from a surf function similar to how dmenu is used, or 2) add a refresh in response to a propertychangenotify event in surf.  The later would seem much cleaner to me - I don't know why suckless didn't do that themselves.  The former would be a bit easier though as there would be no need to manage surf's window id numbers outside of surf.

For 1, I could add a feature to interrobang: silent bangs (a hush-bang?).  This would be a bang passed via the command line, so you don't have to type it explicitly.  We could have the following in our interrobangrc:

!echo        echo %s

Then call interrobang from a surf macro something like the following:

#define  SETPROP(p,q)  { \
        .v = (char *[]{ "/bin/sh", "-c", \
                "prop=\"`interrobang echo`\" &&" \
                "xprop -id $2 -f $1 8s -set $1 \"$prop\"", \
                p, q, winid, NULL \
        }

I'll add the "hush-bang" option today, and I'll see if I can get this to work with surf.

EDIT: I've just pused the hushbang option to github.  This is used by passing the name of the bang (w/o bangchar) as a parameter on the command line.  I'll try this out with surf over the next few days.

EDIT2: I just installed surf (built with abs) and included the above "patch" to config.h - it works as intended: interrobang can be used to enter urls or search terms for finding.

Last edited by Trilby (2013-04-02 18:36:29)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#65 2013-04-02 17:25:58

bgc1954
Member
From: Edmonton, AB, Canada
Registered: 2006-03-14
Posts: 1,119

Re: Interrobang: a tiny menu packing a big bang (syntax)

Hey Trilby, thought I'd give interrobang a go and it worked fine right out of the box on my desktop.  My netbook didn't like it quite as well and it wouldn't appear at all but as I read up a few posts, I saw anonymous_user was having trouble with the same font definition that I was using.  Once I plugged in your font string, it worked!

Funny thing is that when I was trying different things with fonts on the netbook and I even left the default interrobangrc setting "font fixed" and that didn't work either, although it did with my desktop.


Time is a great teacher, but unfortunately it kills all its pupils ... - Louis Hector Berlioz

Offline

#66 2013-04-02 17:30:14

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,510
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Hmm, I also can't use "font    fixed" on my netbook.  I will have to figure this out.

"-misc-fixed-" works on my netbook where "fixed" doesn't.  I really don't get how these fonts are looked up.

I could put a simple default in the code incase the lookup fails, but one reason I don't like this is when I try tinkering with fonts in other programs, I often want to know how a new font looks ... so I put the new font in the config and the program launches normally but looks ugly.  Is it an ugly font, or did the program fallback on an ugly default.  At least if the program fails, I know to adjust the config or rehash my font database.  In otherwords, at least I know something went wrong, rather than getting a false bad impression of the font.

So adding a default would be "nicer", but I'll let interrobang instead either get the font the user asked for, or do nothing at all.


Out of curiosity, is "fixed" by itself an actual font alias on your computers?  It is on my netbook, and I'll try at home later today.  The easy way to check, if you have xorg-xlsfonts installed, is to run `xlsfonts -fn fixed`.

Last edited by Trilby (2013-04-02 17:44:04)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#67 2013-04-02 18:17:08

bgc1954
Member
From: Edmonton, AB, Canada
Registered: 2006-03-14
Posts: 1,119

Re: Interrobang: a tiny menu packing a big bang (syntax)

For me, xorg-xlsfonts is not installed but I do still get fixed fonts showing in xfontsel--I think they're supplied by the xorg-fonts-misc package which I do have installed.  I also found it strange that trying "-*-tamsyn...etc" does not work but "-misc-tamsyn..etc" works.  Fonts are still a mystery to me it seems.


Time is a great teacher, but unfortunately it kills all its pupils ... - Louis Hector Berlioz

Offline

#68 2013-04-02 18:25:08

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,510
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

It's not an issue with whether fixed fonts are installed, it is whether the font alias (/usr/share/fonts/*/fonts.alias) "fixed" exists or not and what it is aliased to.  xlsfonts will show all the available fonts and aliases - which is just a bit easier than grepping each fonts.alias file ... though I just learned that bash can do mid-path globbing (this should go in the oh nice thread):

grep -E "^fixed" /usr/share/fonts/*/fonts.alias

InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#69 2013-04-02 19:04:18

bgc1954
Member
From: Edmonton, AB, Canada
Registered: 2006-03-14
Posts: 1,119

Re: Interrobang: a tiny menu packing a big bang (syntax)

This is what I get when I use your grep command

 $  grep -E "^fixed" /usr/share/fonts/*/fonts.alias
/usr/share/fonts/cyrillic/fonts.alias:fixed  -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-koi8-r
/usr/share/fonts/misc/fonts.alias:fixed        -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1

if that helps at all.


Time is a great teacher, but unfortunately it kills all its pupils ... - Louis Hector Berlioz

Offline

#70 2013-04-02 19:21:25

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,510
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Hmm, well a little reading of the Fonts page on the wiki cleared this up.  `fc-match fixed` is the more relevant command.  On my netbook, where that fails as a font string, fc-match returns a font for "fixed" which I don't have installed.

EDIT: scratch that, it's installed, it's just not in the fonts.alias file.

Last edited by Trilby (2013-04-02 19:23:09)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#71 2013-04-02 21:14:56

Richjn
Member
From: Perth (Australia)
Registered: 2004-03-22
Posts: 32

Re: Interrobang: a tiny menu packing a big bang (syntax)

Trilby wrote:

The only limitation is that this *sets* the url, but it seems surf does not refresh itself upon receiving propertychange events.  So if you just run the above command from a terminal (or eventually interrobang) you'd also need to do something in surf to trigger a page refresh.

Doh! I feel such a newbie


Trilby wrote:

#define  SETPROP(p,q)  { \
        .v = (char *[]{ "/bin/sh", "-c", \
                "prop=\"`interrobang echo`\" &&" \
                "xprop -id $2 -f $1 8s -set $1 \"$prop\"", \
                p, q, winid, NULL \
        }

Works a treat, thanks for looking into this, I can now loose demenu.


Richard

Offline

#72 2013-04-10 14:24:44

Baryon
Member
Registered: 2011-08-12
Posts: 63

Re: Interrobang: a tiny menu packing a big bang (syntax)

Interrobang is very nice. Thanks Trilby.
One thing I'd still love to have, though, is the ability to see all the options before I select them - but that's something I crave even when using Bash completion in the terminal, so it's not really a feature for Interrobang as such. I tried to make a little test script which would 'tee' the output of compgen to dzen2 so that the completion options would pop up on the screen whilst you were typing - the main obstacle to this working, it seems, is the fact that dzen2 isn't going to run asynchronously. In other words, interrobang wants to wait for dzen2 to exit before it will carry on accepting input (even if it runs with & in the script).

For what it's worth, here's my pdf tab, which filters compgen output so that I complete just on directories and pdf files within them. It seems to work, although I'm not really an expert on any of these things so I could have made a mistake somewhere:

TAB(pdf)        prefix="%s" pattern=%s; { compgen -P "$prefix" -d $pattern; compgen -P "$prefix" -f $pattern | grep -Ei ".pdf$"; }

Offline

#73 2013-04-10 14:51:45

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,510
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Thanks Baryon,

I just slapped together a quick listing in interobang of the completion options.  Enable it by adding the line "show options" to your interobangrc.  It's brand new, so undoubtedly will need some testing.  If it works out well I may spruce it up just a bit with some line highlighting - but for now it's very basic: it just shows the list.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#74 2013-04-10 15:05:55

HalosGhost
Member
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 1,485
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Trilby wrote:

I just slapped together a quick listing in interobang of the completion options.  Enable it by adding the line "show options" to your interobangrc.  It's brand new, so undoubtedly will need some testing.  If it works out well I may spruce it up just a bit with some line highlighting - but for now it's very basic: it just shows the list.

This sounds really exciting actually. However, it does not appear to work on my end. I still only see the normal behavior. I tried running interrobang from a terminal to see if it threw an error, but it throws none. Thoughts?

All the best,

-HG


"All errors are ᴘᴇʙᴋᴀᴄ errors—It's just a matter of narrowing down which keyboard and chair." -Trilby
\ldots

Offline

#75 2013-04-10 15:59:52

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,510
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Odd - no, no thoughts of hand.  You have "show options" set in the rc file, and you can tab through completion options, but they don't show in a list, is that right?

One thought, I suppose: do you have interrobang on the bottom of your monitor?  Currently, the list just pops out from the bottom of the window - so it may be offscreen if it is already on the bottom.  This will certainly have to be revised to work for such cases - this was really just thrown together in 5 minutes, if it stays it will need some development.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

Board footer

Powered by FluxBB