Added hyprsolusctl
Added hyprsolusctl which is a control script for managing hyprsolus.
Features include:
- checking for new updates. This provides the ability to know when a
newer version of Hyprland has been release. Note that this works
based off the tags of Hyprland, which are the releases.
- provide info of the latest changes. The changelog provided by
Hyprland is saved locally under $HOME/.cached and can be viewed any
time. If a newer version of Hyprland is available the changelog will
be this.
- update hyprsolus. The ability to update hyprsolus itself.
- upgrading the system (WIP). The system is prepared and upgraded with
the latest versions of libraries, components provided by hyprsolus
and importantly Hyprland itself.
This commit is contained in:
parent
2a77d230cc
commit
dab6392d04
128
hyprsolusctl
Normal file
128
hyprsolusctl
Normal file
|
|
@ -0,0 +1,128 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
HYPRSOLUS_PATH="/usr/src/hyprsolus"
|
||||||
|
|
||||||
|
# create cache folder for Hyprland metadata
|
||||||
|
cache="$HOME/.cache/hyprsolus"
|
||||||
|
[[ ! -d "$cache" ]] && mkdir -p "$cache" >/dev/null
|
||||||
|
|
||||||
|
check () {
|
||||||
|
>&2 echo "Checking for Hyprland upgrades..."
|
||||||
|
# ensure that Hyprland is even running
|
||||||
|
if ! pidof hyprland
|
||||||
|
then
|
||||||
|
>&2 echo "Could not find Hyprland process. Is it even running?"
|
||||||
|
exit 255
|
||||||
|
fi
|
||||||
|
# get the releases from the origin
|
||||||
|
origin=$(curl -sL \
|
||||||
|
https://api.github.com/repos/hyprwm/Hyprland/releases)
|
||||||
|
exit_code=$?
|
||||||
|
# check if the cURL was successful
|
||||||
|
if [[ $exit_code -ne 0 ]]
|
||||||
|
then
|
||||||
|
>&2 echo "Failed to contact GitHub API. Check Internet connection and \
|
||||||
|
try again."
|
||||||
|
exit 254
|
||||||
|
fi
|
||||||
|
# latest tag release in origin and current Hyprland version
|
||||||
|
origin_vers=$(echo "$origin" | jq -r ".[0].tag_name")
|
||||||
|
hyprland_vers=$(hyprctl version | sed -nr 's/Tag: (.*),.*/\1/p')
|
||||||
|
|
||||||
|
[[ ! -e "$cache/metadata.json" ]] && echo "$origin" \
|
||||||
|
| jq -r ".[] | select(.tag_name == \"$hyprland_vers\")" \
|
||||||
|
>"$cache/metadata.json"
|
||||||
|
|
||||||
|
if [[ "$origin_vers" != "$hyprland_vers" ]]
|
||||||
|
then
|
||||||
|
echo "$origin" | jq -r ".[0]" >"$cache/release-metadata.json"
|
||||||
|
notify-send -a "Hyprsolus" "Hyprland Update Available" \
|
||||||
|
"A new version of Hyprland is available ($origin_vers)."
|
||||||
|
else
|
||||||
|
>&2 echo "No upgrade available. Ensuring most recent metadata..."
|
||||||
|
[[ -f "$cache/release-metadata.json" ]] && \
|
||||||
|
mv "$cache/release-metadata.json" "$cache/metadata.json"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
info () {
|
||||||
|
while test $# -ne 0
|
||||||
|
do
|
||||||
|
case $1 in
|
||||||
|
--local) shift ; release=0 ;;
|
||||||
|
--json) shift ; json=0 ;;
|
||||||
|
--) shift ; glow_args="$*" ; break ;;
|
||||||
|
*) echo "$1"
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Initialise defaults if no flags given
|
||||||
|
release=${release:-1}
|
||||||
|
json=${json:-1}
|
||||||
|
|
||||||
|
if [[ -e "$cache/release-metadata.json" && $release -eq 1 ]]
|
||||||
|
then
|
||||||
|
[[ ! -s "$cache/release-metadata.json" ]] && exit 2
|
||||||
|
[[ $json -eq 0 ]] && cat "$cache/release-metadata.json" && exit 0
|
||||||
|
jq -r ".body" < "$cache/release-metadata.json" | glow "$glow_args" -
|
||||||
|
elif [[ -e "$cache/metadata.json" ]]
|
||||||
|
then
|
||||||
|
[[ ! -s "$cache/metadata.json" ]] && exit 2
|
||||||
|
[[ $json -eq 0 ]] && cat "$cache/metadata.json" && exit 0
|
||||||
|
jq -r ".body" "$cache/metadata.json" | glow "$glow_args" -
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
update () {
|
||||||
|
cd "$HYPRSOLUS_PATH"
|
||||||
|
|
||||||
|
# Fetch new content from remote
|
||||||
|
git fetch origin --all
|
||||||
|
git pull origin main
|
||||||
|
|
||||||
|
echo "(hyprsolus) Updating the dependencies if needed."
|
||||||
|
sudo sh "${HYPRSOLUS_PATH}/requirements.sh"
|
||||||
|
|
||||||
|
echo "(hyprsolus) Updating additional scripts if needed."
|
||||||
|
sudo cp -ru "${HYPRSOLUS_PATH}/systemd" "$HOME/.config/systemd/"
|
||||||
|
sudo cp -u "${HYPRSOLUS_PATH}/hyprsolusctl" "$HYPRSOLUSCTL_PATH" & disown
|
||||||
|
}
|
||||||
|
|
||||||
|
upgrade () {
|
||||||
|
while test $# -ne 0
|
||||||
|
do
|
||||||
|
case $1 in
|
||||||
|
--ensure-integrity) shift ; eopkg_check=0 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
eopkg_check=${eopkg_check:-1}
|
||||||
|
if [[ $eopkg_check -eq 0 ]]
|
||||||
|
then
|
||||||
|
echo -n "Check package intergity..."
|
||||||
|
while read -r line
|
||||||
|
do
|
||||||
|
check=$(eopkg check --no-color "$line" | grep -o "OK")
|
||||||
|
if [[ $check != OK ]]
|
||||||
|
then
|
||||||
|
>&2 echo -e "failed.\n[FATAL] The following package is corrupt: $line."\
|
||||||
|
"Aborting upgrade."
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
done < <(cat depends.txt)
|
||||||
|
echo "ok."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TODO: Implement calls to make build system
|
||||||
|
}
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
check) check ;;
|
||||||
|
update) update ;;
|
||||||
|
upgrade) shift ; upgrade "$@" ;;
|
||||||
|
info) shift ; info "$@" ;;
|
||||||
|
*) exit 1 ;;
|
||||||
|
esac
|
||||||
|
exit 0
|
||||||
Loading…
Reference in New Issue
Block a user