notification programs that work over the local network
This commit is contained in:
parent
e2a3c50844
commit
252ae8d03c
@ -1,4 +1,4 @@
|
||||
#!/bin/zsh
|
||||
#xrdb -merge ~/.Xresources.green
|
||||
urxvt -fn xft:inconsolata-26:hinting=false -letsp 1 -im none -b 26 &
|
||||
#xrdb -merge ~/.Xresources
|
||||
xrdb -merge ~/.Xresources.green
|
||||
urxvt -fn xft:inconsolata-26:antialias=true:hinting=true -letsp 1 -b 26 &
|
||||
xrdb -merge ~/.Xresources
|
||||
|
@ -1,2 +1,2 @@
|
||||
#!/bin/zsh
|
||||
ruby -run -e httpd . -p 8080 --bind-address=192.168.1.2
|
||||
ruby -run -e httpd . -p 8080 --bind-address=`~/Scripts/current-ip.sh`
|
||||
|
1
makefile-notifyd
Normal file
1
makefile-notifyd
Normal file
@ -0,0 +1 @@
|
||||
csc net-notifyd.scm -o net-notifyd -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libpng16 -I/usr/include/x86_64-linux-gnu -I/usr/include/libmount -I/usr/include/blkid -L -lnotify -L -lgio-2.0 -L -lgdk_pixbuf-2.0 -L -lgobject-2.0 -L -lglib-2.0
|
30
net-notify.scm
Normal file
30
net-notify.scm
Normal file
@ -0,0 +1,30 @@
|
||||
(import scheme)
|
||||
(import (chicken base))
|
||||
(import srfi-1)
|
||||
(import srfi-13)
|
||||
(import socket)
|
||||
(import (chicken process-context))
|
||||
|
||||
(define broadcast-socket #f)
|
||||
|
||||
(define bind-address (inet-address "0.0.0.0" #f))
|
||||
|
||||
(define broadcast-address (inet-address "255.255.255.255" 3742))
|
||||
|
||||
(define (broadcast-setup)
|
||||
(set! broadcast-socket (socket af/inet sock/dgram))
|
||||
(set! (so-broadcast? broadcast-socket) #t)
|
||||
(socket-bind broadcast-socket bind-address))
|
||||
|
||||
(define (broadcast-send str)
|
||||
(socket-send-to broadcast-socket str broadcast-address))
|
||||
|
||||
(define (main)
|
||||
(let ((args (drop (argv) 1)))
|
||||
(if (null? args)
|
||||
(begin (display "usage: net-notify <message>")
|
||||
(newline))
|
||||
(begin (broadcast-setup)
|
||||
(broadcast-send (string-concatenate (intersperse (cons "net-notify:" args) " ")))))))
|
||||
|
||||
(main)
|
50
net-notifyd.scm
Normal file
50
net-notifyd.scm
Normal file
@ -0,0 +1,50 @@
|
||||
(import scheme)
|
||||
(import (chicken base))
|
||||
(import srfi-1)
|
||||
(import srfi-13)
|
||||
(import socket)
|
||||
|
||||
(foreign-declare "#include <libnotify/notify.h>")
|
||||
|
||||
(define (forever tn)
|
||||
(tn)
|
||||
(forever tn))
|
||||
|
||||
(define-syntax thunk
|
||||
(syntax-rules ()
|
||||
((_ exp ...)
|
||||
(lambda () exp ...))))
|
||||
|
||||
(define notify
|
||||
(foreign-lambda* void ((c-string title) (c-string body))
|
||||
"NotifyNotification *notif;\n"
|
||||
"notify_init(title);\n"
|
||||
"notif = notify_notification_new(title, body, NULL);\n"
|
||||
"notify_notification_show(notif, NULL);\n"
|
||||
"g_object_unref(notif);\n"))
|
||||
|
||||
(define broadcast-socket #f)
|
||||
|
||||
(define broadcast-address (inet-address "255.255.255.255" 3742))
|
||||
|
||||
(define (broadcast-setup)
|
||||
(set! broadcast-socket (socket af/inet sock/dgram))
|
||||
(set! (so-broadcast? broadcast-socket) #t)
|
||||
(socket-bind broadcast-socket broadcast-address))
|
||||
|
||||
(define (broadcast-receive)
|
||||
(condition-case (socket-receive broadcast-socket 256)
|
||||
((exn timeout) (broadcast-receive))))
|
||||
|
||||
(define (net-notify-listen)
|
||||
(let ((response (broadcast-receive)))
|
||||
(if (equal? (string-take response 12) "net-notify: ")
|
||||
(string-drop response 12)
|
||||
(net-notify-listen))))
|
||||
|
||||
(define (main)
|
||||
(broadcast-setup)
|
||||
(forever (thunk (notify "net-notify" (net-notify-listen)))))
|
||||
|
||||
(main)
|
||||
|
Loading…
Reference in New Issue
Block a user