Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements in install script #26

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
obj/
*.so
compile_flags.txt
compile_commands.json
.cache/
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ check_env:
exit 1; \
fi
@if pkg-config --exists hyprland; then \
echo 'Hyprland headers found.'; \
echo 'Hyprland headers found in: '`pkg-config --variable=includedir hyprland`; \
else \
echo 'Hyprland headers not available. Run `make all` in the root Hyprland directory.'; \
exit 1; \
Expand Down
39 changes: 31 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,31 @@
# This script is used to install hyprload, in a known location

progress() {
echo -e "\033[1;32m$1\033[0m"
echo -e "\033[1;32m$1\033[0m"
}

info() {
echo -e "\033[1;34m$1\033[0m"
}

warn() {
echo -e "\033[1;31m$1\033[0m"
}

set -e

HYPRLOAD_PATH=$HOME/.local/share/hyprload

HYPRLOAD_SOURCE_PATH="$HYPRLOAD_PATH/src"

progress "[1/7] Cloning hyprload to $HYPRLOAD_SOURCE_PATH"

if [ -d "$HYPRLOAD_SOURCE_PATH" ]; then
git -C "$HYPRLOAD_SOURCE_PATH" pull
info "Updating existing hyprload source"
git -C "$HYPRLOAD_SOURCE_PATH" pull origin main
else
git clone https://github.com/duckonaut/hyprload.git "$HYPRLOAD_SOURCE_PATH" --depth 1
info "Cloning hyprload source"
git clone https://github.com/duckonaut/hyprload.git "$HYPRLOAD_SOURCE_PATH" --depth 1
fi

progress "[2/7] Cloned hyprload source to $HYPRLOAD_SOURCE_PATH"
Expand All @@ -24,19 +36,30 @@ HYPRLAND_PATH="$HYPRLOAD_PATH/include/hyprland"
progress "[3/7] Setting up hyprland source in $HYPRLAND_PATH"

if [ -d "$HYPRLAND_PATH" ]; then
git -C "$HYPRLAND_PATH" pull
info "Updating existing hyprland source"
git -C "$HYPRLAND_PATH" pull origin main
Comment on lines -27 to +40
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed git pull doesn't always seem to work (when already checked out to a specific commit), specifying origin main fixed that.

else
git clone https://github.com/hyprwm/Hyprland.git "$HYPRLAND_PATH" --recursive
info "Cloning hyprland source"
git clone https://github.com/hyprwm/Hyprland.git "$HYPRLAND_PATH" --recursive
fi

HYPRLAND_COMMIT=""
if [ -z $(which hyprctl) ]; then
HYPRLAND_COMMIT=$(git -C "$HYPRLAND_PATH" rev-parse HEAD)
warn "hyprctl not found, using latest Hyprland commit"
HYPRLAND_COMMIT=$(git -C "$HYPRLAND_PATH" rev-parse HEAD)
else
HYPRLAND_COMMIT=$(hyprctl version | grep "commit" | cut -d " " -f 8 | sed 's/dirty$//')
git -C "$HYPRLAND_PATH" checkout "$HYPRLAND_COMMIT"
info "hyprctl found, using commit from hyprctl"
HYPRLAND_COMMIT=$(hyprctl version | grep "commit" | cut -d " " -f 8 | sed 's/dirty$//')
git -C "$HYPRLAND_PATH" checkout "$HYPRLAND_COMMIT"
fi

info "Checking out Hyprland submodules"
git -C "$HYPRLAND_PATH" submodule update --init --recursive

if [ -z "$(ls -A $HYPRLAND_PATH)" ]; then
warn "ERROR: Hyprland was not cloned properly."
exit 1
fi

progress "[4/7] Set up hyprland source in $HYPRLAND_PATH at commit $HYPRLAND_COMMIT"

Expand Down
6 changes: 3 additions & 3 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ namespace hyprload {

int exit = pclose(pipe);

Debug::log(LOG, " [hyprload] Command: %s", command.c_str());
Debug::log(LOG, " [hyprload] Exit code: %d", exit);
Debug::log(LOG, " [hyprload] Result: %s", result.c_str());
Debug::log(LOG, " [hyprload] Command: {}", command);
Debug::log(LOG, " [hyprload] Exit code: {}", exit);
Debug::log(LOG, " [hyprload] Result: {}", result);

return std::make_tuple(exit, result);
}
Expand Down