diff --git a/coding-terminal b/coding-terminal index 9f51ce0..91592bf 100755 --- a/coding-terminal +++ b/coding-terminal @@ -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 diff --git a/host-cwd.sh b/host-cwd.sh index 80cbcce..9a49307 100755 --- a/host-cwd.sh +++ b/host-cwd.sh @@ -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` diff --git a/makefile-notifyd b/makefile-notifyd new file mode 100644 index 0000000..ed227bf --- /dev/null +++ b/makefile-notifyd @@ -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 diff --git a/net-notify.scm b/net-notify.scm new file mode 100644 index 0000000..64b2d86 --- /dev/null +++ b/net-notify.scm @@ -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 ") + (newline)) + (begin (broadcast-setup) + (broadcast-send (string-concatenate (intersperse (cons "net-notify:" args) " "))))))) + +(main) diff --git a/net-notifyd.scm b/net-notifyd.scm new file mode 100644 index 0000000..01be2d2 --- /dev/null +++ b/net-notifyd.scm @@ -0,0 +1,50 @@ +(import scheme) +(import (chicken base)) +(import srfi-1) +(import srfi-13) +(import socket) + +(foreign-declare "#include ") + +(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) +