Compare commits

..

No commits in common. "dd8fc68c626f80f6a9c90dc7702bd027403b64f1" and "f64f06b35bb52dfc70910ea1924369b05ce54c92" have entirely different histories.

2 changed files with 17 additions and 25 deletions

View File

@ -1,10 +1,9 @@
(import astal *) (import astal *)
(import astal.gtk3 *) (import astal.gtk3 *)
(import datetime)
(let [ (let [
time (.poll (Variable "") 1000 (fn [_] (. datetime datetime (now) (strftime "%d %b %H:%M:%S"))) (fn [out] out)) datetime (.poll (Variable "") 1000 "date +'%d %b %H:%M:%S'" (fn [out _] out))
unix-seconds (.poll (Variable "") 1000 (fn [_] (. datetime datetime (now) (strftime "%s"))) (fn [out] out))] unix-seconds (.poll (Variable "") 1000 "date +%s" (fn [out _] out))]
(setv clock (Widget.Box (setv clock (Widget.Box
:class-name "clock" :class-name "clock"
:vertical True :vertical True
@ -12,7 +11,7 @@
:children [ :children [
(Widget.Label (Widget.Label
:halign Gtk.Align.START :halign Gtk.Align.START
:label (bind time)) :label (bind datetime))
(Widget.Label (Widget.Label
:halign Gtk.Align.START :halign Gtk.Align.START
:label (bind unix-seconds))]))) :label (bind unix-seconds))])))

View File

@ -1,41 +1,34 @@
(import astal *) (import astal *)
(import astal.gtk3 *) (import astal.gtk3 *)
(.require-version gi "AstalNiri" "0.1") (.require-version gi "AstalHyprland" "0.1")
(import gi.repository [AstalHyprland :as Hyprland])
(import gi.repository [AstalNiri :as Niri])
(let [ (let [
Niri (.get-default Niri) hyprland (.get-default Hyprland)
workspace-row (fn [start stop] workspace-row (fn [start stop]
(Widget.Box (Widget.Box
:children (lfor i (range start stop) :children (lfor i (range start stop)
(Widget.Button (Widget.Button
:class-name "workspace" :class-name "workspace"
:attribute (+ i 1) :attribute (+ i 1)
:on-clicked (fn [self] (exec-async f"niri msg action focus-workspace {self.attribute}")) :on-clicked (fn [self] (.message-async hyprland f"dispatch workspace {self.attribute}"))
:setup (fn [self] :setup (fn [self]
(.hook self hyprland "notify::focused-workspace" (fn [self, w] (.toggle-class-name self "focused" (= (.get-id w) self.attribute))))
(.hook self Niri "workspace-activated" (fn [_ w __]
(when w
(.toggle-class-name self "focused" (= (.get-id (. Niri (get-workspace w))) self.attribute)))))
(defn update [#* _] (defn update [#* _]
(let [workspace (.get-workspace Niri self.attribute)] (let [workspace (.get-workspace hyprland self.attribute)]
(when (!= workspace None) (when (!= workspace None)
(.toggle-class-name self "occupied" (< 0 (len (lfor window (. Niri (get-windows)) (.toggle-class-name self "occupied" (< 0 (len (.get-clients workspace)))))))
:if (= (.get-workspace-id window) (.get-id workspace))
window)))))))
(.hook self Niri "workspaces-changed" update) (.hook self hyprland "notify::workspaces" update)
(.hook self Niri "window-opened" update) (.hook self hyprland "notify::clients" update)
(.hook self Niri "window-changed" update) (.hook self hyprland "client-moved" update)
(.hook self Niri "window-closed" update) (update)
(idle update) (when (= (.get-id (.get-focused-workspace hyprland)) self.attribute)
(.toggle-class-name self "focused")))))))]
(idle (fn [] (when (= (.get-id (.get-focused-workspace Niri)) self.attribute)
(.toggle-class-name self "focused")))))))))]
(setv workspaces (Widget.Box (setv workspaces (Widget.Box
:class_name "workspaces" :class_name "workspaces"