diff --git a/files/bin/i3-watchers b/files/bin/i3-watchers index 5450688..92ba5ba 100755 --- a/files/bin/i3-watchers +++ b/files/bin/i3-watchers @@ -2,4 +2,4 @@ set DIR (cd (dirname (status -f)); and pwd) -i3-msg -t subscribe -m '["workspace"]' | jq --raw-output --unbuffered 'select(.change == "focus").current.name' | xargs -n1 -r on-focus-workspace & +i3-msg -t subscribe -m '["workspace"]' | jq --raw-output --unbuffered 'select(.change == "focus").current.name' | xargs -n1 -r on-focus-workspace diff --git a/files/bin/i3blocks-ntfy.sh b/files/bin/i3blocks-ntfy.sh new file mode 100755 index 0000000..8291bca --- /dev/null +++ b/files/bin/i3blocks-ntfy.sh @@ -0,0 +1,8 @@ +#!/bin/bash +ntfy_url=$1 +while echo  offline +do + curl -sN --proto-default https --retry 60 --retry-delay 1 --retry-max-time 60 --keepalive-time 1 $ntfy_url |\ + jq --unbuffered -r 'select(.event == "message" or .event == "open")|if .event == "message" then .message else "🖧 online" end'; + sleep 1; +done diff --git a/tasks/i3.yaml b/tasks/i3.yaml index 0be8a6e..e0e32b6 100644 --- a/tasks/i3.yaml +++ b/tasks/i3.yaml @@ -36,6 +36,18 @@ dest: ~/.config/i3blocks/config notify: i3 reload +- name: i3-watchers service for the default xsession + template: + src: i3/i3-watchers.service.j2 + dest: ~/.config/systemd/user/i3-watchers.service + notify: systemd daemon-reload + +- name: i3-watchers service for specific displays + template: + src: i3/i3-watchers@.service.j2 + dest: ~/.config/systemd/user/i3-watchers@.service + notify: systemd daemon-reload + - name: i3wm graphical-session service for the default xsession template: src: i3/i3wm.service.j2 @@ -50,6 +62,6 @@ - name: i3wm graphical-session service enabled systemd: - name: i3wm@.service + name: i3wm.service enabled: true scope: user diff --git a/templates/i3/i3-watchers.service.j2 b/templates/i3/i3-watchers.service.j2 new file mode 100644 index 0000000..5efa726 --- /dev/null +++ b/templates/i3/i3-watchers.service.j2 @@ -0,0 +1,11 @@ +{{ ansible_managed | comment }} + +[Unit] +PartOf=graphical-session.target +Requires=i3wm.service + +[Service] +ExecStart=/usr/bin/env i3-watchers + +[Install] +RequiredBy=xsession.target diff --git a/templates/i3/i3-watchers@.service.j2 b/templates/i3/i3-watchers@.service.j2 new file mode 100644 index 0000000..8978741 --- /dev/null +++ b/templates/i3/i3-watchers@.service.j2 @@ -0,0 +1,11 @@ +[Unit] +Description=i3 Window Manager for Display %i +Requires=i3wm@%i.service + +[Service] +Environment=DISPLAY=%i +Environment=XAUTHORITY=%h/.Xauthority%i +ExecStart=/usr/bin/env i3-watchers + +[Install] +WantedBy=default.target diff --git a/templates/i3/i3.config.j2 b/templates/i3/i3.config.j2 index f3055b5..660d096 100644 --- a/templates/i3/i3.config.j2 +++ b/templates/i3/i3.config.j2 @@ -368,6 +368,3 @@ assign [title="^Citrix maximized probe window$"] → citrix {% set ws = workspaces[workspace] %} assign [class="^(?:Tiger)?V[Nn][Cc] ?[Vv]iewer$" title="^{{ws.host}}:{{ws.display|default(home_vncserver_display_number)}}"] → {{workspace}} {% endfor %} - -# Autostart -exec --no-startup-id i3-watchers diff --git a/templates/i3/i3blocks.config.j2 b/templates/i3/i3blocks.config.j2 index b79309d..c563e2e 100644 --- a/templates/i3/i3blocks.config.j2 +++ b/templates/i3/i3blocks.config.j2 @@ -30,17 +30,20 @@ command=/usr/share/i3blocks/$BLOCK_NAME separator_block_width=15 markup=none +{% if i3blocks_ntfy_url is defined %} # todo -[todo] -command=i3block-socket-watcher {{todo_i3block_socket}} +[ntfy] +command=i3blocks-ntfy.sh {{ i3blocks_ntfy_url | quote }} interval=persist -markup=pango +{% endif %} +{# # timer [timer] command=i3block-socket-watcher {{timer_i3block_socket}} interval=persist markup=pango +#} # hostinfo [hostinfo] diff --git a/templates/i3/i3wm.service.j2 b/templates/i3/i3wm.service.j2 index 81f66ca..02b1d8d 100644 --- a/templates/i3/i3wm.service.j2 +++ b/templates/i3/i3wm.service.j2 @@ -1,6 +1,7 @@ [Unit] Description=i3 Window Manager PartOf=graphical-session.target +Wants=i3-watchers.service [Service] Type=exec