Artifact
3006a4a9aaf9d82fce69a1dd0022889c9deb0032 :
File
net2o-notify.fs
— part of check-in
[d7d1d6ddc1]
at
2015-12-09 22:48:19
on branch trunk
— fork+execve-based notify-send call, which removes any possibility to screw the shell
(user:
bernd
size: 5106)
0000: 5c 20 6e 65 74 32 6f 20 74 65 6d 70 6c 61 74 65 \ net2o template
0010: 20 66 6f 72 20 6e 65 77 20 66 69 6c 65 73 0a 0a for new files..
0020: 5c 20 43 6f 70 79 72 69 67 68 74 20 28 43 29 20 \ Copyright (C)
0030: 32 30 31 35 20 20 20 42 65 72 6e 64 20 50 61 79 2015 Bernd Pay
0040: 73 61 6e 0a 0a 5c 20 54 68 69 73 20 70 72 6f 67 san..\ This prog
0050: 72 61 6d 20 69 73 20 66 72 65 65 20 73 6f 66 74 ram is free soft
0060: 77 61 72 65 3a 20 79 6f 75 20 63 61 6e 20 72 65 ware: you can re
0070: 64 69 73 74 72 69 62 75 74 65 20 69 74 20 61 6e distribute it an
0080: 64 2f 6f 72 20 6d 6f 64 69 66 79 0a 5c 20 69 74 d/or modify.\ it
0090: 20 75 6e 64 65 72 20 74 68 65 20 74 65 72 6d 73 under the terms
00a0: 20 6f 66 20 74 68 65 20 47 4e 55 20 41 66 66 65 of the GNU Affe
00b0: 72 6f 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 ro General Publi
00c0: 63 20 4c 69 63 65 6e 73 65 20 61 73 20 70 75 62 c License as pub
00d0: 6c 69 73 68 65 64 20 62 79 0a 5c 20 74 68 65 20 lished by.\ the
00e0: 46 72 65 65 20 53 6f 66 74 77 61 72 65 20 46 6f Free Software Fo
00f0: 75 6e 64 61 74 69 6f 6e 2c 20 65 69 74 68 65 72 undation, either
0100: 20 76 65 72 73 69 6f 6e 20 33 20 6f 66 20 74 68 version 3 of th
0110: 65 20 4c 69 63 65 6e 73 65 2c 20 6f 72 0a 5c 20 e License, or.\
0120: 28 61 74 20 79 6f 75 72 20 6f 70 74 69 6f 6e 29 (at your option)
0130: 20 61 6e 79 20 6c 61 74 65 72 20 76 65 72 73 69 any later versi
0140: 6f 6e 2e 0a 0a 5c 20 54 68 69 73 20 70 72 6f 67 on...\ This prog
0150: 72 61 6d 20 69 73 20 64 69 73 74 72 69 62 75 74 ram is distribut
0160: 65 64 20 69 6e 20 74 68 65 20 68 6f 70 65 20 74 ed in the hope t
0170: 68 61 74 20 69 74 20 77 69 6c 6c 20 62 65 20 75 hat it will be u
0180: 73 65 66 75 6c 2c 0a 5c 20 62 75 74 20 57 49 54 seful,.\ but WIT
0190: 48 4f 55 54 20 41 4e 59 20 57 41 52 52 41 4e 54 HOUT ANY WARRANT
01a0: 59 3b 20 77 69 74 68 6f 75 74 20 65 76 65 6e 20 Y; without even
01b0: 74 68 65 20 69 6d 70 6c 69 65 64 20 77 61 72 72 the implied warr
01c0: 61 6e 74 79 20 6f 66 0a 5c 20 4d 45 52 43 48 41 anty of.\ MERCHA
01d0: 4e 54 41 42 49 4c 49 54 59 20 6f 72 20 46 49 54 NTABILITY or FIT
01e0: 4e 45 53 53 20 46 4f 52 20 41 20 50 41 52 54 49 NESS FOR A PARTI
01f0: 43 55 4c 41 52 20 50 55 52 50 4f 53 45 2e 20 20 CULAR PURPOSE.
0200: 53 65 65 20 74 68 65 0a 5c 20 47 4e 55 20 41 66 See the.\ GNU Af
0210: 66 65 72 6f 20 47 65 6e 65 72 61 6c 20 50 75 62 fero General Pub
0220: 6c 69 63 20 4c 69 63 65 6e 73 65 20 66 6f 72 20 lic License for
0230: 6d 6f 72 65 20 64 65 74 61 69 6c 73 2e 0a 0a 5c more details...\
0240: 20 59 6f 75 20 73 68 6f 75 6c 64 20 68 61 76 65 You should have
0250: 20 72 65 63 65 69 76 65 64 20 61 20 63 6f 70 79 received a copy
0260: 20 6f 66 20 74 68 65 20 47 4e 55 20 41 66 66 65 of the GNU Affe
0270: 72 6f 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 ro General Publi
0280: 63 20 4c 69 63 65 6e 73 65 0a 5c 20 61 6c 6f 6e c License.\ alon
0290: 67 20 77 69 74 68 20 74 68 69 73 20 70 72 6f 67 g with this prog
02a0: 72 61 6d 2e 20 20 49 66 20 6e 6f 74 2c 20 73 65 ram. If not, se
02b0: 65 20 3c 68 74 74 70 3a 2f 2f 77 77 77 2e 67 6e e <http://www.gn
02c0: 75 2e 6f 72 67 2f 6c 69 63 65 6e 73 65 73 2f 3e u.org/licenses/>
02d0: 2e 0a 0a 5c 20 6e 6f 74 69 66 69 63 61 74 69 6f ...\ notificatio
02e0: 6e 73 20 28 6f 6e 20 61 6e 64 72 6f 69 64 20 6f ns (on android o
02f0: 6e 6c 79 20 6e 6f 77 29 0a 0a 36 34 23 30 20 36 nly now)..64#0 6
0300: 34 56 61 6c 75 65 20 6c 61 73 74 2d 6e 6f 74 69 4Value last-noti
0310: 66 79 0a 36 34 23 30 20 36 34 56 61 6c 75 65 20 fy.64#0 64Value
0320: 6c 61 74 65 73 74 2d 6e 6f 74 69 66 79 0a 36 30 latest-notify.60
0330: 2e 30 30 30 30 30 30 30 30 30 20 64 3e 36 34 20 .000000000 d>64
0340: 36 34 56 61 6c 75 65 20 64 65 6c 74 61 2d 6e 6f 64Value delta-no
0350: 74 69 66 79 20 5c 20 6f 6e 65 20 6e 6f 74 69 66 tify \ one notif
0360: 69 63 61 74 69 6f 6e 20 70 65 72 20 6d 69 6e 75 ication per minu
0370: 74 65 20 69 73 20 65 6e 6f 75 67 68 0a 33 20 56 te is enough.3 V
0380: 61 6c 75 65 20 6e 6f 74 69 66 79 2d 6d 6f 64 65 alue notify-mode
0390: 0a 24 46 46 46 46 30 30 20 56 61 6c 75 65 20 6e .$FFFF00 Value n
03a0: 6f 74 69 66 79 2d 72 67 62 0a 35 30 30 20 56 61 otify-rgb.500 Va
03b0: 6c 75 65 20 6e 6f 74 69 66 79 2d 6f 6e 0a 34 35 lue notify-on.45
03c0: 30 30 20 56 61 6c 75 65 20 6e 6f 74 69 66 79 2d 00 Value notify-
03d0: 6f 66 66 0a 0a 3a 20 74 69 63 6b 2d 6e 6f 74 69 off..: tick-noti
03e0: 66 79 3f 20 28 20 2d 2d 20 66 6c 61 67 20 29 0a fy? ( -- flag ).
03f0: 20 20 20 20 74 69 63 6b 73 20 6c 61 73 74 2d 6e ticks last-n
0400: 6f 74 69 66 79 20 36 34 2d 20 64 65 6c 74 61 2d otify 64- delta-
0410: 6e 6f 74 69 66 79 20 36 34 3c 20 3b 0a 56 61 72 notify 64< ;.Var
0420: 69 61 62 6c 65 20 6e 6f 74 69 66 79 3f 20 2d 32 iable notify? -2
0430: 20 6e 6f 74 69 66 79 3f 20 21 20 5c 20 64 65 66 notify? ! \ def
0440: 61 75 6c 74 3a 20 6e 6f 20 6e 6f 74 69 66 69 63 ault: no notific
0450: 61 74 69 6f 6e 20 77 68 65 6e 20 61 63 74 69 76 ation when activ
0460: 65 0a 56 61 72 69 61 62 6c 65 20 6e 6f 74 69 66 e.Variable notif
0470: 79 24 0a 56 61 72 69 61 62 6c 65 20 70 65 6e 64 y$.Variable pend
0480: 69 6e 67 2d 6e 6f 74 69 66 69 63 61 74 69 6f 6e ing-notification
0490: 73 0a 0a 53 65 6d 61 20 6e 6f 74 69 66 79 2d 73 s..Sema notify-s
04a0: 65 6d 61 0a 3a 20 6e 6f 74 69 66 79 3b 20 6e 69 ema.: notify; ni
04b0: 70 20 28 3b 5d 29 20 5d 5d 20 6e 6f 74 69 66 79 p (;]) ]] notify
04c0: 2d 73 65 6d 61 20 63 2d 73 65 63 74 69 6f 6e 20 -sema c-section
04d0: 3b 20 5b 5b 20 3b 0a 3a 20 6e 6f 74 69 66 79 3e ; [[ ;.: notify>
04e0: 20 63 6f 6d 70 2d 5b 3a 20 5b 27 5d 20 6e 6f 74 comp-[: ['] not
04f0: 69 66 79 3b 20 63 6f 6c 6f 6e 2d 73 79 73 2d 78 ify; colon-sys-x
0500: 74 2d 6f 66 66 73 65 74 20 73 74 69 63 6b 20 3b t-offset stick ;
0510: 20 69 6d 6d 65 64 69 61 74 65 0a 0a 3a 20 6e 6f immediate..: no
0520: 74 69 66 79 2d 74 69 74 6c 65 20 28 20 2d 2d 20 tify-title ( --
0530: 29 0a 20 20 20 20 2e 22 20 6e 65 74 32 6f 3a 20 ). ." net2o:
0540: 22 20 70 65 6e 64 69 6e 67 2d 6e 6f 74 69 66 69 " pending-notifi
0550: 63 61 74 69 6f 6e 73 20 40 20 64 75 70 20 2e 0a cations @ dup ..
0560: 20 20 20 20 2e 22 20 4d 65 73 73 61 67 65 22 20 ." Message"
0570: 31 20 3e 20 49 46 20 2e 22 20 73 22 20 20 54 48 1 > IF ." s" TH
0580: 45 4e 20 3b 0a 20 20 20 20 0a 5b 49 46 44 45 46 EN ;. .[IFDEF
0590: 5d 20 61 6e 64 72 6f 69 64 0a 20 20 20 20 61 6c ] android. al
05a0: 73 6f 20 61 6e 64 72 6f 69 64 20 61 6c 73 6f 20 so android also
05b0: 6a 6e 69 0a 20 20 20 20 6a 76 61 6c 75 65 20 6e jni. jvalue n
05c0: 62 0a 20 20 20 20 6a 76 61 6c 75 65 20 6e 69 0a b. jvalue ni.
05d0: 20 20 20 20 6a 76 61 6c 75 65 20 6e 66 0a 20 20 jvalue nf.
05e0: 20 20 6a 76 61 6c 75 65 20 6e 6f 74 69 66 69 63 jvalue notific
05f0: 61 74 69 6f 6e 2d 6d 61 6e 61 67 65 72 0a 20 20 ation-manager.
0600: 20 20 3a 20 6e 6f 74 69 66 79 2b 20 28 20 61 64 : notify+ ( ad
0610: 64 72 20 75 20 2d 2d 20 29 20 20 6e 6f 74 69 66 dr u -- ) notif
0620: 79 3e 20 6e 6f 74 69 66 79 24 20 24 2b 21 20 3b y> notify$ $+! ;
0630: 0a 20 20 20 20 3a 20 6e 6f 74 69 66 79 21 20 28 . : notify! (
0640: 20 61 64 64 72 20 75 20 2d 2d 20 29 20 20 6e 6f addr u -- ) no
0650: 74 69 66 79 3e 20 6e 6f 74 69 66 79 24 20 24 21 tify> notify$ $!
0660: 20 3b 0a 20 20 20 20 3a 20 3f 6e 6d 20 28 20 2d ;. : ?nm ( -
0670: 2d 20 29 0a 09 6e 6f 74 69 66 69 63 61 74 69 6f - )..notificatio
0680: 6e 2d 6d 61 6e 61 67 65 72 20 30 3d 20 49 46 0a n-manager 0= IF.
0690: 09 20 20 20 20 4e 4f 54 49 46 49 43 41 54 49 4f . NOTIFICATIO
06a0: 4e 5f 53 45 52 56 49 43 45 20 63 6c 61 7a 7a 20 N_SERVICE clazz
06b0: 2e 67 65 74 53 79 73 74 65 6d 53 65 72 76 69 63 .getSystemServic
06c0: 65 0a 09 20 20 20 20 74 6f 20 6e 6f 74 69 66 69 e.. to notifi
06d0: 63 61 74 69 6f 6e 2d 6d 61 6e 61 67 65 72 0a 09 cation-manager..
06e0: 54 48 45 4e 20 3b 0a 20 20 20 20 3a 20 3f 6e 69 THEN ;. : ?ni
06f0: 20 28 20 2d 2d 20 29 0a 09 6e 69 20 30 3d 20 49 ( -- )..ni 0= I
0700: 46 20 20 63 6c 61 7a 7a 20 2e 67 66 6f 72 74 68 F clazz .gforth
0710: 69 6e 74 65 6e 74 20 74 6f 20 6e 69 20 20 54 48 intent to ni TH
0720: 45 4e 20 3b 0a 20 20 20 20 3a 20 6d 73 67 2d 62 EN ;. : msg-b
0730: 75 69 6c 64 65 72 20 28 20 2d 2d 20 29 20 3f 6e uilder ( -- ) ?n
0740: 6d 20 3f 6e 69 0a 09 63 6c 61 7a 7a 20 6e 65 77 m ?ni..clazz new
0750: 4e 6f 74 69 66 69 63 61 74 69 6f 6e 2e 42 75 69 Notification.Bui
0760: 6c 64 65 72 20 74 6f 20 6e 62 0a 09 6e 6f 74 69 lder to nb..noti
0770: 66 79 2d 72 67 62 20 6e 6f 74 69 66 79 2d 6f 6e fy-rgb notify-on
0780: 20 6e 6f 74 69 66 79 2d 6f 66 66 20 6e 62 20 2e notify-off nb .
0790: 73 65 74 4c 69 67 68 74 73 20 74 6f 20 6e 62 0a setLights to nb.
07a0: 09 6e 6f 74 69 66 79 2d 6d 6f 64 65 20 6e 62 20 .notify-mode nb
07b0: 2e 73 65 74 44 65 66 61 75 6c 74 73 20 74 6f 20 .setDefaults to
07c0: 6e 62 0a 09 30 78 30 31 30 38 30 30 37 37 20 6e nb..0x01080077 n
07d0: 62 20 2e 73 65 74 53 6d 61 6c 6c 49 63 6f 6e 20 b .setSmallIcon
07e0: 74 6f 20 6e 62 0a 09 6e 69 20 6e 62 20 2e 73 65 to nb..ni nb .se
07f0: 74 43 6f 6e 74 65 6e 74 49 6e 74 65 6e 74 20 74 tContentIntent t
0800: 6f 20 6e 62 0a 09 31 20 6e 62 20 2e 73 65 74 41 o nb..1 nb .setA
0810: 75 74 6f 43 61 6e 63 65 6c 20 74 6f 20 6e 62 20 utoCancel to nb
0820: 3b 0a 20 20 20 20 6d 73 67 2d 62 75 69 6c 64 65 ;. msg-builde
0830: 72 0a 20 20 20 20 3a 20 62 75 69 6c 64 2d 6e 6f r. : build-no
0840: 74 69 66 69 63 61 74 69 6f 6e 20 28 20 2d 2d 20 tification ( --
0850: 29 0a 09 31 20 70 65 6e 64 69 6e 67 2d 6e 6f 74 )..1 pending-not
0860: 69 66 69 63 61 74 69 6f 6e 73 20 2b 21 0a 09 5b ifications +!..[
0870: 27 5d 20 6e 6f 74 69 66 79 2d 74 69 74 6c 65 20 '] notify-title
0880: 24 74 6d 70 20 6d 61 6b 65 2d 6a 73 74 72 69 6e $tmp make-jstrin
0890: 67 20 6e 62 20 2e 73 65 74 43 6f 6e 74 65 6e 74 g nb .setContent
08a0: 54 69 74 6c 65 20 74 6f 20 6e 62 0a 09 6e 6f 74 Title to nb..not
08b0: 69 66 79 24 20 24 40 20 6d 61 6b 65 2d 6a 73 74 ify$ $@ make-jst
08c0: 72 69 6e 67 20 6e 62 20 2e 73 65 74 43 6f 6e 74 ring nb .setCont
08d0: 65 6e 74 54 65 78 74 20 74 6f 20 6e 62 0a 09 6e entText to nb..n
08e0: 6f 74 69 66 79 24 20 24 40 20 6d 61 6b 65 2d 6a otify$ $@ make-j
08f0: 73 74 72 69 6e 67 20 6e 62 20 2e 73 65 74 54 69 string nb .setTi
0900: 63 6b 65 72 20 74 6f 20 6e 62 0a 09 6e 62 20 2e cker to nb..nb .
0910: 62 75 69 6c 64 20 74 6f 20 6e 66 20 3b 0a 20 20 build to nf ;.
0920: 20 20 3a 20 73 68 6f 77 2d 6e 6f 74 69 66 69 63 : show-notific
0930: 61 74 69 6f 6e 20 28 20 2d 2d 20 29 0a 09 31 20 ation ( -- )..1
0940: 6e 66 20 6e 6f 74 69 66 69 63 61 74 69 6f 6e 2d nf notification-
0950: 6d 61 6e 61 67 65 72 20 2e 6e 6f 74 69 66 79 20 manager .notify
0960: 3b 0a 5b 45 4c 53 45 5d 0a 20 20 20 20 3a 20 6e ;.[ELSE]. : n
0970: 6f 74 69 66 79 2b 20 6e 6f 74 69 66 79 3e 20 6e otify+ notify> n
0980: 6f 74 69 66 79 24 20 24 2b 21 20 3b 0a 20 20 20 otify$ $+! ;.
0990: 20 3a 20 6e 6f 74 69 66 79 21 20 6e 6f 74 69 66 : notify! notif
09a0: 79 3e 20 6e 6f 74 69 66 79 24 20 24 21 20 3b 0a y> notify$ $! ;.
09b0: 20 20 20 20 3a 20 62 75 69 6c 64 2d 6e 6f 74 69 : build-noti
09c0: 66 69 63 61 74 69 6f 6e 20 28 20 2d 2d 20 29 20 fication ( -- )
09d0: 3b 0a 20 20 20 20 5b 49 46 44 45 46 5d 20 6c 69 ;. [IFDEF] li
09e0: 6e 75 78 0a 09 5b 49 46 44 45 46 5d 20 66 6f 72 nux..[IFDEF] for
09f0: 6b 2b 65 78 65 63 0a 09 20 20 20 20 56 61 72 69 k+exec.. Vari
0a00: 61 62 6c 65 20 6e 6f 74 69 66 79 2d 73 65 6e 64 able notify-send
0a10: 20 20 24 31 30 30 30 20 6e 6f 74 69 66 79 2d 73 $1000 notify-s
0a20: 65 6e 64 20 24 21 6c 65 6e 0a 09 20 20 20 20 73 end $!len.. s
0a30: 22 20 77 68 69 63 68 20 6e 6f 74 69 66 79 2d 73 " which notify-s
0a40: 65 6e 64 22 20 72 2f 6f 20 6f 70 65 6e 2d 70 69 end" r/o open-pi
0a50: 70 65 20 74 68 72 6f 77 0a 09 20 20 20 20 3e 72 pe throw.. >r
0a60: 20 6e 6f 74 69 66 79 2d 73 65 6e 64 20 24 40 20 notify-send $@
0a70: 72 40 20 72 65 61 64 2d 66 69 6c 65 20 74 68 72 r@ read-file thr
0a80: 6f 77 20 72 3e 20 63 6c 6f 73 65 2d 66 69 6c 65 ow r> close-file
0a90: 20 74 68 72 6f 77 0a 09 20 20 20 20 6e 6f 74 69 throw.. noti
0aa0: 66 79 2d 73 65 6e 64 20 24 40 20 72 6f 74 20 75 fy-send $@ rot u
0ab0: 6d 69 6e 20 23 6c 66 20 2d 73 6b 69 70 20 6e 6f min #lf -skip no
0ac0: 74 69 66 79 2d 73 65 6e 64 20 24 21 6c 65 6e 0a tify-send $!len.
0ad0: 09 20 20 20 20 0a 09 20 20 20 20 56 61 72 69 61 . .. Varia
0ae0: 62 6c 65 20 6e 65 74 32 6f 2d 6c 6f 67 6f 0a 09 ble net2o-logo..
0af0: 20 20 20 20 73 22 20 64 6f 63 2f 6e 65 74 32 6f s" doc/net2o
0b00: 2d 6c 6f 67 6f 2e 70 6e 67 22 20 6f 70 65 6e 2d -logo.png" open-
0b10: 66 70 61 74 68 2d 66 69 6c 65 20 30 3d 20 5b 49 fpath-file 0= [I
0b20: 46 5d 0a 09 09 72 6f 74 20 63 6c 6f 73 65 2d 66 F]...rot close-f
0b30: 69 6c 65 20 74 68 72 6f 77 0a 09 09 6f 76 65 72 ile throw...over
0b40: 20 63 40 20 27 2f 27 20 3c 3e 20 5b 49 46 5d 0a c@ '/' <> [IF].
0b50: 09 09 20 20 20 20 70 61 64 20 24 32 30 30 20 67 .. pad $200 g
0b60: 65 74 2d 64 69 72 20 6e 65 74 32 6f 2d 6c 6f 67 et-dir net2o-log
0b70: 6f 20 24 21 20 27 2f 27 20 6e 65 74 32 6f 2d 6c o $! '/' net2o-l
0b80: 6f 67 6f 20 63 24 2b 21 0a 09 09 5b 54 48 45 4e ogo c$+!...[THEN
0b90: 5d 0a 09 09 6e 65 74 32 6f 2d 6c 6f 67 6f 20 24 ]...net2o-logo $
0ba0: 2b 21 0a 09 20 20 20 20 5b 54 48 45 4e 5d 0a 09 +!.. [THEN]..
0bb0: 20 20 20 20 0a 09 20 20 20 20 3a 20 30 73 74 72 .. : 0str
0bc0: 69 6e 67 20 28 20 61 64 64 72 20 75 20 2d 2d 20 ing ( addr u --
0bd0: 63 73 74 72 20 29 0a 09 09 31 2b 20 73 61 76 65 cstr )...1+ save
0be0: 2d 6d 65 6d 20 6f 76 65 72 20 2b 20 31 2d 20 30 -mem over + 1- 0
0bf0: 20 73 77 61 70 20 63 21 20 3b 0a 09 20 20 20 20 swap c! ;..
0c00: 0a 09 20 20 20 20 43 72 65 61 74 65 20 6e 6f 74 .. Create not
0c10: 69 66 79 2d 61 72 67 73 0a 09 20 20 20 20 22 6e ify-args.. "n
0c20: 6f 74 69 66 79 2d 73 65 6e 64 5c 30 22 20 64 72 otify-send\0" dr
0c30: 6f 70 20 2c 0a 09 20 20 20 20 22 2d 61 5c 30 22 op ,.. "-a\0"
0c40: 20 64 72 6f 70 20 2c 0a 09 20 20 20 20 22 6e 65 drop ,.. "ne
0c50: 74 32 6f 5c 30 22 20 64 72 6f 70 20 2c 0a 09 20 t2o\0" drop ,..
0c60: 20 20 20 22 2d 63 5c 30 22 20 64 72 6f 70 20 2c "-c\0" drop ,
0c70: 0a 09 20 20 20 20 22 69 6d 2e 72 65 63 65 69 76 .. "im.receiv
0c80: 65 64 5c 30 22 20 64 72 6f 70 20 2c 0a 09 20 20 ed\0" drop ,..
0c90: 20 20 6e 65 74 32 6f 2d 6c 6f 67 6f 20 24 40 6c net2o-logo $@l
0ca0: 65 6e 20 5b 49 46 5d 0a 09 09 22 2d 69 5c 30 22 en [IF]..."-i\0"
0cb0: 20 64 72 6f 70 20 2c 0a 09 09 6e 65 74 32 6f 2d drop ,...net2o-
0cc0: 6c 6f 67 6f 20 24 40 20 30 73 74 72 69 6e 67 20 logo $@ 0string
0cd0: 2c 0a 09 20 20 20 20 5b 54 48 45 4e 5d 0a 09 20 ,.. [THEN]..
0ce0: 20 20 20 68 65 72 65 20 30 20 2c 0a 09 20 20 20 here 0 ,..
0cf0: 20 68 65 72 65 20 30 20 2c 0a 09 20 20 20 20 30 here 0 ,.. 0
0d00: 20 2c 20 5c 20 6d 75 73 74 20 62 65 20 74 65 72 , \ must be ter
0d10: 6d 69 6e 61 74 65 64 20 62 79 20 6e 75 6c 6c 20 minated by null
0d20: 70 6f 69 6e 74 65 72 0a 09 20 20 20 20 43 6f 6e pointer.. Con
0d30: 73 74 61 6e 74 20 63 6f 6e 74 65 6e 74 2d 73 74 stant content-st
0d40: 72 69 6e 67 0a 09 20 20 20 20 43 6f 6e 73 74 61 ring.. Consta
0d50: 6e 74 20 74 69 74 6c 65 2d 73 74 72 69 6e 67 0a nt title-string.
0d60: 09 20 20 20 20 0a 09 20 20 20 20 3a 20 6c 69 6e . .. : lin
0d70: 75 78 2d 6e 6f 74 69 66 69 63 61 74 69 6f 6e 20 ux-notification
0d80: 28 20 2d 2d 20 29 20 20 6e 6f 74 69 66 79 2d 73 ( -- ) notify-s
0d90: 65 6e 64 20 24 40 6c 65 6e 20 30 3d 20 3f 45 58 end $@len 0= ?EX
0da0: 49 54 0a 09 09 74 69 74 6c 65 2d 73 74 72 69 6e IT...title-strin
0db0: 67 20 30 20 3f 66 72 65 65 20 20 63 6f 6e 74 65 g 0 ?free conte
0dc0: 6e 74 2d 73 74 72 69 6e 67 20 30 20 3f 66 72 65 nt-string 0 ?fre
0dd0: 65 0a 09 09 5b 27 5d 20 6e 6f 74 69 66 79 2d 74 e...['] notify-t
0de0: 69 74 6c 65 20 24 74 6d 70 20 30 73 74 72 69 6e itle $tmp 0strin
0df0: 67 20 74 69 74 6c 65 2d 73 74 72 69 6e 67 20 21 g title-string !
0e00: 0a 09 09 6e 6f 74 69 66 79 24 20 24 40 20 30 73 ...notify$ $@ 0s
0e10: 74 72 69 6e 67 20 63 6f 6e 74 65 6e 74 2d 73 74 tring content-st
0e20: 72 69 6e 67 20 21 0a 09 09 6e 6f 74 69 66 79 2d ring !...notify-
0e30: 73 65 6e 64 20 24 40 20 6e 6f 74 69 66 79 2d 61 send $@ notify-a
0e40: 72 67 73 20 66 6f 72 6b 2b 65 78 65 63 20 3b 0a rgs fork+exec ;.
0e50: 09 5b 45 4c 53 45 5d 0a 09 20 20 20 20 3a 20 6c .[ELSE].. : l
0e60: 69 6e 75 78 2d 6e 6f 74 69 66 69 63 61 74 69 6f inux-notificatio
0e70: 6e 20 28 20 2d 2d 20 29 20 5c 20 73 68 65 6c 6c n ( -- ) \ shell
0e80: 20 73 63 72 69 70 74 20 62 61 73 65 64 0a 09 09 script based...
0e90: 5b 20 73 22 20 77 68 69 63 68 20 6e 6f 74 69 66 [ s" which notif
0ea0: 79 2d 73 65 6e 64 20 3e 2f 64 65 76 2f 6e 75 6c y-send >/dev/nul
0eb0: 6c 20 32 3e 2f 64 65 76 2f 6e 75 6c 6c 22 20 73 l 2>/dev/null" s
0ec0: 79 73 74 65 6d 0a 09 09 24 3f 20 30 3d 20 5d 20 ystem...$? 0= ]
0ed0: 5b 49 46 5d 0a 09 09 20 20 20 20 5b 3a 20 2e 5c [IF]... [: .\
0ee0: 22 20 6e 6f 74 69 66 79 2d 73 65 6e 64 20 2d 61 " notify-send -a
0ef0: 20 6e 65 74 32 6f 20 2d 63 20 69 6d 2e 72 65 63 net2o -c im.rec
0f00: 65 69 76 65 64 20 22 0a 09 09 09 5b 20 73 22 20 eived "....[ s"
0f10: 64 6f 63 2f 6e 65 74 32 6f 2d 6c 6f 67 6f 2e 70 doc/net2o-logo.p
0f20: 6e 67 22 20 6f 70 65 6e 2d 66 70 61 74 68 2d 66 ng" open-fpath-f
0f30: 69 6c 65 20 30 3d 20 5d 20 5b 49 46 5d 0a 09 09 ile 0= ] [IF]...
0f40: 09 20 20 20 20 2e 22 20 2d 69 20 22 20 5b 20 6f . ." -i " [ o
0f50: 76 65 72 20 63 40 20 27 2f 27 20 3c 3e 20 5b 49 ver c@ '/' <> [I
0f60: 46 5d 0a 09 09 09 09 70 61 64 20 24 32 30 30 20 F].....pad $200
0f70: 67 65 74 2d 64 69 72 20 5d 20 73 6c 69 74 65 72 get-dir ] sliter
0f80: 61 6c 20 74 79 70 65 20 2e 22 20 2f 22 20 5b 0a al type ." /" [.
0f90: 09 09 09 20 20 20 20 5b 54 48 45 4e 5d 0a 09 09 ... [THEN]...
0fa0: 09 20 20 20 20 5d 20 73 6c 69 74 65 72 61 6c 20 . ] sliteral
0fb0: 27 74 79 70 65 27 20 5b 20 63 6c 6f 73 65 2d 66 'type' [ close-f
0fc0: 69 6c 65 20 74 68 72 6f 77 20 5d 0a 09 09 09 5b ile throw ]....[
0fd0: 54 48 45 4e 5d 0a 09 09 09 2e 22 20 20 27 22 20 THEN]....." '"
0fe0: 6e 6f 74 69 66 79 2d 74 69 74 6c 65 0a 09 09 09 notify-title....
0ff0: 2e 22 20 27 20 22 20 6e 6f 74 69 66 79 24 20 24 ." ' " notify$ $
1000: 40 20 27 74 79 70 65 27 20 3b 5d 20 24 74 6d 70 @ 'type' ;] $tmp
1010: 20 73 79 73 74 65 6d 0a 09 09 5b 54 48 45 4e 5d system...[THEN]
1020: 20 3b 0a 09 5b 54 48 45 4e 5d 0a 20 20 20 20 5b ;..[THEN]. [
1030: 54 48 45 4e 5d 0a 09 0a 20 20 20 20 3a 20 73 68 THEN]... : sh
1040: 6f 77 2d 6e 6f 74 69 66 69 63 61 74 69 6f 6e 20 ow-notification
1050: 28 20 2d 2d 20 29 0a 09 31 20 70 65 6e 64 69 6e ( -- )..1 pendin
1060: 67 2d 6e 6f 74 69 66 69 63 61 74 69 6f 6e 73 20 g-notifications
1070: 2b 21 0a 09 5b 49 46 44 45 46 5d 20 6c 69 6e 75 +!..[IFDEF] linu
1080: 78 2d 6e 6f 74 69 66 69 63 61 74 69 6f 6e 0a 09 x-notification..
1090: 20 20 20 20 6c 69 6e 75 78 2d 6e 6f 74 69 66 69 linux-notifi
10a0: 63 61 74 69 6f 6e 0a 09 5b 54 48 45 4e 5d 20 3b cation..[THEN] ;
10b0: 0a 20 20 20 20 3a 20 6d 73 67 2d 62 75 69 6c 64 . : msg-build
10c0: 65 72 20 3b 0a 20 20 20 20 5b 49 46 55 4e 44 45 er ;. [IFUNDE
10d0: 46 5d 20 72 65 6e 64 65 72 69 6e 67 0a 09 56 61 F] rendering..Va
10e0: 72 69 61 62 6c 65 20 72 65 6e 64 65 72 69 6e 67 riable rendering
10f0: 20 20 2d 31 20 72 65 6e 64 65 72 69 6e 67 20 21 -1 rendering !
1100: 0a 20 20 20 20 5b 54 48 45 4e 5d 0a 20 20 20 20 . [THEN].
1110: 61 6c 73 6f 20 61 6c 73 6f 0a 5b 54 48 45 4e 5d also also.[THEN]
1120: 0a 0a 3a 20 6e 6f 74 69 66 79 2d 20 28 20 2d 2d ..: notify- ( --
1130: 20 29 0a 20 20 20 20 70 65 6e 64 69 6e 67 2d 6e ). pending-n
1140: 6f 74 69 66 69 63 61 74 69 6f 6e 73 20 6f 66 66 otifications off
1150: 0a 20 20 20 20 36 34 23 30 20 74 6f 20 6c 61 73 . 64#0 to las
1160: 74 2d 6e 6f 74 69 66 79 20 3b 0a 0a 3a 20 6d 73 t-notify ;..: ms
1170: 67 2d 6e 6f 74 69 66 79 20 28 20 2d 2d 20 29 20 g-notify ( -- )
1180: 6e 6f 74 69 66 79 3e 0a 20 20 20 20 74 69 63 6b notify>. tick
1190: 73 20 74 6f 20 6c 61 74 65 73 74 2d 6e 6f 74 69 s to latest-noti
11a0: 66 79 0a 20 20 20 20 72 65 6e 64 65 72 69 6e 67 fy. rendering
11b0: 20 40 20 6e 6f 74 69 66 79 3f 20 40 20 3c 3d 20 @ notify? @ <=
11c0: 64 75 70 20 49 46 0a 09 6e 6f 74 69 66 79 2d 0a dup IF..notify-.
11d0: 20 20 20 20 54 48 45 4e 0a 20 20 20 20 74 69 63 THEN. tic
11e0: 6b 2d 6e 6f 74 69 66 79 3f 20 6f 72 20 30 3d 20 k-notify? or 0=
11f0: 49 46 0a 09 62 75 69 6c 64 2d 6e 6f 74 69 66 69 IF..build-notifi
1200: 63 61 74 69 6f 6e 20 73 68 6f 77 2d 6e 6f 74 69 cation show-noti
1210: 66 69 63 61 74 69 6f 6e 0a 09 74 69 63 6b 73 20 fication..ticks
1220: 74 6f 20 6c 61 73 74 2d 6e 6f 74 69 66 79 0a 20 to last-notify.
1230: 20 20 20 54 48 45 4e 20 20 6e 6f 74 69 66 79 24 THEN notify$
1240: 20 24 6f 66 66 20 3b 0a 0a 70 72 65 76 69 6f 75 $off ;..previou
1250: 73 20 70 72 65 76 69 6f 75 73 0a 0a 30 20 5b 49 s previous..0 [I
1260: 46 5d 0a 4c 6f 63 61 6c 20 56 61 72 69 61 62 6c F].Local Variabl
1270: 65 73 3a 0a 66 6f 72 74 68 2d 6c 6f 63 61 6c 2d es:.forth-local-
1280: 77 6f 72 64 73 3a 0a 20 20 20 20 28 0a 20 20 20 words:. (.
1290: 20 20 28 28 22 6e 65 74 32 6f 3a 22 20 22 2b 6e (("net2o:" "+n
12a0: 65 74 32 6f 3a 22 29 20 64 65 66 69 6e 69 74 69 et2o:") definiti
12b0: 6f 6e 2d 73 74 61 72 74 65 72 20 28 66 6f 6e 74 on-starter (font
12c0: 2d 6c 6f 63 6b 2d 6b 65 79 77 6f 72 64 2d 66 61 -lock-keyword-fa
12d0: 63 65 20 2e 20 31 29 0a 20 20 20 20 20 20 22 5b ce . 1). "[
12e0: 20 5c 74 5c 6e 5d 22 20 74 20 6e 61 6d 65 20 28 \t\n]" t name (
12f0: 66 6f 6e 74 2d 6c 6f 63 6b 2d 66 75 6e 63 74 69 font-lock-functi
1300: 6f 6e 2d 6e 61 6d 65 2d 66 61 63 65 20 2e 20 33 on-name-face . 3
1310: 29 29 0a 20 20 20 20 20 28 22 5b 61 2d 7a 30 2d )). ("[a-z0-
1320: 39 5d 2b 28 22 20 69 6d 6d 65 64 69 61 74 65 20 9]+(" immediate
1330: 28 66 6f 6e 74 2d 6c 6f 63 6b 2d 63 6f 6d 6d 65 (font-lock-comme
1340: 6e 74 2d 66 61 63 65 20 2e 20 31 29 0a 20 20 20 nt-face . 1).
1350: 20 20 20 22 29 22 20 6e 69 6c 20 63 6f 6d 6d 65 ")" nil comme
1360: 6e 74 20 28 66 6f 6e 74 2d 6c 6f 63 6b 2d 63 6f nt (font-lock-co
1370: 6d 6d 65 6e 74 2d 66 61 63 65 20 2e 20 31 29 29 mment-face . 1))
1380: 0a 20 20 20 20 29 0a 66 6f 72 74 68 2d 6c 6f 63 . ).forth-loc
1390: 61 6c 2d 69 6e 64 65 6e 74 2d 77 6f 72 64 73 3a al-indent-words:
13a0: 0a 20 20 20 20 28 0a 20 20 20 20 20 28 28 22 6e . (. (("n
13b0: 65 74 32 6f 3a 22 20 22 2b 6e 65 74 32 6f 3a 22 et2o:" "+net2o:"
13c0: 29 20 28 30 20 2e 20 32 29 20 28 30 20 2e 20 32 ) (0 . 2) (0 . 2
13d0: 29 20 6e 6f 6e 2d 69 6d 6d 65 64 69 61 74 65 29 ) non-immediate)
13e0: 0a 20 20 20 20 29 0a 45 6e 64 3a 0a 5b 54 48 45 . ).End:.[THE
13f0: 4e 5d N]