Re: [9fans] htmlroff -ms footnotes
okay, yeah, .SH calls .RT calls .BG calls .rn FJ FS you could drop -ms but you probably don't want that either... you could use ms2html :) you could write your own macros :))) umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T530822947a31ba06-Mbe3ae7b1d9fa62fcf9a2f264 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] htmlroff -ms footnotes
It isn't the Abstract, it's the .SH, which calls .RT, which somehow changes the FS macro. If you replace .SH with .RT in test.ms nothing changes; if you delete it altogether the missing footnotes appear. If you put .pm above and below .SH (or .RT) and run: ; htmlroff -ms -mhtml test.ms >/dev/null |[2] grep FS you can see that the FS macro is being messed with. I'll dig further... umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T530822947a31ba06-M34d92b1177885d8baf1d0ab6 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] wctl
; read -c 72 /dev/wctl rio(4) umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tf13f657beb7b12c0-Ma0337129de0681f834f7e7c7 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] use of plumber for new rule
I think you probably want: plumb start rc -c 'kertex/divps '$wdir'/'$0' | page -w' umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tce7385fe52c532d6-M95c2618ac3b3dd2f17c75c24 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] use of plumber for new rule
Here's my rule for manpages: data matches (.+)\(([0-9])\) arg isfile /sys/man/$2/$1 plumb start rc -c 'man -t '$2' '$1' | plumb -id image' which replumbs the cmd output to the image port; then: dst is image plumb to image plumb client rc -c 'window -r 380 0 1600 900 ''echo -n page >/dev/label; bind /dev/mordor /dev/label; page -i -p180 -m64''' either sends it to any existing page instance or else starts a new one to send it to. Worth noting I am using 9front's version of page, which listens on the image port; can't recall if the original listens on the postscript port in a similar way: probably. If you just want to pop open a new window with your dvi each time you can use a plumb start rule that does whatever you want; something like: data matches '([a-zA-Z¡-�0-9_\-.,/]+)\.(dvi|DVI)' arg isfile $0 plumb start window kertex/dvips $0 '|' page There are other workflows too, if what you want is a tight loop for editing a document and seeing the new version. Some people use a watch(1) program that runs a command whenever a given file changes. I prefer to tie the file write and doc gen to a single command using (9front) sam's ^ cmd, which sends its output to sam's command window: ^echo w; window troff $% '|' page The last shell command is remembered, so subsequent write'n'reviews are a simple ^ thereafter. umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tce7385fe52c532d6-Me347adb350456cff65756620 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] troff and fonts
Someone in another forum chased down the sdf thing. Here is an example: https://fontforge.org/downloads/Big5.txt and here is the format: https://manpages.ubuntu.com/manpages/jammy/man1/ttf2tfm.1.html#subfont%20definition%20files Hope that helps, umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T5e2e59d44fa0cbdc-Mcfdd803544c9c0cef6d6d036 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] troff and fonts
> I've some difficult to generate a "PS 1 Multiple Binary", > Fontforge ask me for a "speficication file" during the pfb generation... > What is it ? Sorry, I don't recall. Things may have changed since I last performed this task. It's mentioned here: https://fontforge.org/archive/generate.html umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T5091c0751c09-M45d4ec39bfb47669e432a2e1 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] troff and fonts
Here are my notes & a script for troff fonts: http://runjimmyrunrunyoufuckerrun.com/fonts/ umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T5091c0751c09-M44d0b0baa163a1282f8973ac Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] sam and 'here documents' on Unix [WAS: Re: Making multiple changes to dot using sam -d]
hmm, interesting. ^ is indeed very useful; making it work in sam -d is probably the correct thing to do but here's a quick hack. (9front specific, tho you can probably figure out another way to pretend you typed.) umbraticus ; fn f{echo ,x/red/c/blue >/dev/kbdin} ; sam -d -. a I hired a red redemptionist . !f ,x/red/c/blue , I hiblue a blue blueemptionist -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tcf06324837558cea-M37afd51dab499eefb093aa10 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Deleting lines in sam - d
I mean, if you really want it, you can ,|awk '{print NR "\t" $0}' then ,x/^[0-9]+ /d or something. umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tc5c492077a61275c-Mf73fea5ddae7354548491a99 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] acme & sam text selection and delete deletes extra character
Don't forget Esc cuts a selection. umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T06d3bdd208f5a90b-Maa4736ab2beb35086413d070 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Deleting lines in sam - d
= prints line number 3,7d deletes some lines Setting and working with the mark may also suit your problem find a place, press k, find another place, then ',.d or .,' deletes everything in between. Multiple marks à la ed would be a nice addition to sam. umbraticus P.S. Here's a patch to make = more sensible (ie. plumbable): --- a/sys/man/1/sam Wed Apr 27 19:24:07 2022 +++ b/sys/man/1/sam Sat Apr 16 02:53:35 2022 @@ -403,10 +403,10 @@ Set dot. .TP .B = -Print the line address and character address of the range. +Print the file name and line address of the range. .TP .B =# -Print just the character address of the range. +Print the file name and character address of the range. .PD .SS File commands .PD 0 --- a/sys/src/cmd/sam/sam.c Wed Apr 27 19:24:07 2022 +++ b/sys/src/cmd/sam/sam.c Sat Apr 16 02:53:35 2022 @@ -688,11 +688,27 @@ } void -printposn(File *f, int charsonly) +printposn(File *f, int chars) { Posn l1, l2; + char *s; - if(!charsonly){ + if(f->name.s[0]){ + if(f->name.s[0]!='/'){ + getcurwd(); + s = Strtoc(); + dprint("%s", s); + free(s); + } + s = Strtoc(>name); + dprint("%s:", s); + free(s); + } + if(chars){ + dprint("#%lud", addr.r.p1); + if(addr.r.p2 != addr.r.p1) + dprint(",#%lud", addr.r.p2); + }else{ l1 = 1+nlcount(f, (Posn)0, addr.r.p1); l2 = l1+nlcount(f, addr.r.p1, addr.r.p2); /* check if addr ends with '\n' */ @@ -701,11 +717,7 @@ dprint("%lud", l1); if(l2 != l1) dprint(",%lud", l2); - dprint("; "); } - dprint("#%lud", addr.r.p1); - if(addr.r.p2 != addr.r.p1) - dprint(",#%lud", addr.r.p2); dprint("\n"); } -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tc5c492077a61275c-M738ed39a9ebb9a95372a4aad Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] acme and sam - mouse suggestions?
> small ones seem to me like a pain to point, and the large ones look > like hard to make chords with the big ball in the middle. Could you > share your experience? I use a Kensington Expert which I guess falls into the big ball in the middle category. Honestly, most of the time I click/chord with my left hand on the thinkpad's trackpad buttons while rolling the ball with my right hand, but chording with the trackball buttons is also fine. The scrollwheel thing is pretty nice too. umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T49f3cceea70d2b61-M7e16480b278fcd704279bcb1 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] acme and sam - mouse suggestions?
Trackballs also often have more than two real buttons. umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T49f3cceea70d2b61-Mba1f4f1caaa4c6c3a0189de1 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Autoexpand in sam
Another related convenience is to have a rule somewhere near the bottom of your plumbing file that pops up a window and prints the dictionary listing for the word you plumbed. If I could remember who it was I would thank the person who recommended this to me because I use it all the time. If you are confident with the first part of a word look(1) could be handy. You could also write a filter that transposes letters until it finds a match in /lib/words. Some toys along these lines: http://runjimmyrunrunyoufuckerrun.com/rc/anagram http://runjimmyrunrunyoufuckerrun.com/rc/bee umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T0e2541a723ce90e5-M58401f8a2d81fe9d6ffc48f7 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Autoexpand in sam
> autocorrect in sam not really but you can ,>spell -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T0e2541a723ce90e5-Mbb8fbc041f3be84400daf880 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] UTF-8 characters in acme
> How to write UTF-8 caracters keyboard(6) -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T0d54d4b593281935-Mb9d3caaf9c167393db658f43 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] A few more questions about sam
> Is there a way to customise the starting layout of sam? I have this patch, which changes the starting geometry of cmd window and opens files fullscreen immediately instead of having to sweep a rect: diff -u /sys/src/cmd/samterm/main.c ./main.c --- /sys/src/cmd/samterm/main.c Thu Apr 30 10:24:09 2020 +++ ./main.cSat Jan 16 16:08:33 2021 @@ -43,7 +43,7 @@ scratch = alloc(100*RUNESIZE); nscralloc = 100; r = screen->r; - r.max.y = r.min.y+Dy(r)/5; + r.min.x = r.max.x-Dx(r)/4; flstart(screen->clipr); rinit(); flnew([0], gettext, 1, ); diff -u /sys/src/cmd/samterm/menu.c ./menu.c --- /sys/src/cmd/samterm/menu.c Wed Jan 18 13:12:54 2012 +++ ./menu.cMon Jun 21 21:53:12 2021 @@ -205,7 +205,8 @@ Rectangle r; Text *t; - if(getr() && (t = malloc(sizeof(Text{ + r = screen->r; + if(t = malloc(sizeof(Text))){ memset((void*)t, 0, sizeof(Text)); current((Flayer *)0); flnew(>l[0], gettext, 0, (char *)t); kvik also has some window placement hacks: https://git.sr.ht/~kvik/ham There was a video demo somewhere. To understand sam's automatic window placement around the cmd window, resize cmd to a square in the centre and experiment with creating new windows by clicking in various regions around the square. There is afaik no way to save & reproduce window geometry; as mentioned above, I just open everything fullscreen. > http://runjimmyrunrunyoufuckerrun.com/rc/s I wrote this (improvements welcomed) but it relies on the ^ command and $% and $%dot variables which may not exist in your version of sam. I believe it was brought to your attention for these functions, which load a previous editing session: # ^d [file] # save unwritten changes and dump sam state to file fn d{ rfork e switch($#*){ case 0 dump = /tmp/sam.dump case 1 dump = $1 case * echo !u d exit } d = `{pwd} echo 'X/^''/w' echo !rm -f $dump echo 'Y/^..\./!echo `{cleanname -d' $d '$%}^'':#''^$%dot(2)^'',#''^$%dot(3) >>' $dump echo 'X/^..\./!echo `{cleanname -d' $d '$%}^'':#''^$%dot(2)^'',#''^$%dot(3) >>' $dump } # !l [file] # load dump file fn l{ switch($#*){ case 0 xargs -n1 plumb Can someone point me to a specific resource that explains > these expressions in more detail than does the sam man and > sam tut? http://sam.cat-v.org/ has a cheat sheet & some other resources. What is sam_tut.pdf missing that you would like to understand? umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T3107cd3bc536dc63-M51c4690187627a0d4fc416e0 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] sam label and rio snarf buffer
> I've to think about the plumber and the the named pipe to be able > to plumb a file and bring to the front a sam instance if it has > the file open, moving the file's window to the front with dot set at > the address, if one is given. I have this: diff -u /sys/src/cmd/samterm/plan9.c ./plan9.c --- /sys/src/cmd/samterm/plan9.cMon Jun 21 18:44:27 2021 +++ ./plan9.c Mon Jun 21 19:51:51 2021 @@ -215,6 +215,11 @@ which = i; send(c, ); } + if((n = open("/dev/wctl", OWRITE)) >= 0){ + write(n, "current\n", 8); + write(n, "unhide\n", 7); + close(n); + } } } -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tc809ad6007ccd2bd-M619b1c2110ae7f980ce9f1c9 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Help with a sam cleanup script
> bash: fg: %: no such job The % is a prompt: ignore it. I think your script boils down to something like: ,x/\*|^ +| +$/d ,x/ +//c/ ,x/[‘‘’’“”‘’]/c/" ,x/\\p|\\b/c/\n\n\n ,x/\n\n+/c/\n umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T10b1d559ae7d981e-M75c05feaef122451a0351d21 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Help with a sam cleanup script
also worth mentioning the ^ command if you're using 9front's sam. put your sam commands in script like this: #!/bin/rc cat << STOP x/ +/c/ x/\*/d STOP then you can run ^script and it will apply the commands. Note that if you leave off the commas before the commands, as I have above, you will have to set dot before running ^ but this allows more flexibility, eg. you can apply the edits to a section of a document instead of always the whole thing. One step at a time, though. It would be neat if you could use ! ^ < > _ | in conjunction with X… umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T10b1d559ae7d981e-M2e7ac6c9ebf53e2d3cd2bfec Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Help with a sam cleanup script
you probably want to use ssam (no wq required) what isn't working? some suggestions: ,x/‘‘|’’/s//"/ and ,x/‘|’/s//"/ → ,x/[“‘’”]/c/" .x s/\*//g → ,x/\*/d ,x/^ +/s/// → ,x/^ +/d ,x/ +$/s/// → ,x/ +$/d ,x/ +/s// / → ,x/ +/c/ / take your time, learn the language, & enjoy umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T10b1d559ae7d981e-M7713c653ed3bb3ebbe17be73 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] ed regular expressions in sam
or: ,x/^/i/echo " ,x/$/i/" -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Te7fcdc06a68bb777-M3a70c9ddc3e626951d6349fb Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Command to set samterm label
Sorry, didn't mean to come off as insisting you had to do it my way (I am guilty of hacking all kinds of things into my own samterm); just wanted to point out there are other ways besides adding a new command to sam. > The next step is add an option (or better an environment variable) > to use the rio snarf buffer directly. There is a patch for this floating around somewhere: perhaps whoever wrote it can chime in. Below is a quick illustration of the other thought I had, having label reflect the most recently topped buffer, in case you are or anyone else is interested. umbraticus diff -u /sys/src/cmd/samterm/main.c ./main.c --- /sys/src/cmd/samterm/main.c Thu Apr 30 10:24:09 2020 +++ ./main.cMon Jul 19 23:36:12 2021 @@ -150,6 +150,7 @@ current(Flayer *nw) { Text *t; + int fd; if(which) flborder(which, 0); @@ -160,8 +161,13 @@ buttons(Up); t = (Text *)nw->user1; t->front = nw->l[0]; - if(t != ) + if(t != ){ work = nw; + if((fd = open("/dev/label", OWRITE)) >= 0){ + fprint(fd, "sam %s", (char*)name[whichmenu(t->tag)] + 1); + close(fd); + } + } } which = nw; } @@ -170,11 +176,15 @@ closeup(Flayer *l) { Text *t=(Text *)l->user1; - int m; + int m, fd; m = whichmenu(t->tag); if(m < 0) return; + if((fd = open("/dev/label", OWRITE)) >= 0){ + write(fd, "sam", 4); + close(fd); + } flclose(l); if(l == which){ which = 0; -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tf1e211daf823c0e0-M2dfbf5d65c86fcf89c315484 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Command to set samterm label
> That's run by sam, not samterm. Ah, I see; /dev/label is not available to the remote end of sam -r. Do people use sam -r a lot, instead of [r]cpu -c sam? Is it appreciably faster? surely having /mnt/term & local /dev in the namespace is nice? Anyway, I see your point. Still not convinced setting the window label belongs inside the editor (or the editor's wm) since it is a feature of rio... If you use winwatch some have patched it to make setting label more convenient, or you could have a script that does: ; label sam $files; bind /dev/null /dev/label; sam $files I discovered this trick when I wanted my persistent page always to be labeled as such rather than change based on whatever it is displaying. > It's for using multimple instances of sam. Sure, was just pointing out if !label was sufficient you could simplify your patch to just tweaking the initdraw call. (Maybe it would be nice to print all files listed on the command line) On the odd occasion I have multiple sams, I prefer to set the label myself to project1, project2 but having the filename(s) there initially might be nice. You could even get clever and have the label change to reflect the most recently active buffer. umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tf1e211daf823c0e0-M1e8dc73ec3b6f44f7e047e5b Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Command to set samterm label
> This patch adds a command 'l' to set the label, and sets it at > startup as described above. meh; you can already run !label blah from inside sam not sure the label-on-startup adds much… but I guess you could just add that at the call to initdraw. umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tf1e211daf823c0e0-M8c02d90b20788e858568ad92 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Alternative to fine-grained mouse usage?
nothing's tying you to sam syntax: ,|awk '{print NR "\t" $0}' then undo. umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T716c5aa0e2aa8a27-Mc258d9e136ffe16b7aeb04fa Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Alternative to fine-grained mouse usage?
> taking advantage of Fitts' law in UI interactions another fairly standard practice: organise window management to leave a pixel or two around the edge to allow slamming mouse to the nearest extremity in order to access rio b3 menu. blasphemy: I occasionally wonder how difficult it would be to implement windows-style Ctrl+←/→ word boundary jumping, maybe even Shift to select… umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T716c5aa0e2aa8a27-M962e5aa87312fb3af7063d84 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Alternative to fine-grained mouse usage?
> needing to copy/paste previous commands in terminal windows, etc. see " and "" scripts The finnicky mouse stuff is indeed an annoyance in acme. I use sam & a trackball & a huge font. some conveniences have been added to sam, ^B and ^G to switch from sam window and back to buffer. Make use of <>!| commands and so on... standard ^W ^U ^A ^E stuff... plumbing, searching, command language. rio window placement mostly automated. I have sam just open files fullscreen automatically, which is quite nice… umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T716c5aa0e2aa8a27-Ma610880200ac6ba2e64f4e5b Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] tbl page width
.LL is to early for tbl but even .ll doesn't do anything in the following. ; {echo .ll 28c; echo .sp 4c; echo .TS; read -c 30 https://9fans.topicbox.com/groups/9fans/T8da23d19a22963e2-M3c72233bbcfbd7760d9d35a1 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] 9term, insta scroll to bottom?
> I tried ^ b, it has the same effect as pg down. It doe snot take me to the > bottom Yeah. Are you pressing Del to kill the cat? umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T13b7a14fa28da183-M3f2ab540cd456d40b6c912bd Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Request for (constructive?) comments: Plan 9 : 2020
; 9fs docs.google.com srv: timeout establishing connection to net!docs.google.com!9fs -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T7414e0ecd12c8643-Me5e7390dda458d519a62ae21 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Accessing old Bell labs URLs
http://9p.io is what you want. Your example: http://9p.io/magic/man2html/1/acme see also http://man.cat-v.org -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tda617782a458b1cf-M4b92ae63af31badd6999bebf Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] auth server on a different port
I use the instructions here: http://fqa.9front.org/fqa8.html#8.4.8.2 to drawterm past the firewall at work; perhaps useful? umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T438cfac2481e3602-Md27f232343773d1082ca85e8 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] printing from Plan 9
I use this with lp(1): HP Color LaserJet Pro MFP M281fdw I just looked for something that could speak postscript. umbraticus
Re: [9fans] Someone made a Wayland compositor based on Rio, Wio
> you'll need to install hubfs first not true; just: srv -c tcp!107.191.50.176!9997 gridchat /n/chat then read and write from /n/chat/chat in whatever manner you please.
Re: [9fans] Someone made a Wayland compositor based on Rio, Wio
info trav
Re: [9fans] focus window on plumb
Even simpler, run the following program in riostart thus: window 'raiseplumb web & mothra' window 'raiseplumb edit & sam' could probably even be an rc script #include #include #include void main(int argc, char **argv) { Plumbmsg *m; int port, wctl; if(argc != 2) sysfatal("usage: %s port", argv[0]); if((port = plumbopen(argv[1], OREAD)) < 0) sysfatal("couldn't open plumb port %s", argv[1]); if((wctl = open("/dev/wctl", OWRITE)) < 0) sysfatal("couldn't open /dev/wctl"); for(;;){ if((m = plumbrecv(port)) == nil) sysfatal("error on plumb port %s", argv[1]); plumbfree(m); fprint(wctl, "unhide"); fprint(wctl, "current"); } } umbraticus
[9fans] focus window on plumb
Hi 9fans, I wrote the attached to listen on a plumb port and make a given window current when it gets a message. I'm not sure how much I will like it: it's nice not to have to hunt for a buried client program after plumbing something; on the other hand, sometimes I like to plumb a few urls, images, or pdfs and view later. Still, I thought I'd figure out a way to do it. The first argument is the port to listen on and the second is a string to match against the label of the window to raise. In my riostart I start my main rc window like this: window 'raiseplumb web mothra! & raiseplumb edit sam & raiseplumb image page & cat todo; label rc; rc' (After setting page's label I bind /dev/null over it so it isn't overwritten) The program could be improved but it seems to work well enough for a quick implementation. Other solutions I thought of were to prime the windows I want to raise by posting their wctl in /srv (since /dev/wsys isn't in the plumber's namespace) then writing plumb rules to first raise the window by mounting the wctl, then plumb to the port; or else patch the client programs to raise themselves when they get a plumb. Has anyone else wanted/implemented something like this? umbraticus#include #include #include enum{LEN = 128}; int match(int n, char *label) { int fd, len; char s[LEN]; snprint(s, LEN, "/dev/wsys/%d/label", n); if((fd = open(s, OREAD)) < 0) return 0; len = strlen(label); if(read(fd, s, len) != len || memcmp(s, label, len) != 0){ close(fd); return 0; } close(fd); snprint(s, LEN, "/dev/wsys/%d/wctl", n); if((fd = open(s, OWRITE)) < 0) return -1; fprint(fd, "unhide"); fprint(fd, "current"); close(fd); return 1; } void findwctl(char *label) { Dir *d; int fd, n, i; if((fd = open("/dev/wsys", OREAD)) < 0) return; while((n = dirread(fd, )) > 0){ for(i = 0; i < n; i++) if(match(atoi(d[i].name), label)){ free(d); close(fd); return; } free(d); } close(fd); } void main(int argc, char **argv) { Plumbmsg *m; int fd; if(argc != 3) sysfatal("usage: %s fd label", argv[0]); if(strlen(argv[2]) >= LEN) sysfatal("label match too long: %s", argv[2]); if((fd = plumbopen(argv[1], OREAD)) < 0) sysfatal("couldn't open plumb fd %s", argv[1]); for(;;){ if((m = plumbrecv(fd)) == nil) sysfatal("error on plumb fd %s", argv[1]); plumbfree(m); findwctl(argv[2]); } }