aboutsummaryrefslogtreecommitdiffstats
path: root/restart.sh
blob: f99ca988c7dea475e98fa13080473ad23295ed86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Restart the dashboard after editing dashboard.lua or a widget.
#
# Conky never rereads its config, and the Lua is symlinked into
# ~/.config/conky/, so a restart is the whole update path. Only a change to
# conky.conf.in or the palette needs UDT's install.sh to re-render first.
#
# Relaunched through hyprctl with `[workspace special:dash silent]`: the
# dashboard's window rule puts it on that workspace but cannot suppress the
# switch to it, so a plain exec throws the dashboard up over whatever is on
# screen.

set -u

CONF="$HOME/.config/conky/conky.conf"

if [ ! -e "$CONF" ]; then
    echo "restart: no $CONF (run ../unified-desktop-theme/install.sh first)" >&2
    exit 1
fi

# Syntax-check first: a Lua error is a blank screen with no message, so it is
# worth catching here rather than discovering it on the workspace.
if ! luac -p dashboard.lua lib/*.lua widgets/*.lua; then
    echo "restart: Lua syntax error, not restarting" >&2
    exit 1
fi

pkill -x conky 2>/dev/null && sleep 0.5

if command -v hyprctl >/dev/null 2>&1 && [ -n "${HYPRLAND_INSTANCE_SIGNATURE:-}" ]; then
    hyprctl dispatch \
        "hl.dsp.exec_cmd(\"[workspace special:dash silent] conky -c $CONF -d\")" \
        >/dev/null
else
    (conky -c "$CONF" -d >/dev/null 2>&1 &)
fi

sleep 1
if pgrep -x conky >/dev/null; then
    echo "dashboard restarted"
else
    echo "restart: conky did not come up; run it in the foreground to see why:" >&2
    echo "    conky -c $CONF" >&2
    exit 1
fi