2022-05-05 22:38:39 +00:00
|
|
|
(local { : view } (require :fennel))
|
|
|
|
|
2022-07-03 10:16:37 +00:00
|
|
|
(local texture (require :texture))
|
2022-07-03 13:03:35 +00:00
|
|
|
(local matrix (require :matrix))
|
2022-07-01 21:28:41 +00:00
|
|
|
(local socket-repl (require :socket-repl))
|
2022-05-05 22:38:39 +00:00
|
|
|
|
2022-07-01 21:28:41 +00:00
|
|
|
(let [repl-socket-name
|
|
|
|
(..
|
|
|
|
(: (os.getenv "XDG_RUNTIME_DIR") :gsub "/$" "")
|
|
|
|
"/kiwmi-repl."
|
|
|
|
(os.getenv "WAYLAND_DISPLAY")
|
|
|
|
".socket"
|
|
|
|
)]
|
|
|
|
(socket-repl.start repl-socket-name))
|
2022-05-08 21:38:44 +00:00
|
|
|
|
2022-07-01 22:09:00 +00:00
|
|
|
(fn resize-wayland-backend [output]
|
|
|
|
(when (string.find (output:name) "^WL-")
|
|
|
|
(output:set_mode 360 720 0)))
|
2022-05-08 21:38:44 +00:00
|
|
|
|
2022-07-03 14:36:48 +00:00
|
|
|
(fn kill-window []
|
|
|
|
(print "DIE")
|
|
|
|
true)
|
|
|
|
|
|
|
|
(fn launch []
|
|
|
|
(print "WHOOSH")
|
|
|
|
true)
|
|
|
|
|
|
|
|
(fn carousel []
|
|
|
|
(print "spin spin sugar")
|
|
|
|
true)
|
|
|
|
|
|
|
|
(fn placements [output]
|
|
|
|
(let [(width height) (output:size)
|
|
|
|
bar-height (/ height 15)]
|
|
|
|
{
|
|
|
|
|
|
|
|
:application {
|
|
|
|
:x 0
|
|
|
|
:y 0
|
|
|
|
:w width
|
|
|
|
:h (- height (* bar-height 1.1))
|
|
|
|
}
|
|
|
|
:bar {
|
|
|
|
:x 0
|
|
|
|
:y (- height (* bar-height 1.1))
|
|
|
|
:w width
|
|
|
|
:h (* bar-height 1.1)
|
|
|
|
}
|
|
|
|
:kill {
|
|
|
|
:x (- (* width 0.25) (/ bar-height 2))
|
|
|
|
:y (- height bar-height)
|
|
|
|
:w bar-height
|
|
|
|
:h bar-height
|
|
|
|
:on-press kill-window
|
|
|
|
}
|
|
|
|
:launch {
|
|
|
|
:x (- (* width 0.5) (/ bar-height 2))
|
|
|
|
:y (- height bar-height)
|
|
|
|
:w bar-height
|
|
|
|
:h bar-height
|
|
|
|
:on-press launch
|
|
|
|
}
|
|
|
|
:overview {
|
|
|
|
:x (- (* width 0.75) (/ bar-height 2))
|
|
|
|
:y (- height bar-height)
|
|
|
|
:w bar-height
|
|
|
|
:h bar-height
|
|
|
|
:on-press carousel
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
|
2022-05-05 22:38:39 +00:00
|
|
|
(kiwmi:on
|
|
|
|
"output"
|
|
|
|
(fn [output]
|
2022-07-03 13:57:57 +00:00
|
|
|
(resize-wayland-backend output)
|
|
|
|
(let [(width height) (output:size)
|
2022-07-01 22:08:15 +00:00
|
|
|
r (output:renderer)
|
2022-07-03 10:16:37 +00:00
|
|
|
kill (texture.from-file r "close-window.png")
|
|
|
|
launch (texture.from-file r "launcher.png")
|
2022-07-03 22:17:39 +00:00
|
|
|
overview (texture.from-file r "carousel.png")]
|
2022-05-05 22:38:39 +00:00
|
|
|
(output:on "render"
|
|
|
|
(fn [{: output : renderer}]
|
2022-07-03 14:36:48 +00:00
|
|
|
(let [buttons (placements output)]
|
|
|
|
(renderer:draw_rect :#77000077
|
|
|
|
buttons.bar.x buttons.bar.y
|
|
|
|
buttons.bar.w buttons.bar.h)
|
2022-05-08 21:38:44 +00:00
|
|
|
(renderer:draw_texture
|
|
|
|
kill
|
2022-07-03 13:03:35 +00:00
|
|
|
matrix.identity
|
2022-07-03 14:36:48 +00:00
|
|
|
buttons.kill.x buttons.kill.y
|
2022-05-08 21:38:44 +00:00
|
|
|
0.7)
|
|
|
|
(renderer:draw_texture
|
2022-07-03 13:03:35 +00:00
|
|
|
launch
|
|
|
|
matrix.identity
|
2022-07-03 14:36:48 +00:00
|
|
|
buttons.launch.x buttons.launch.y
|
2022-05-08 21:38:44 +00:00
|
|
|
0.7)
|
|
|
|
(renderer:draw_texture
|
2022-07-03 22:17:39 +00:00
|
|
|
overview
|
2022-07-03 13:03:35 +00:00
|
|
|
matrix.identity
|
2022-07-03 14:36:48 +00:00
|
|
|
buttons.overview.x buttons.overview.y
|
2022-05-08 21:38:44 +00:00
|
|
|
0.7)))))))
|
|
|
|
|
2022-05-08 21:48:44 +00:00
|
|
|
|
|
|
|
(let [cursor (kiwmi:cursor)]
|
|
|
|
(cursor:on "button_down"
|
|
|
|
(fn [button]
|
|
|
|
(let [(x y) (cursor:pos)]
|
2022-07-03 14:36:48 +00:00
|
|
|
(each [name attribs (pairs (placements (kiwmi:active_output)))]
|
|
|
|
(if (and
|
|
|
|
(<= attribs.x x)
|
|
|
|
(< x (+ attribs.x attribs.w))
|
|
|
|
(<= attribs.y y)
|
|
|
|
(< y (+ attribs.y attribs.h)))
|
|
|
|
(if attribs.on-press (attribs.on-press))))))))
|
2022-05-05 22:38:39 +00:00
|
|
|
|
2022-04-26 21:13:51 +00:00
|
|
|
(kiwmi:on "view"
|
|
|
|
(fn [view]
|
2022-07-03 14:36:48 +00:00
|
|
|
(let [geom (placements (kiwmi:active_output))]
|
|
|
|
(view:resize geom.application.w geom.application.h)
|
|
|
|
(view:move geom.application.x geom.application.y))
|
2022-04-26 21:13:51 +00:00
|
|
|
(view:focus)
|
|
|
|
(view:show)
|
|
|
|
(view:on "request_move" #(view:imove))
|
|
|
|
(view:on "request_resize" (fn [ev] (view:iresize ev.edges)))))
|
2022-04-26 20:14:46 +00:00
|
|
|
|
2022-04-26 21:13:37 +00:00
|
|
|
|
|
|
|
;(kiwmi:spawn "swaybg -c '#ff00ff'")
|
|
|
|
(kiwmi:spawn "lua -l fennelrun modeline.fnl")
|
2022-04-26 22:01:30 +00:00
|
|
|
(kiwmi:spawn "lua -l fennelrun saturn/main.fnl")
|
2022-04-27 09:07:33 +00:00
|
|
|
(kiwmi:spawn "lua -l fennelrun crier/crier.fnl")
|
2022-04-27 12:26:54 +00:00
|
|
|
(kiwmi:spawn "lua -l fennelrun just/just.fnl")
|
2022-04-27 09:07:33 +00:00
|
|
|
;(kiwmi:spawn "foot")
|