Skip to content

Commit

Permalink
feat: add ublue-changelog script to ublue-motd package (#105)
Browse files Browse the repository at this point in the history
That way we get some fancy changelogs on our images!! Yay!
  • Loading branch information
tulilirockz authored Jan 7, 2025
1 parent 601ed37 commit c7fb361
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
29 changes: 29 additions & 0 deletions ublue/motd/src/ublue-changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

get_config() {
CHANGELOG_CONFIG_FILE="${changelog_CONFIG_FILE:-/etc/ublue-os/changelog.json}"
QUERY="$1"
FALLBACK="$2"
shift
shift
OUTPUT="$(jq -r "$QUERY" "$CHANGELOG_CONFIG_FILE" 2>/dev/null || echo "$FALLBACK")"
if [ "$OUTPUT" == "null" ] ; then
echo "$FALLBACK"
return
fi
echo "$OUTPUT"
}

DEFAULT_THEME="$(get_config '."default-theme"' "slate")"
TARGET_URL="$(get_config '."target-url"' "invalid")"
JQ_EXPRESSION="$(get_config '."jq-expression"' ".body")"
THEMES_DIRECTORY="$(get_config '."themes-directory"' "/usr/share/ublue-os/motd/themes")"

THEME=$(dconf read /org/gnome/desktop/interface/accent-color 2>/dev/null || printf '%s' "\'$DEFAULT_THEME\'")
THEME=${THEME//\'/}
THEME=${CHANGELOG_FORCE_THEME:-$THEME}


curl -s "$TARGET_URL" | \
jq -r "$JQ_EXPRESSION" | \
glow -s "${THEMES_DIRECTORY}/${THEME}.json" -w 78 - $@
3 changes: 2 additions & 1 deletion ublue/motd/src/ublue-motd
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ KEY_WARN_FILE="/run/user-motd-sbkey-warn.md"
[ -e $KEY_WARN_FILE ] && KEY_WARN="**WARNING**: $(cat $KEY_WARN_FILE)"
KEY_WARN_ESCAPED=$(escape "$KEY_WARN")

THEME=$(gsettings get org.gnome.desktop.interface accent-color 2>/dev/null || printf '%s' "\'$DEFAULT_THEME\'")

THEME=$(dconf read /org/gnome/desktop/interface/accent-color 2>/dev/null || printf '%s' "\'$DEFAULT_THEME\'")
THEME=${THEME//\'/}
THEME=${MOTD_FORCE_THEME:-$THEME}

Expand Down
14 changes: 9 additions & 5 deletions ublue/motd/ublue-motd.spec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%global debug_package %{nil}

Name: ublue-motd
Version: 0.1.0
Version: 0.2.0
Release: 1%{?dist}
Summary: MOTD scripts for Universal Blue images

Expand All @@ -11,22 +11,26 @@ VCS: {{{ git_dir_vcs }}}
Source: {{{ git_dir_pack }}}

Requires: glow
Requires: jq
Requires: curl

%description
MOTD script for Universal Blue
MOTD and changelogs script for Universal Blue

%prep
{{{ git_dir_setup_macro }}}

%install
install -Dm0755 ./src/ublue-motd %{buildroot}%{_libexecdir}/ublue-motd
install -dm 0755 %{buildroot}%{_datadir}/ublue-os/motd/themes
install -dm0755 %{buildroot}%{_datadir}/ublue-os/motd/themes
cp -rp ./src/themes/* %{buildroot}%{_datadir}/ublue-os/motd/themes
install -Dm0755 ./src/%{name} %{buildroot}%{_libexecdir}/%{name}
install -Dm0755 ./src/ublue-changelog %{buildroot}%{_libexecdir}/ublue-changelog
install -Dm0755 ./src/vendor.sh %{buildroot}%{_sysconfdir}/profile.d/%{name}.sh
install -Dm0755 ./src/vendor.fish %{buildroot}%{_datadir}/fish/vendor_conf.d/%{name}.fish

%files
%{_libexecdir}/ublue-motd
%{_libexecdir}/%{name}
%{_libexecdir}/ublue-changelog
%{_datadir}/ublue-os/motd/themes/*
%{_sysconfdir}/profile.d/%{name}.sh
%{_datadir}/fish/vendor_conf.d/%{name}.fish
Expand Down

0 comments on commit c7fb361

Please sign in to comment.