Artifact 353cbe94e98cdf787e707d9705d71b1a80027046:
- File linux/notify.fs — part of check-in [9de6150452] at 2018-11-15 23:25:52 on branch trunk — Notification+Otrify problems fixed (Otrify only partly) (user: bernd size: 2687)
0000: 5c 20 4c 69 6e 75 78 20 73 70 65 63 69 66 69 63 \ Linux specific 0010: 20 6e 6f 74 69 66 69 63 61 74 69 6f 6e 20 73 74 notification st 0020: 75 66 66 0a 0a 5c 20 43 6f 70 79 72 69 67 68 74 uff..\ Copyright 0030: 20 28 43 29 20 32 30 31 36 20 20 20 42 65 72 6e (C) 2016 Bern 0040: 64 20 50 61 79 73 61 6e 0a 0a 5c 20 54 68 69 73 d Paysan..\ This 0050: 20 70 72 6f 67 72 61 6d 20 69 73 20 66 72 65 65 program is free 0060: 20 73 6f 66 74 77 61 72 65 3a 20 79 6f 75 20 63 software: you c 0070: 61 6e 20 72 65 64 69 73 74 72 69 62 75 74 65 20 an redistribute 0080: 69 74 20 61 6e 64 2f 6f 72 20 6d 6f 64 69 66 79 it and/or modify 0090: 0a 5c 20 69 74 20 75 6e 64 65 72 20 74 68 65 20 .\ it under the 00a0: 74 65 72 6d 73 20 6f 66 20 74 68 65 20 47 4e 55 terms of the GNU 00b0: 20 41 66 66 65 72 6f 20 47 65 6e 65 72 61 6c 20 Affero General 00c0: 50 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 61 Public License a 00d0: 73 20 70 75 62 6c 69 73 68 65 64 20 62 79 0a 5c s published by.\ 00e0: 20 74 68 65 20 46 72 65 65 20 53 6f 66 74 77 61 the Free Softwa 00f0: 72 65 20 46 6f 75 6e 64 61 74 69 6f 6e 2c 20 65 re Foundation, e 0100: 69 74 68 65 72 20 76 65 72 73 69 6f 6e 20 33 20 ither version 3 0110: 6f 66 20 74 68 65 20 4c 69 63 65 6e 73 65 2c 20 of the License, 0120: 6f 72 0a 5c 20 28 61 74 20 79 6f 75 72 20 6f 70 or.\ (at your op 0130: 74 69 6f 6e 29 20 61 6e 79 20 6c 61 74 65 72 20 tion) any later 0140: 76 65 72 73 69 6f 6e 2e 0a 0a 5c 20 54 68 69 73 version...\ This 0150: 20 70 72 6f 67 72 61 6d 20 69 73 20 64 69 73 74 program is dist 0160: 72 69 62 75 74 65 64 20 69 6e 20 74 68 65 20 68 ributed in the h 0170: 6f 70 65 20 74 68 61 74 20 69 74 20 77 69 6c 6c ope that it will 0180: 20 62 65 20 75 73 65 66 75 6c 2c 0a 5c 20 62 75 be useful,.\ bu 0190: 74 20 57 49 54 48 4f 55 54 20 41 4e 59 20 57 41 t WITHOUT ANY WA 01a0: 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 74 20 RRANTY; without 01b0: 65 76 65 6e 20 74 68 65 20 69 6d 70 6c 69 65 64 even the implied 01c0: 20 77 61 72 72 61 6e 74 79 20 6f 66 0a 5c 20 4d warranty of.\ M 01d0: 45 52 43 48 41 4e 54 41 42 49 4c 49 54 59 20 6f ERCHANTABILITY o 01e0: 72 20 46 49 54 4e 45 53 53 20 46 4f 52 20 41 20 r FITNESS FOR A 01f0: 50 41 52 54 49 43 55 4c 41 52 20 50 55 52 50 4f PARTICULAR PURPO 0200: 53 45 2e 20 20 53 65 65 20 74 68 65 0a 5c 20 47 SE. See the.\ G 0210: 4e 55 20 41 66 66 65 72 6f 20 47 65 6e 65 72 61 NU Affero Genera 0220: 6c 20 50 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 l Public License 0230: 20 66 6f 72 20 6d 6f 72 65 20 64 65 74 61 69 6c for more detail 0240: 73 2e 0a 0a 5c 20 59 6f 75 20 73 68 6f 75 6c 64 s...\ You should 0250: 20 68 61 76 65 20 72 65 63 65 69 76 65 64 20 61 have received a 0260: 20 63 6f 70 79 20 6f 66 20 74 68 65 20 47 4e 55 copy of the GNU 0270: 20 41 66 66 65 72 6f 20 47 65 6e 65 72 61 6c 20 Affero General 0280: 50 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 0a 5c Public License.\ 0290: 20 61 6c 6f 6e 67 20 77 69 74 68 20 74 68 69 73 along with this 02a0: 20 70 72 6f 67 72 61 6d 2e 20 20 49 66 20 6e 6f program. If no 02b0: 74 2c 20 73 65 65 20 3c 68 74 74 70 3a 2f 2f 77 t, see <http://w 02c0: 77 77 2e 67 6e 75 2e 6f 72 67 2f 6c 69 63 65 6e ww.gnu.org/licen 02d0: 73 65 73 2f 3e 2e 0a 0a 3a 20 65 73 63 61 70 65 ses/>...: escape 02e0: 2d 3c 26 3e 20 28 20 61 64 64 72 20 75 20 2d 2d -<&> ( addr u -- 02f0: 20 29 0a 20 20 20 20 62 6f 75 6e 64 73 20 3f 44 ). bounds ?D 0300: 4f 20 20 63 61 73 65 20 69 20 63 40 0a 09 20 20 O case i c@.. 0310: 20 20 27 3c 27 20 6f 66 20 20 2e 22 20 26 6c 74 '<' of ." < 0320: 3b 22 20 20 65 6e 64 6f 66 0a 09 20 20 20 20 27 ;" endof.. ' 0330: 3e 27 20 6f 66 20 20 2e 22 20 26 67 74 3b 22 20 >' of ." >" 0340: 20 65 6e 64 6f 66 0a 09 20 20 20 20 27 26 27 20 endof.. '&' 0350: 6f 66 20 20 2e 22 20 26 61 6d 70 3b 22 20 65 6e of ." &" en 0360: 64 6f 66 0a 09 20 20 20 20 65 6d 69 74 20 20 30 dof.. emit 0 0370: 20 65 6e 64 63 61 73 65 20 20 4c 4f 4f 50 20 3b endcase LOOP ; 0380: 0a 0a 3a 20 62 75 69 6c 64 2d 6e 6f 74 69 66 69 ..: build-notifi 0390: 63 61 74 69 6f 6e 20 28 20 2d 2d 20 29 20 3b 0a cation ( -- ) ;. 03a0: 3a 20 6e 6f 74 69 66 79 40 20 28 20 2d 2d 20 61 : notify@ ( -- a 03b0: 64 64 72 20 75 20 29 0a 20 20 20 20 63 6f 6e 66 ddr u ). conf 03c0: 69 67 3a 6e 6f 74 69 66 79 2d 74 65 78 74 23 20 ig:notify-text# 03d0: 40 20 49 46 0a 09 6e 6f 74 69 66 79 2d 6f 74 72 @ IF..notify-otr 03e0: 3f 20 40 20 63 6f 6e 66 69 67 3a 6e 6f 74 69 66 ? @ config:notif 03f0: 79 2d 74 65 78 74 23 20 40 20 30 3e 20 61 6e 64 y-text# @ 0> and 0400: 20 49 46 0a 09 20 20 20 20 22 3c 69 3e 5b 6f 74 IF.. "<i>[ot 0410: 72 5d 20 6d 65 73 73 61 67 65 3c 2f 69 3e 22 0a r] message</i>". 0420: 09 45 4c 53 45 20 20 6e 6f 74 69 66 79 24 20 24 .ELSE notify$ $ 0430: 40 20 5b 27 5d 20 65 73 63 61 70 65 2d 3c 26 3e @ ['] escape-<&> 0440: 20 24 74 6d 70 20 20 54 48 45 4e 0a 20 20 20 20 $tmp THEN. 0450: 45 4c 53 45 20 20 22 3c 69 3e 65 6e 63 72 79 70 ELSE "<i>encryp 0460: 74 65 64 20 6d 65 73 73 61 67 65 3c 2f 69 3e 22 ted message</i>" 0470: 20 20 54 48 45 4e 20 3b 0a 0a 56 61 72 69 61 62 THEN ;..Variab 0480: 6c 65 20 6e 6f 74 69 66 79 2d 73 65 6e 64 0a 56 le notify-send.V 0490: 61 72 69 61 62 6c 65 20 75 70 61 74 68 0a 0a 3a ariable upath..: 04a0: 20 21 75 70 61 74 68 20 28 20 2d 2d 20 29 0a 20 !upath ( -- ). 04b0: 20 20 20 22 50 41 54 48 22 20 67 65 74 65 6e 76 "PATH" getenv 04c0: 20 75 70 61 74 68 20 24 21 0a 20 20 20 20 75 70 upath $!. up 04d0: 61 74 68 20 24 40 20 62 6f 75 6e 64 73 20 3f 44 ath $@ bounds ?D 04e0: 4f 20 49 20 63 40 20 27 3a 27 20 3d 20 49 46 20 O I c@ ':' = IF 04f0: 30 20 49 20 63 21 20 54 48 45 4e 20 4c 4f 4f 50 0 I c! THEN LOOP 0500: 0a 20 20 20 20 22 6e 6f 74 69 66 79 2d 73 65 6e . "notify-sen 0510: 64 22 20 75 70 61 74 68 20 6f 70 65 6e 2d 70 61 d" upath open-pa 0520: 74 68 2d 66 69 6c 65 20 30 3d 20 49 46 0a 09 72 th-file 0= IF..r 0530: 6f 74 20 63 6c 6f 73 65 2d 66 69 6c 65 20 74 68 ot close-file th 0540: 72 6f 77 0a 09 6f 76 65 72 20 63 40 20 27 2f 27 row..over c@ '/' 0550: 20 3c 3e 20 49 46 0a 09 20 20 20 20 70 61 64 20 <> IF.. pad 0560: 24 31 30 30 30 20 67 65 74 2d 64 69 72 20 6e 6f $1000 get-dir no 0570: 74 69 66 79 2d 73 65 6e 64 20 24 21 20 27 2f 27 tify-send $! '/' 0580: 20 6e 6f 74 69 66 79 2d 73 65 6e 64 20 63 24 2b notify-send c$+ 0590: 21 0a 09 54 48 45 4e 0a 09 6e 6f 74 69 66 79 2d !..THEN..notify- 05a0: 73 65 6e 64 20 24 2b 21 0a 20 20 20 20 54 48 45 send $+!. THE 05b0: 4e 0a 20 20 20 20 75 70 61 74 68 20 24 6f 66 66 N. upath $off 05c0: 20 3b 0a 0a 56 61 72 69 61 62 6c 65 20 6e 65 74 ;..Variable net 05d0: 32 6f 2d 6c 6f 67 6f 0a 0a 3a 20 21 6e 65 74 32 2o-logo..: !net2 05e0: 6f 2d 6c 6f 67 6f 20 28 20 2d 2d 20 29 0a 20 20 o-logo ( -- ). 05f0: 20 20 73 22 20 2e 2e 2f 64 6f 63 2f 6e 65 74 32 s" ../doc/net2 0600: 6f 2d 6c 6f 67 6f 2e 70 6e 67 22 20 6f 70 65 6e o-logo.png" open 0610: 2d 66 70 61 74 68 2d 66 69 6c 65 20 30 3d 20 49 -fpath-file 0= I 0620: 46 0a 09 72 6f 74 20 63 6c 6f 73 65 2d 66 69 6c F..rot close-fil 0630: 65 20 74 68 72 6f 77 0a 09 6f 76 65 72 20 63 40 e throw..over c@ 0640: 20 27 2f 27 20 3c 3e 20 49 46 0a 09 20 20 20 20 '/' <> IF.. 0650: 70 61 64 20 24 31 30 30 30 20 67 65 74 2d 64 69 pad $1000 get-di 0660: 72 20 6e 65 74 32 6f 2d 6c 6f 67 6f 20 24 21 20 r net2o-logo $! 0670: 27 2f 27 20 6e 65 74 32 6f 2d 6c 6f 67 6f 20 63 '/' net2o-logo c 0680: 24 2b 21 0a 09 54 48 45 4e 0a 09 6e 65 74 32 6f $+!..THEN..net2o 0690: 2d 6c 6f 67 6f 20 24 2b 21 0a 20 20 20 20 54 48 -logo $+!. TH 06a0: 45 4e 20 3b 0a 0a 21 75 70 61 74 68 20 21 6e 65 EN ;..!upath !ne 06b0: 74 32 6f 2d 6c 6f 67 6f 0a 0a 3a 20 30 73 74 72 t2o-logo..: 0str 06c0: 69 6e 67 20 28 20 61 64 64 72 20 75 20 2d 2d 20 ing ( addr u -- 06d0: 63 73 74 72 20 29 0a 20 20 20 20 6f 76 65 72 20 cstr ). over 06e0: 30 3d 20 49 46 20 20 32 64 72 6f 70 20 73 22 20 0= IF 2drop s" 06f0: 22 20 20 54 48 45 4e 0a 20 20 20 20 31 2b 20 73 " THEN. 1+ s 0700: 61 76 65 2d 6d 65 6d 20 6f 76 65 72 20 2b 20 31 ave-mem over + 1 0710: 2d 20 30 20 73 77 61 70 20 63 21 20 3b 0a 0a 30 - 0 swap c! ;..0 0720: 20 56 61 6c 75 65 20 63 6f 6e 74 65 6e 74 2d 73 Value content-s 0730: 74 72 69 6e 67 0a 30 20 56 61 6c 75 65 20 74 69 tring.0 Value ti 0740: 74 6c 65 2d 73 74 72 69 6e 67 0a 0a 31 30 20 63 tle-string..10 c 0750: 65 6c 6c 73 20 62 75 66 66 65 72 3a 20 6e 6f 74 ells buffer: not 0760: 69 66 79 2d 61 72 67 73 0a 0a 3a 20 21 6e 6f 74 ify-args..: !not 0770: 69 66 79 2d 61 72 67 73 20 28 20 2d 2d 20 29 0a ify-args ( -- ). 0780: 20 20 20 20 68 65 72 65 20 3e 72 20 6e 6f 74 69 here >r noti 0790: 66 79 2d 61 72 67 73 20 64 70 20 21 0a 20 20 20 fy-args dp !. 07a0: 20 22 6e 6f 74 69 66 79 2d 73 65 6e 64 5c 30 22 "notify-send\0" 07b0: 20 64 72 6f 70 20 2c 0a 20 20 20 20 22 2d 61 5c drop ,. "-a\ 07c0: 30 22 20 64 72 6f 70 20 2c 0a 20 20 20 20 22 6e 0" drop ,. "n 07d0: 65 74 32 6f 5c 30 22 20 64 72 6f 70 20 2c 0a 20 et2o\0" drop ,. 07e0: 20 20 20 22 2d 63 5c 30 22 20 64 72 6f 70 20 2c "-c\0" drop , 07f0: 0a 20 20 20 20 22 69 6d 2e 72 65 63 65 69 76 65 . "im.receive 0800: 64 5c 30 22 20 64 72 6f 70 20 2c 0a 20 20 20 20 d\0" drop ,. 0810: 6e 65 74 32 6f 2d 6c 6f 67 6f 20 24 40 6c 65 6e net2o-logo $@len 0820: 20 49 46 0a 09 22 2d 69 5c 30 22 20 64 72 6f 70 IF.."-i\0" drop 0830: 20 2c 0a 09 6e 65 74 32 6f 2d 6c 6f 67 6f 20 24 ,..net2o-logo $ 0840: 40 20 30 73 74 72 69 6e 67 20 2c 0a 20 20 20 20 @ 0string ,. 0850: 54 48 45 4e 0a 20 20 20 20 68 65 72 65 20 74 6f THEN. here to 0860: 20 74 69 74 6c 65 2d 73 74 72 69 6e 67 20 30 20 title-string 0 0870: 2c 0a 20 20 20 20 68 65 72 65 20 74 6f 20 63 6f ,. here to co 0880: 6e 74 65 6e 74 2d 73 74 72 69 6e 67 20 30 20 2c ntent-string 0 , 0890: 0a 20 20 20 20 30 20 2c 20 5c 20 6d 75 73 74 20 . 0 , \ must 08a0: 62 65 20 74 65 72 6d 69 6e 61 74 65 64 20 62 79 be terminated by 08b0: 20 6e 75 6c 6c 20 70 6f 69 6e 74 65 72 0a 20 20 null pointer. 08c0: 20 20 72 3e 20 64 70 20 21 20 3b 0a 0a 21 6e 6f r> dp ! ;..!no 08d0: 74 69 66 79 2d 61 72 67 73 0a 0a 3a 6e 6f 6e 61 tify-args..:nona 08e0: 6d 65 20 64 65 66 65 72 73 20 27 63 6f 6c 64 0a me defers 'cold. 08f0: 20 20 20 20 6e 6f 74 69 66 79 2d 73 65 6e 64 20 notify-send 0900: 6f 66 66 20 75 70 61 74 68 20 6f 66 66 20 6e 65 off upath off ne 0910: 74 32 6f 2d 6c 6f 67 6f 20 6f 66 66 0a 20 20 20 t2o-logo off. 0920: 20 21 75 70 61 74 68 20 21 6e 65 74 32 6f 2d 6c !upath !net2o-l 0930: 6f 67 6f 20 21 6e 6f 74 69 66 79 2d 61 72 67 73 ogo !notify-args 0940: 20 3b 20 69 73 20 27 63 6f 6c 64 0a 0a 3a 20 6c ; is 'cold..: l 0950: 69 6e 75 78 2d 6e 6f 74 69 66 69 63 61 74 69 6f inux-notificatio 0960: 6e 20 28 20 2d 2d 20 29 20 20 6e 6f 74 69 66 79 n ( -- ) notify 0970: 2d 73 65 6e 64 20 24 40 6c 65 6e 20 30 3d 20 3f -send $@len 0= ? 0980: 45 58 49 54 0a 20 20 20 20 74 69 74 6c 65 2d 73 EXIT. title-s 0990: 74 72 69 6e 67 20 30 20 3f 66 72 65 65 20 20 63 tring 0 ?free c 09a0: 6f 6e 74 65 6e 74 2d 73 74 72 69 6e 67 20 30 20 ontent-string 0 09b0: 3f 66 72 65 65 0a 20 20 20 20 5b 27 5d 20 6e 6f ?free. ['] no 09c0: 74 69 66 79 2d 74 69 74 6c 65 20 24 74 6d 70 20 tify-title $tmp 09d0: 64 75 70 20 30 3d 20 49 46 20 20 32 64 72 6f 70 dup 0= IF 2drop 09e0: 20 20 45 58 49 54 20 20 54 48 45 4e 0a 20 20 20 EXIT THEN. 09f0: 20 6e 6f 74 69 66 79 40 20 64 75 70 20 30 3d 20 notify@ dup 0= 0a00: 49 46 20 20 32 64 72 6f 70 20 32 64 72 6f 70 20 IF 2drop 2drop 0a10: 20 45 58 49 54 20 20 54 48 45 4e 0a 20 20 20 20 EXIT THEN. 0a20: 30 73 74 72 69 6e 67 20 63 6f 6e 74 65 6e 74 2d 0string content- 0a30: 73 74 72 69 6e 67 20 21 0a 20 20 20 20 30 73 74 string !. 0st 0a40: 72 69 6e 67 20 74 69 74 6c 65 2d 73 74 72 69 6e ring title-strin 0a50: 67 20 21 0a 20 20 20 20 6e 6f 74 69 66 79 2d 73 g !. notify-s 0a60: 65 6e 64 20 24 40 20 6e 6f 74 69 66 79 2d 61 72 end $@ notify-ar 0a70: 67 73 20 66 6f 72 6b 2b 65 78 65 63 20 3b 0a gs fork+exec ;.