diff --git a/.clang-format-ignore b/.clang-format-ignore deleted file mode 100644 index c6bf34ed..00000000 --- a/.clang-format-ignore +++ /dev/null @@ -1 +0,0 @@ -subprojects/**/* diff --git a/.clang-tidy b/.clang-tidy deleted file mode 100644 index db499035..00000000 --- a/.clang-tidy +++ /dev/null @@ -1,208 +0,0 @@ -WarningsAsErrors: > - -*, - bugprone-*, - -bugprone-multi-level-implicit-pointer-conversion, - -bugprone-empty-catch, - -bugprone-unused-return-value, - -bugprone-reserved-identifier, - -bugprone-switch-missing-default-case, - -bugprone-unused-local-non-trivial-variable, - -bugprone-easily-swappable-parameters, - -bugprone-forward-declararion-namespace, - -bugprone-forward-declararion-namespace, - -bugprone-macro-parentheses, - -bugprone-narrowing-conversions, - -bugprone-branch-clone, - -bugprone-assignment-in-if-condition, - concurrency-*, - -concurrency-mt-unsafe, - cppcoreguidelines-*, - -cppcoreguidelines-pro-type-const-cast, - -cppcoreguidelines-owning-memory, - -cppcoreguidelines-avoid-magic-numbers, - -cppcoreguidelines-pro-bounds-constant-array-index, - -cppcoreguidelines-avoid-const-or-ref-data-members, - -cppcoreguidelines-non-private-member-variables-in-classes, - -cppcoreguidelines-avoid-goto, - -cppcoreguidelines-pro-bounds-array-to-pointer-decay, - -cppcoreguidelines-avoid-do-while, - -cppcoreguidelines-avoid-non-const-global-variables, - -cppcoreguidelines-special-member-functions, - -cppcoreguidelines-explicit-virtual-functions, - -cppcoreguidelines-avoid-c-arrays, - -cppcoreguidelines-pro-bounds-pointer-arithmetic, - -cppcoreguidelines-narrowing-conversions, - -cppcoreguidelines-pro-type-union-access, - -cppcoreguidelines-pro-type-member-init, - -cppcoreguidelines-macro-usage, - -cppcoreguidelines-macro-to-enum, - -cppcoreguidelines-init-variables, - -cppcoreguidelines-pro-type-cstyle-cast, - -cppcoreguidelines-pro-type-vararg, - -cppcoreguidelines-pro-type-reinterpret-cast, - -google-global-names-in-headers, - -google-readability-casting, - google-runtime-operator, - misc-*, - -misc-use-internal-linkage, - -misc-unused-parameters, - -misc-no-recursion, - -misc-non-private-member-variables-in-classes, - -misc-include-cleaner, - -misc-use-anonymous-namespace, - -misc-const-correctness, - modernize-*, - -modernize-use-emplace, - -modernize-redundant-void-arg, - -modernize-use-starts-ends-with, - -modernize-use-designated-initializers, - -modernize-use-std-numbers, - -modernize-return-braced-init-list, - -modernize-use-trailing-return-type, - -modernize-use-using, - -modernize-use-override, - -modernize-avoid-c-arrays, - -modernize-macro-to-enum, - -modernize-loop-convert, - -modernize-use-nodiscard, - -modernize-pass-by-value, - -modernize-use-auto, - performance-*, - -performance-inefficient-vector-operation, - -performance-inefficient-string-concatenation, - -performance-enum-size, - -performance-move-const-arg, - -performance-avoid-endl, - -performance-unnecessary-value-param, - portability-std-allocator-const, - readability-*, - -readability-identifier-naming, - -readability-use-std-min-max, - -readability-math-missing-parentheses, - -readability-simplify-boolean-expr, - -readability-static-accessed-through-instance, - -readability-use-anyofallof, - -readability-enum-initial-value, - -readability-redundant-inline-specifier, - -readability-function-cognitive-complexity, - -readability-function-size, - -readability-identifier-length, - -readability-magic-numbers, - -readability-uppercase-literal-suffix, - -readability-braces-around-statements, - -readability-redundant-access-specifiers, - -readability-else-after-return, - -readability-container-data-pointer, - -readability-implicit-bool-conversion, - -readability-avoid-nested-conditional-operator, - -readability-redundant-member-init, - -readability-redundant-string-init, - -readability-avoid-const-params-in-decls, - -readability-named-parameter, - -readability-convert-member-functions-to-static, - -readability-qualified-auto, - -readability-make-member-function-const, - -readability-isolate-declaration, - -readability-inconsistent-declaration-parameter-name, - -clang-diagnostic-error, - -HeaderFilterRegex: '.*\.hpp' -FormatStyle: file -Checks: > - -*, - bugprone-*, - -bugprone-easily-swappable-parameters, - -bugprone-forward-declararion-namespace, - -bugprone-forward-declararion-namespace, - -bugprone-macro-parentheses, - -bugprone-narrowing-conversions, - -bugprone-branch-clone, - -bugprone-assignment-in-if-condition, - concurrency-*, - -concurrency-mt-unsafe, - cppcoreguidelines-*, - -cppcoreguidelines-owning-memory, - -cppcoreguidelines-avoid-magic-numbers, - -cppcoreguidelines-pro-bounds-constant-array-index, - -cppcoreguidelines-avoid-const-or-ref-data-members, - -cppcoreguidelines-non-private-member-variables-in-classes, - -cppcoreguidelines-avoid-goto, - -cppcoreguidelines-pro-bounds-array-to-pointer-decay, - -cppcoreguidelines-avoid-do-while, - -cppcoreguidelines-avoid-non-const-global-variables, - -cppcoreguidelines-special-member-functions, - -cppcoreguidelines-explicit-virtual-functions, - -cppcoreguidelines-avoid-c-arrays, - -cppcoreguidelines-pro-bounds-pointer-arithmetic, - -cppcoreguidelines-narrowing-conversions, - -cppcoreguidelines-pro-type-union-access, - -cppcoreguidelines-pro-type-member-init, - -cppcoreguidelines-macro-usage, - -cppcoreguidelines-macro-to-enum, - -cppcoreguidelines-init-variables, - -cppcoreguidelines-pro-type-cstyle-cast, - -cppcoreguidelines-pro-type-vararg, - -cppcoreguidelines-pro-type-reinterpret-cast, - google-global-names-in-headers, - -google-readability-casting, - google-runtime-operator, - misc-*, - -misc-unused-parameters, - -misc-no-recursion, - -misc-non-private-member-variables-in-classes, - -misc-include-cleaner, - -misc-use-anonymous-namespace, - -misc-const-correctness, - modernize-*, - -modernize-return-braced-init-list, - -modernize-use-trailing-return-type, - -modernize-use-using, - -modernize-use-override, - -modernize-avoid-c-arrays, - -modernize-macro-to-enum, - -modernize-loop-convert, - -modernize-use-nodiscard, - -modernize-pass-by-value, - -modernize-use-auto, - performance-*, - -performance-avoid-endl, - -performance-unnecessary-value-param, - portability-std-allocator-const, - readability-*, - -readability-function-cognitive-complexity, - -readability-function-size, - -readability-identifier-length, - -readability-magic-numbers, - -readability-uppercase-literal-suffix, - -readability-braces-around-statements, - -readability-redundant-access-specifiers, - -readability-else-after-return, - -readability-container-data-pointer, - -readability-implicit-bool-conversion, - -readability-avoid-nested-conditional-operator, - -readability-redundant-member-init, - -readability-redundant-string-init, - -readability-avoid-const-params-in-decls, - -readability-named-parameter, - -readability-convert-member-functions-to-static, - -readability-qualified-auto, - -readability-make-member-function-const, - -readability-isolate-declaration, - -readability-inconsistent-declaration-parameter-name, - -clang-diagnostic-error, - -CheckOptions: - performance-for-range-copy.WarnOnAllAutoCopies: true - performance-inefficient-string-concatenation.StrictMode: true - readability-braces-around-statements.ShortStatementLines: 0 - readability-identifier-naming.ClassCase: CamelCase - readability-identifier-naming.ClassIgnoredRegexp: I.* - readability-identifier-naming.ClassPrefix: C # We can't use regex here?!?!?!? - readability-identifier-naming.EnumCase: CamelCase - readability-identifier-naming.EnumPrefix: e - readability-identifier-naming.EnumConstantCase: UPPER_CASE - readability-identifier-naming.FunctionCase: camelBack - readability-identifier-naming.NamespaceCase: CamelCase - readability-identifier-naming.NamespacePrefix: N - readability-identifier-naming.StructPrefix: S - readability-identifier-naming.StructCase: CamelCase diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml deleted file mode 100644 index fd5797d5..00000000 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Do not open issues, go to discussions please! -description: Do not open an issue -body: - - type: checkboxes - attributes: - label: Please close this issue. - description: Users cannot open issues. I want my issue to be closed. - options: - - label: Yes, I want this issue to be closed. - required: true - - - type: textarea - id: body - attributes: - label: Issue body diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..06fc6b5d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,12 @@ +--- +name: Bug report +about: Found a bug? Report it here! +title: '' +labels: bug +assignees: '' + +--- + +Please consult the issue guidelines at +https://github.com/vaxerski/Hyprland/blob/main/docs/ISSUE_GUIDELINES.md +BEFORE submitting. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..a0a41238 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,12 @@ +--- +name: Feature request +about: Suggest a feature/change/idea +title: '' +labels: enhancement +assignees: '' + +--- + +Please consult the issue guidelines at +https://github.com/vaxerski/Hyprland/blob/main/docs/ISSUE_GUIDELINES.md +BEFORE submitting. diff --git a/.github/actions/setup_base/action.yml b/.github/actions/setup_base/action.yml deleted file mode 100644 index 9fcaabfb..00000000 --- a/.github/actions/setup_base/action.yml +++ /dev/null @@ -1,123 +0,0 @@ -name: "Setup base" - -inputs: - INSTALL_XORG_PKGS: - description: 'Install xorg dependencies' - required: false - default: false - -runs: - using: "composite" - steps: - - name: Get required pacman pkgs - shell: bash - run: | - sed -i 's/SigLevel = Required DatabaseOptional/SigLevel = Optional TrustAll/' /etc/pacman.conf - pacman --noconfirm --noprogressbar -Syyu - pacman --noconfirm --noprogressbar -Sy \ - base-devel \ - cairo \ - clang \ - cmake \ - git \ - glaze \ - glm \ - glslang \ - go \ - gtest \ - hyprlang \ - hyprcursor \ - jq \ - libc++ \ - libdisplay-info \ - libdrm \ - libepoxy \ - libfontenc \ - libglvnd \ - libinput \ - libjxl \ - libliftoff \ - libspng \ - libwebp \ - libxcursor \ - libxcvt \ - libxfont2 \ - libxkbcommon \ - libxkbfile \ - lld \ - meson \ - muparser \ - ninja \ - pango \ - pixman \ - pkgconf \ - pugixml \ - scdoc \ - seatd \ - systemd \ - tomlplusplus \ - wayland \ - wayland-protocols \ - xcb-util-errors \ - xcb-util-renderutil \ - xcb-util-wm \ - xcb-util \ - xcb-util-image \ - libzip \ - librsvg \ - re2 - - - name: Get hyprwayland-scanner-git - shell: bash - run: | - git clone https://github.com/hyprwm/hyprwayland-scanner --recursive - cd hyprwayland-scanner - cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build - cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` - cmake --install build - - - name: Get hyprwire-git - shell: bash - run: | - git clone https://github.com/hyprwm/hyprwire --recursive - cd hyprwire - cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build - cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` - cmake --install build - - - name: Get hyprutils-git - shell: bash - run: | - git clone https://github.com/hyprwm/hyprutils && cd hyprutils && cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -B build && cmake --build build --target hyprutils && cmake --install build - - - name: Get hyprgraphics-git - shell: bash - run: | - git clone https://github.com/hyprwm/hyprgraphics && cd hyprgraphics && cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -B build && cmake --build build --target hyprgraphics && cmake --install build - - - name: Get aquamarine-git - shell: bash - run: | - git clone https://github.com/hyprwm/aquamarine && cd aquamarine && cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -B build && cmake --build build --target aquamarine && cmake --install build - - - name: Get Xorg pacman pkgs - shell: bash - if: inputs.INSTALL_XORG_PKGS == 'true' - run: | - pacman --noconfirm --noprogressbar -Sy \ - xorg-fonts-encodings \ - xorg-server-common \ - xorg-setxkbmap \ - xorg-xkbcomp \ - xorg-xwayland - - - name: Checkout Hyprland - uses: actions/checkout@v4 - with: - submodules: recursive - - # Fix an issue with actions/checkout where the checkout repo is not mark as safe - - name: Mark directory as safe for git - shell: bash - run: | - git config --global --add safe.directory /__w/Hyprland/Hyprland diff --git a/.github/labeler.yml b/.github/labeler.yml deleted file mode 100644 index 6b89255a..00000000 --- a/.github/labeler.yml +++ /dev/null @@ -1,87 +0,0 @@ -assets: - - changed-files: - - any-glob-to-any-file: "assets/**" - -docs: - - changed-files: - - any-glob-to-any-file: "docs/**" - -hyprctl: - - changed-files: - - any-glob-to-any-file: "hyprctl/**" - -hyprpm: - - changed-files: - - any-glob-to-any-file: "hyprpm/**" - -nix: - - changed-files: - - any-glob-to-any-file: "nix/**" - -protocols: - - changed-files: - - any-glob-to-any-file: ["protocols/**", "src/protocols/**"] - -start: - - changed-files: - - any-glob-to-any-file: "start/**" - -core: - - changed-files: - - any-glob-to-any-file: "src/**" - -config: - - changed-files: - - any-glob-to-any-file: "src/config/**" - -debug: - - changed-files: - - any-glob-to-any-file: "src/debug/**" - -desktop: - - changed-files: - - any-glob-to-any-file: "src/desktop/**" - -devices: - - changed-files: - - any-glob-to-any-file: "src/devices/**" - -events: - - changed-files: - - any-glob-to-any-file: "src/events/**" - -helpers: - - changed-files: - - any-glob-to-any-file: "src/helpers/**" - -hyprerror: - - changed-files: - - any-glob-to-any-file: "src/hyprerror/**" - -init: - - changed-files: - - any-glob-to-any-file: "src/init/**" - -layout: - - changed-files: - - any-glob-to-any-file: "src/layout/**" - -managers: - - changed-files: - - any-glob-to-any-file: "src/managers/**" - -pch: - - changed-files: - - any-glob-to-any-file: "src/pch/**" - -plugins: - - changed-files: - - any-glob-to-any-file: "src/plugins/**" - -render: - - changed-files: - - any-glob-to-any-file: "src/render/**" - -xwayland: - - changed-files: - - any-glob-to-any-file: "src/xwayland/**" diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 75b4b7c5..073333bc 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,11 +1,3 @@ - - - #### Describe your PR, what does it fix/add? diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2ec558ed..2c9b60a6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,81 +3,106 @@ name: Build Hyprland on: [push, pull_request, workflow_dispatch] jobs: gcc: - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork name: "Build Hyprland (Arch)" runs-on: ubuntu-latest container: image: archlinux steps: - - name: Checkout repository actions - uses: actions/checkout@v4 + - name: Get required pacman pkgs + run: | + sed -i 's/SigLevel = Required DatabaseOptional/SigLevel = Optional TrustAll/' /etc/pacman.conf + pacman --noconfirm --noprogressbar -Syyu + pacman --noconfirm --noprogressbar -Sy glslang libepoxy libfontenc libxcvt libxfont2 libxkbfile vulkan-headers vulkan-validation-layers xcb-util-errors xcb-util-renderutil xcb-util-wm xorg-fonts-encodings xorg-server-common xorg-setxkbmap xorg-xkbcomp xorg-xwayland git cmake go clang lld libc++ pkgconf meson ninja wayland wayland-protocols libinput libxkbcommon pixman glm libdrm libglvnd cairo pango systemd scdoc base-devel seatd python libliftoff + - name: Set up user + run: | + useradd -m githubuser + echo -e "root ALL=(ALL:ALL) ALL\ngithubuser ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers + - name: Install libdisplay-info from the AUR + run: | + su githubuser -c "cd ~ && git clone https://aur.archlinux.org/libdisplay-info.git && cd ./libdisplay-info && makepkg -si --skippgpcheck --noconfirm --noprogressbar" + - name: Fix permissions for git + run: | + git config --global --add safe.directory /__w/Hyprland/Hyprland + - name: Checkout Hyprland + uses: actions/checkout@v3 with: - sparse-checkout: .github/actions - - - name: Setup base - uses: ./.github/actions/setup_base - with: - INSTALL_XORG_PKGS: true - + submodules: recursive - name: Build Hyprland run: | - CFLAGS=-Werror CXXFLAGS=-Werror make nopch - + git submodule sync --recursive && git submodule update --init --force --recursive + make all - name: Compress and package artifacts run: | mkdir x86_64-pc-linux-gnu mkdir hyprland + mkdir hyprland/example + mkdir hyprland/assets cp ./LICENSE hyprland/ cp build/Hyprland hyprland/ - cp build/hyprctl/hyprctl hyprland/ - cp build/hyprpm/hyprpm hyprland/ + cp hyprctl/hyprctl hyprland/ + cp subprojects/wlroots/build/libwlroots.so.12032 hyprland/ + cp build/Hyprland hyprland/ cp -r example/ hyprland/ cp -r assets/ hyprland/ - tar -cvJf Hyprland.tar.xz hyprland - + tar -cvf Hyprland.tar.xz hyprland - name: Release - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: Build archive path: Hyprland.tar.xz - clang-format: - permissions: read-all - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork - name: "Code Style" + meson: + name: "Build Hyprland with Meson (Arch)" runs-on: ubuntu-latest container: image: archlinux steps: - - name: Checkout repository - uses: actions/checkout@v4 - - # - name: clang-format check - # uses: jidicula/clang-format-action@v4.16.0 - # with: - # exclude-regex: ^subprojects$ - - - name: Install clang-format + - name: Download dependencies run: | + sed -i 's/SigLevel = Required DatabaseOptional/SigLevel = Optional TrustAll/' /etc/pacman.conf pacman --noconfirm --noprogressbar -Syyu - pacman --noconfirm --noprogressbar -Sy clang - - - name: clang-format check - run: .github/workflows/clang-format-check.sh "." "llvm" "^subprojects$" "" - - - name: Save PR head commit SHA - if: failure() && github.event_name == 'pull_request' - shell: bash + pacman --noconfirm --noprogressbar -Sy glslang libepoxy libfontenc libxcvt libxfont2 libxkbfile vulkan-headers vulkan-validation-layers git go clang lld libc++ pkgconf meson ninja wayland wayland-protocols libinput libxkbcommon pixman glm libdrm libglvnd cairo pango systemd scdoc base-devel seatd cmake jq python libliftoff + - name: Set up user run: | - SHA="${{ github.event.pull_request.head.sha }}" - echo "SHA=$SHA" >> $GITHUB_ENV - - name: Save latest commit SHA if not PR - if: failure() && github.event_name != 'pull_request' - shell: bash - run: echo "SHA=${{ github.sha }}" >> $GITHUB_ENV - - - name: Report failure in job summary - if: failure() + useradd -m githubuser + echo -e "root ALL=(ALL:ALL) ALL\ngithubuser ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers + - name: Install libdisplay-info from the AUR run: | - DEEPLINK="${{ github.server_url }}/${{ github.repository }}/commit/${{ env.SHA }}" - echo -e "Format check failed on commit [${GITHUB_SHA:0:8}]($DEEPLINK) with files:\n$(<$GITHUB_WORKSPACE/failing-files.txt)" >> $GITHUB_STEP_SUMMARY + su githubuser -c "cd ~ && git clone https://aur.archlinux.org/libdisplay-info.git && cd ./libdisplay-info && makepkg -si --skippgpcheck --noconfirm --noprogressbar" + - name: Checkout Hyprland + uses: actions/checkout@v3 + with: + submodules: true + - name: Configure + run: | + meson obj-x86_64-pc-linux-gnu \ + -Ddefault_library=static + - name: Compile + run: ninja -C obj-x86_64-pc-linux-gnu + + noxwayland: + name: "Build Hyprland in pure Wayland (Arch)" + runs-on: ubuntu-latest + container: + image: archlinux + steps: + - name: Download dependencies + run: | + sed -i 's/SigLevel = Required DatabaseOptional/SigLevel = Optional TrustAll/' /etc/pacman.conf + pacman --noconfirm --noprogressbar -Syyu + pacman --noconfirm --noprogressbar -Sy glslang libepoxy libfontenc libxcvt libxfont2 libxkbfile vulkan-headers vulkan-validation-layers git cmake go clang lld libc++ pkgconf meson ninja wayland wayland-protocols libinput libxkbcommon pixman glm libdrm libglvnd cairo pango systemd scdoc base-devel seatd libliftoff + - name: Set up user + run: | + useradd -m githubuser + echo -e "root ALL=(ALL:ALL) ALL\ngithubuser ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers + - name: Install libdisplay-info from the AUR + run: | + su githubuser -c "cd ~ && git clone https://aur.archlinux.org/libdisplay-info.git && cd ./libdisplay-info && makepkg -si --skippgpcheck --noconfirm --noprogressbar" + - name: Checkout Hyprland + uses: actions/checkout@v3 + with: + submodules: true + - name: Configure + run: mkdir -p build && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DNO_XWAYLAND:STRING=true -H./ -B./build -G Ninja + - name: Compile + run: make config && make release diff --git a/.github/workflows/clang-format-check.sh b/.github/workflows/clang-format-check.sh deleted file mode 100755 index 41237aa7..00000000 --- a/.github/workflows/clang-format-check.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/env bash -# -# Adapted from https://github.com/jidicula/clang-format-action - -############################################################################### -# check.sh # -############################################################################### -# USAGE: ./entrypoint.sh [] [] -# -# Checks all C/C++/Protobuf/CUDA files (.h, .H, .hpp, .hh, .h++, .hxx and .c, -# .C, .cpp, .cc, .c++, .cxx, .proto, .cu) in the provided GitHub repository path -# (arg1) for conforming to clang-format. If no path is provided or provided path -# is not a directory, all C/C++/Protobuf/CUDA files are checked. If any files -# are incorrectly formatted, the script lists them and exits with 1. -# -# Define your own formatting rules in a .clang-format file at your repository -# root. Otherwise, the provided style guide (arg2) is used as a fallback. - -# format_diff function -# Accepts a filepath argument. The filepath passed to this function must point -# to a C/C++/Protobuf/CUDA file. -format_diff() { - local filepath="$1" - - # Invoke clang-format with dry run and formatting error output - local_format="$(clang-format \ - --dry-run \ - --Werror \ - --style=file \ - --fallback-style="$FALLBACK_STYLE" \ - "${filepath}")" - - local format_status="$?" - if [[ ${format_status} -ne 0 ]]; then - # Append Markdown-bulleted monospaced filepath of failing file to - # summary file. - echo "* \`$filepath\`" >>failing-files.txt - - echo "Failed on file: $filepath" >&2 - echo "$local_format" >&2 - exit_code=1 # flip the global exit code - return "${format_status}" - fi - return 0 -} - -CHECK_PATH="$1" -FALLBACK_STYLE="$2" -EXCLUDE_REGEX="$3" -INCLUDE_REGEX="$4" - -# Set the regex to an empty string regex if nothing was provided -if [[ -z $EXCLUDE_REGEX ]]; then - EXCLUDE_REGEX="^$" -fi - -# Set the filetype regex if nothing was provided. -# Find all C/C++/Protobuf/CUDA files: -# h, H, hpp, hh, h++, hxx -# c, C, cpp, cc, c++, cxx -# ino, pde -# proto -# cu -if [[ -z $INCLUDE_REGEX ]]; then - INCLUDE_REGEX='^.*\.((((c|C)(c|pp|xx|\+\+)?$)|((h|H)h?(pp|xx|\+\+)?$))|(ino|pde|proto|cu))$' -fi - -cd "$GITHUB_WORKSPACE" || exit 2 - -if [[ ! -d $CHECK_PATH ]]; then - echo "Not a directory in the workspace, fallback to all files." >&2 - CHECK_PATH="." -fi - -# initialize exit code -exit_code=0 - -# All files improperly formatted will be printed to the output. -src_files=$(find "$CHECK_PATH" -name .git -prune -o -regextype posix-egrep -regex "$INCLUDE_REGEX" -print) - -# check formatting in each source file -IFS=$'\n' # Loop below should separate on new lines, not spaces. -for file in $src_files; do - # Only check formatting if the path doesn't match the regex - if ! [[ ${file} =~ $EXCLUDE_REGEX ]]; then - format_diff "${file}" - fi -done - -# global exit code is flipped to nonzero if any invocation of `format_diff` has -# a formatting difference. -exit "$exit_code" diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml deleted file mode 100644 index 505829e3..00000000 --- a/.github/workflows/clang-format.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: clang-format -on: pull_request_target -jobs: - clang-format: - permissions: write-all - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork - name: "Code Style" - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: clang-format check - uses: jidicula/clang-format-action@v4.16.0 - with: - exclude-regex: ^subprojects$ - - - name: Create comment - if: ${{ failure() && github.event_name == 'pull_request' }} - run: | - echo 'Please fix the formatting issues by running [`clang-format`](https://wiki.hyprland.org/Contributing-and-Debugging/PR-Guidelines/#code-style).' > clang-format.patch - - - name: Post comment - if: ${{ failure() && github.event_name == 'pull_request' }} - uses: mshick/add-pr-comment@v2 - with: - message-path: | - clang-format.patch diff --git a/.github/workflows/close-issues.yml b/.github/workflows/close-issues.yml deleted file mode 100644 index 55f4e126..00000000 --- a/.github/workflows/close-issues.yml +++ /dev/null @@ -1,101 +0,0 @@ -name: Close Unauthorized Issues - -on: - workflow_dispatch: - issues: - types: [opened] - -jobs: - close-unauthorized-issues: - runs-on: ubuntu-latest - permissions: - issues: write - steps: - # XXX: This *could* be done in Bash by abusing GitHub's own tool to interact with its API - # but that's too much of a hack, and we'll be adding a layer of abstraction. github-script - # is a workflow that eases interaction with GitHub API in the workflow run context. - - name: "Close 'unauthorized' issues" - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const ALLOWED_USERS = ['vaxerski', 'fufexan', 'NotAShelf']; - const CLOSING_COMMENT = 'Users are no longer allowed to open issues themselves, please open a discussion instead.\n\nPlease see the [wiki](https://wiki.hyprland.org/Contributing-and-Debugging/Issue-Guidelines/) on why this is the case.\n\nWe are volunteers, and we need your cooperation to make the best software we can. Thank you for understanding! ❤️\n\n[Open a discussion here](https://github.com/hyprwm/Hyprland/discussions)'; - - async function closeUnauthorizedIssue(issueNumber, userName) { - if (ALLOWED_USERS.includes(userName)) { - console.log(`Issue #${issueNumber} - Created by authorized user ${userName}`); - return; - } - - console.log(`Issue #${issueNumber} - Unauthorized, closing`); - - await github.rest.issues.update({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issueNumber, - state: 'closed', - state_reason: 'not_planned' - }); - - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issueNumber, - body: CLOSING_COMMENT - }); - } - - if (context.eventName === 'issues' && context.payload.action === 'opened') { - // Direct access to the issue that triggered the workflow - const issue = context.payload.issue; - - // Skip if this is a PR - if (issue.pull_request) { - console.log(`Issue #${issue.number} - Skipping, this is a pull request`); - return; - } - - // Process the single issue that triggered the workflow - await closeUnauthorizedIssue(issue.number, issue.user.login); - } else { - // For manual runs, we need to handle pagination - async function* fetchAllOpenIssues() { - let page = 1; - let hasNextPage = true; - - while (hasNextPage) { - const response = await github.rest.issues.listForRepo({ - owner: context.repo.owner, - repo: context.repo.repo, - state: 'open', - per_page: 100, - page: page - }); - - if (response.data.length === 0) { - hasNextPage = false; - } else { - for (const issue of response.data) { - yield issue; - } - page++; - } - } - } - - // Process issues one by one - for await (const issue of fetchAllOpenIssues()) { - try { - // Skip pull requests - if (issue.pull_request) { - console.log(`Issue #${issue.number} - Skipping, this is a pull request`); - continue; - } - - await closeUnauthorizedIssue(issue.number, issue.user.login); - } catch (error) { - console.error(`Error processing issue #${issue.number}: ${error.message}`); - } - } - } diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml deleted file mode 100644 index 52474c6a..00000000 --- a/.github/workflows/labeler.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: "Pull Request Labeler" -on: - - pull_request_target - -jobs: - labeler: - permissions: - contents: read - pull-requests: write - runs-on: ubuntu-latest - steps: - - uses: actions/labeler@v5 diff --git a/.github/workflows/man-update.yaml b/.github/workflows/man-update.yaml index 6c0a72f3..a42a6fe4 100644 --- a/.github/workflows/man-update.yaml +++ b/.github/workflows/man-update.yaml @@ -15,16 +15,14 @@ jobs: steps: - name: Install deps run: sudo apt install pandoc - - name: Clone repository - uses: actions/checkout@v4 - with: - token: ${{ secrets.PAT }} - + uses: actions/checkout@v3 + # Not needed + # with: + # submodules: recursive - name: Build man pages run: make man - - - uses: stefanzweifel/git-auto-commit-action@v5 + - uses: stefanzweifel/git-auto-commit-action@v4 name: Commit with: commit_message: "[gha] build man pages" diff --git a/.github/workflows/new-pr-comment.yml b/.github/workflows/new-pr-comment.yml deleted file mode 100644 index 36ea1909..00000000 --- a/.github/workflows/new-pr-comment.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: "New MR welcome comment" - -on: - pull_request_target: - types: - - opened - -jobs: - comment: - if: > - github.event.pull_request.user.login != 'vaxerski' && - github.event.pull_request.user.login != 'fufexan' && - github.event.pull_request.user.login != 'gulafaran' && - github.event.pull_request.user.login != 'ujint34' && - github.event.pull_request.user.login != 'paideiadilemma' && - github.event.pull_request.user.login != 'notashelf' - runs-on: ubuntu-latest - permissions: - pull-requests: write - - env: - PR_COMMENT: | - Hello and thank you for making a PR to Hyprland! - - Please check the [PR Guidelines](https://wiki.hypr.land/Contributing-and-Debugging/PR-Guidelines/) and make sure your PR follows them. - It will make the entire review process faster. :) - - If your code can be tested, please always add tests. See more [here](https://wiki.hypr.land/Contributing-and-Debugging/Tests/). - - _beep boop, I'm just a bot. A real human will review your PR soon._ - - steps: - - name: Add comment to PR - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const pr = context.payload.pull_request; - - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: pr.number, - body: process.env.PR_COMMENT, - }); diff --git a/.github/workflows/nix-build.yaml b/.github/workflows/nix-build.yaml new file mode 100644 index 00000000..5e911a38 --- /dev/null +++ b/.github/workflows/nix-build.yaml @@ -0,0 +1,26 @@ +name: Build Hyprland (Nix) + +on: [push, pull_request, workflow_dispatch] +jobs: + nix: + name: "Build Hyprland (Nix)" + runs-on: ubuntu-latest + steps: + - name: Clone repository + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Install nix + uses: cachix/install-nix-action@v20 + with: + install_url: https://nixos.org/nix/install + extra_nix_config: | + auto-optimise-store = true + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + experimental-features = nix-command flakes + - uses: cachix/cachix-action@v12 + with: + name: hyprland + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - name: Build packages + run: nix flake check --print-build-logs --accept-flake-config diff --git a/.github/workflows/nix-ci.yml b/.github/workflows/nix-ci.yml deleted file mode 100644 index 5b22e992..00000000 --- a/.github/workflows/nix-ci.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Nix - -on: [push, pull_request, workflow_dispatch] - -jobs: - update-inputs: - if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') - uses: ./.github/workflows/nix-update-inputs.yml - secrets: inherit - - hyprland: - if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork) - uses: ./.github/workflows/nix.yml - secrets: inherit - with: - command: nix build 'github:${{ github.repository }}?ref=${{ github.ref }}' -L --extra-substituters "https://hyprland.cachix.org" - - xdph: - if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork) - needs: hyprland - uses: ./.github/workflows/nix.yml - secrets: inherit - with: - command: nix build 'github:${{ github.repository }}?ref=${{ github.ref }}#xdg-desktop-portal-hyprland' -L --extra-substituters "https://hyprland.cachix.org" - - test: - if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork) - uses: ./.github/workflows/nix-test.yml - secrets: inherit diff --git a/.github/workflows/nix-test.yml b/.github/workflows/nix-test.yml deleted file mode 100644 index 68357093..00000000 --- a/.github/workflows/nix-test.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Nix (Test) - -on: - workflow_call: - secrets: - CACHIX_AUTH_TOKEN: - required: false - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Install Nix - uses: nixbuild/nix-quick-install-action@v31 - with: - nix_conf: | - keep-env-derivations = true - keep-outputs = true - - - name: Restore and save Nix store - uses: nix-community/cache-nix-action@v6 - with: - # restore and save a cache using this key (per job) - primary-key: nix-${{ runner.os }}-${{ github.job }} - # if there's no cache hit, restore a cache by this prefix - restore-prefixes-first-match: nix-${{ runner.os }} - # collect garbage until the Nix store size (in bytes) is at most this number - # before trying to save a new cache - gc-max-store-size-linux: 5G - - - uses: cachix/cachix-action@v15 - with: - name: hyprland - authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - - - name: Run test VM - run: nix build 'github:${{ github.repository }}?ref=${{ github.ref }}#checks.x86_64-linux.tests' -L --extra-substituters "https://hyprland.cachix.org" - - - name: Check exit status - run: grep 0 result/exit_status - - - name: Upload artifacts - if: always() - uses: actions/upload-artifact@v4 - with: - name: logs - path: result diff --git a/.github/workflows/nix-update-inputs.yml b/.github/workflows/nix-update-inputs.yml deleted file mode 100644 index a3084b27..00000000 --- a/.github/workflows/nix-update-inputs.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Nix (Update Inputs) - -on: - workflow_call: - secrets: - PAT: - required: true - -jobs: - update: - if: github.repository == 'hyprwm/Hyprland' - name: inputs - runs-on: ubuntu-latest - steps: - - name: Clone repository - uses: actions/checkout@v4 - with: - token: ${{ secrets.PAT }} - - - name: Install Nix - uses: nixbuild/nix-quick-install-action@v31 - with: - nix_conf: | - keep-env-derivations = true - keep-outputs = true - - - name: Restore and save Nix store - uses: nix-community/cache-nix-action@v6 - with: - # restore and save a cache using this key (per job) - primary-key: nix-${{ runner.os }}-${{ github.job }} - # if there's no cache hit, restore a cache by this prefix - restore-prefixes-first-match: nix-${{ runner.os }} - # collect garbage until the Nix store size (in bytes) is at most this number - # before trying to save a new cache - gc-max-store-size-linux: 5G - - - name: Update inputs - run: nix/update-inputs.sh - - - name: Commit - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: "[gha] Nix: update inputs" diff --git a/.github/workflows/nix-update.yaml b/.github/workflows/nix-update.yaml new file mode 100644 index 00000000..7bd84350 --- /dev/null +++ b/.github/workflows/nix-update.yaml @@ -0,0 +1,29 @@ +name: "Nix: update lockfile" + +on: [push, workflow_dispatch] + +jobs: + update: + runs-on: ubuntu-latest + steps: + - name: Clone repository + uses: actions/checkout@v3 + - name: Install nix + uses: cachix/install-nix-action@v20 + with: + install_url: https://nixos.org/nix/install + extra_nix_config: | + auto-optimise-store = true + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + experimental-features = nix-command flakes + - name: Update lockfile + run: nix/update-inputs.sh + - uses: cachix/cachix-action@v12 + with: + name: hyprland + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - name: Build Waybar-Hyprland + run: nix build .#waybar-hyprland --print-build-logs + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "[gha] bump flake inputs" diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml deleted file mode 100644 index b46b3795..00000000 --- a/.github/workflows/nix.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Build - -on: - workflow_call: - inputs: - command: - required: true - type: string - description: Command to run - secrets: - CACHIX_AUTH_TOKEN: - required: false - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Install Nix - uses: nixbuild/nix-quick-install-action@v31 - with: - nix_conf: | - keep-env-derivations = true - keep-outputs = true - - - name: Restore and save Nix store - uses: nix-community/cache-nix-action@v6 - with: - # restore and save a cache using this key (per job) - primary-key: nix-${{ runner.os }}-${{ github.job }} - # if there's no cache hit, restore a cache by this prefix - restore-prefixes-first-match: nix-${{ runner.os }} - # collect garbage until the Nix store size (in bytes) is at most this number - # before trying to save a new cache - gc-max-store-size-linux: 5G - - - uses: cachix/cachix-action@v15 - with: - name: hyprland - authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - - - run: ${{ inputs.command }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 09aae111..a092d07c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -9,40 +9,16 @@ jobs: source-tarball: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v5 + - name: Checkout Hyprland + id: checkout + uses: actions/checkout@v3 with: - fetch-depth: 0 submodules: recursive - - name: Populate git info in version.h.in - run: | - git fetch --tags --unshallow || true - - COMMIT_HASH=$(git rev-parse HEAD) - BRANCH="${GITHUB_REF_NAME:-$(git rev-parse --abbrev-ref HEAD)}" - COMMIT_MSG=$(git show -s --format=%s | sed 's/[&/]/\\&/g') - COMMIT_DATE=$(git show -s --format=%cd --date=local) - GIT_DIRTY=$(git diff-index --quiet HEAD -- && echo "clean" || echo "dirty") - GIT_TAG=$(git describe --tags --always || echo "unknown") - GIT_COMMITS=$(git rev-list --count HEAD) - - echo "Branch: $BRANCH" - echo "Tag: $GIT_TAG" - - sed -i \ - -e "s|@GIT_COMMIT_HASH@|$COMMIT_HASH|" \ - -e "s|@GIT_BRANCH@|$BRANCH|" \ - -e "s|@GIT_COMMIT_MESSAGE@|$COMMIT_MSG|" \ - -e "s|@GIT_COMMIT_DATE@|$COMMIT_DATE|" \ - -e "s|@GIT_DIRTY@|$GIT_DIRTY|" \ - -e "s|@GIT_TAG@|$GIT_TAG|" \ - -e "s|@GIT_COMMITS@|$GIT_COMMITS|" \ - src/version.h.in - - name: Create tarball with submodules id: tar run: | + sed -i "1s/^/#define GIT_COMMIT_HASH $(git rev-parse HEAD)\n#define GIT_TAG \"$(git describe --tags)\"\n/" ./src/defines.hpp mkdir hyprland-source; mv ./* ./hyprland-source || tar -czv --owner=0 --group=0 --no-same-owner --no-same-permissions -f source.tar.gz * - id: whatrelease diff --git a/.github/workflows/security-checks.yml b/.github/workflows/security-checks.yml index 284500e6..6b7d71e5 100644 --- a/.github/workflows/security-checks.yml +++ b/.github/workflows/security-checks.yml @@ -4,7 +4,6 @@ on: [push, pull_request] jobs: flawfinder: - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork name: Flawfinder Checks runs-on: ubuntu-latest permissions: @@ -13,7 +12,7 @@ jobs: security-events: write steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Scan with Flawfinder uses: david-a-wheeler/flawfinder@8e4a779ad59dbfaee5da586aa9210853b701959c @@ -25,3 +24,53 @@ jobs: uses: github/codeql-action/upload-sarif@v2 with: sarif_file: ${{github.workspace}}/flawfinder_results.sarif + + codeql: + name: CodeQL + runs-on: ubuntu-latest + container: + image: archlinux + + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'cpp' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + + - name: Init Hyprland build + run: | + sed -i 's/SigLevel = Required DatabaseOptional/SigLevel = Optional TrustAll/' /etc/pacman.conf + pacman --noconfirm --noprogressbar -Syyu + pacman --noconfirm --noprogressbar -Sy glslang libepoxy libfontenc libxcvt libxfont2 libxkbfile vulkan-headers vulkan-validation-layers xcb-util-errors xcb-util-renderutil xcb-util-wm xorg-fonts-encodings xorg-server-common xorg-setxkbmap xorg-xkbcomp xorg-xwayland git cmake go clang lld libc++ pkgconf meson ninja wayland wayland-protocols libinput libxkbcommon pixman glm libdrm libglvnd cairo pango systemd scdoc base-devel seatd python libliftoff + useradd -m githubuser + echo -e "root ALL=(ALL:ALL) ALL\ngithubuser ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers + su githubuser -c "cd ~ && git clone https://aur.archlinux.org/libdisplay-info.git && cd ./libdisplay-info && makepkg -si --skippgpcheck --noconfirm --noprogressbar" + git config --global --add safe.directory /__w/Hyprland/Hyprland + + - name: Checkout Hyprland + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Build Hyprland + run: | + git submodule sync --recursive && git submodule update --init --force --recursive + make all + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/translation-ai-check.yml b/.github/workflows/translation-ai-check.yml deleted file mode 100644 index d6a62a60..00000000 --- a/.github/workflows/translation-ai-check.yml +++ /dev/null @@ -1,139 +0,0 @@ -name: AI Translation Check - -on: - # pull_request_target: - # types: - # - opened - issue_comment: - types: - - created - -permissions: - contents: read - pull-requests: write - issues: write - -jobs: - review: - name: Review Translation - if: ${{ github.event_name == 'pull_request_target' || (github.event_name == 'issue_comment' && github.event.action == 'created' && github.event.issue.pull_request != null && github.event.comment.user.login == 'vaxerski' && github.event.comment.body == 'ai, please recheck' ) }} - runs-on: ubuntu-latest - env: - OPENAI_MODEL: gpt-5-mini - SYSTEM_PROMPT: | - You are a programmer and a translator. Your job is to review the attached patch for adding translation to a piece of software and make sure the submitted translation is not malicious, and that it makes sense. If the translation is not malicious, and doesn't contain obvious grammatical mistakes, say "Translation check OK". Otherwise, say "Translation check not ok" and list bad entries. - Examples of bad translations include obvious trolling (slurs, etc) or nonsense sentences. Meaningful improvements may be suggested, but if there are only minor improvements, just reply with "Translation check OK". Do not provide anything but the result and (if applicable) the bad entries or improvements. - - AI_PROMPT: Translation patch below. - - steps: - - name: Checkout source code - uses: actions/checkout@v5 - - - uses: dorny/paths-filter@v3 - id: changes - with: - filters: | - i18n: - - 'src/i18n/**' - - - name: Stop if i18n not changed - if: steps.changes.outputs.i18n != 'true' - run: echo "No i18n changes in this PR; skipping." && exit 0 - - - name: Determine PR number - id: pr - run: | - if [ "${{ github.event_name }}" = "pull_request_target" ]; then - echo "number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT" - else - echo "number=${{ github.event.issue.number }}" >> "$GITHUB_OUTPUT" - fi - - - name: Download combined PR diff - id: get_diff - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ steps.pr.outputs.number }} - run: | - # Get the combined diff for the entire PR - curl -sSL \ - -H "Authorization: token $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github.v3.diff" \ - "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" \ - -o pr.diff - - # Compute character length - LEN=$(wc -c < pr.diff | tr -d ' ') - echo "len=$LEN" >> "$GITHUB_OUTPUT" - if [ "$LEN" -gt 25000 ]; then - echo "too_long=true" >> "$GITHUB_OUTPUT" - else - echo "too_long=false" >> "$GITHUB_OUTPUT" - fi - - echo "got diff:" - cat pr.diff - - - name: Comment when diff length exceeded - if: steps.get_diff.outputs.too_long == 'true' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ steps.pr.outputs.number }} - run: | - jq -n --arg body "Diff length exceeded, can't query API" '{body: ("AI translation check result:\n\n" + $body)}' > body.json - curl -sS -X POST \ - -H "Authorization: token $GITHUB_TOKEN" \ - -H "Content-Type: application/json" \ - "https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments" \ - --data @body.json - - - name: Query OpenAI and post review - if: steps.get_diff.outputs.too_long == 'false' - env: - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - OPENAI_MODEL: ${{ env.OPENAI_MODEL }} - SYSTEM_PROMPT: ${{ env.SYSTEM_PROMPT }} - AI_PROMPT: ${{ env.AI_PROMPT }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ steps.pr.outputs.number }} - run: | - # Prepare OpenAI chat request payload (embed diff safely) - jq -n \ - --arg model "$OPENAI_MODEL" \ - --arg sys "$SYSTEM_PROMPT" \ - --arg prompt "$AI_PROMPT" \ - --rawfile diff pr.diff \ - '{model:$model, - messages:[ - {role:"system", content:$sys}, - {role:"user", content: ($prompt + "\n\n```diff\n" + $diff + "\n```")} - ] - }' > payload.json - - # Call OpenAI - curl -sS https://api.openai.com/v1/chat/completions \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -d @payload.json > response.json - - # Extract response text - COMMENT=$(jq -r '.choices[0].message.content // empty' response.json) - if [ -z "$COMMENT" ]; then - COMMENT="AI did not return a response." - fi - - # If failed, add a note - ADDITIONAL_NOTE="" - if [[ "$COMMENT" == *"not ok"* ]]; then - ADDITIONAL_NOTE=$(echo -ne "\n\nPlease note this check is a guideline, not a hard requirement. It is here to help you translate. If you disagree with some points, just state that. Any typos should be fixed.") - fi - - # Post the review as a PR comment - jq -n --arg body "$COMMENT" --arg note "$ADDITIONAL_NOTE" '{body: ("AI translation check result:\n\n" + $body + $note)}' > body.json - echo "CURLing https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments" - curl -sS -X POST \ - -H "Authorization: token $GITHUB_TOKEN" \ - -H "Content-Type: application/json" \ - "https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments" \ - --data @body.json diff --git a/.gitignore b/.gitignore index 4e5c2323..96fd6c87 100644 --- a/.gitignore +++ b/.gitignore @@ -7,44 +7,25 @@ cmake_install.cmake install_manifest.txt compile_commands.json CTestTestfile.cmake -CPackConfig.cmake -CPackSourceConfig.cmake -hyprland.pc _deps build/ result* -/.pre-commit-config.yaml /.vscode/ /.idea/ .envrc .cache -.direnv -/.cmake/ -/.worktree/ *.o -protocols/*.c* -protocols/*.h* +*-protocol.c +*-protocol.h .ccls-cache *.so -src/render/shaders/*.inc -src/render/shaders/Shaders.hpp hyprctl/hyprctl -hyprctl/hw-protocols/*.c* -hyprctl/hw-protocols/*.h* gmon.out *.out *.tar.gz PKGBUILD - -src/version.h -hyprpm/Makefile -hyprctl/Makefile -example/hyprland.desktop - -**/.#*.* -**/#*.*# diff --git a/.gitmodules b/.gitmodules index 638f8ba9..26dbceeb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,9 @@ +[submodule "wlroots"] + path = subprojects/wlroots + url = https://gitlab.freedesktop.org/wlroots/wlroots.git [submodule "subprojects/hyprland-protocols"] path = subprojects/hyprland-protocols url = https://github.com/hyprwm/hyprland-protocols [submodule "subprojects/udis86"] path = subprojects/udis86 url = https://github.com/canihavesomecoffee/udis86 -[submodule "subprojects/tracy"] - path = subprojects/tracy - url = https://github.com/wolfpld/tracy diff --git a/CMakeLists.txt b/CMakeLists.txt index 87574b82..cafdd94f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,680 +1,198 @@ -cmake_minimum_required(VERSION 3.30) +cmake_minimum_required(VERSION 3.19) +include(CheckIncludeFile) # Get version -file(READ "${CMAKE_SOURCE_DIR}/VERSION" VER_RAW) -string(STRIP ${VER_RAW} VER) +file(READ ${CMAKE_CURRENT_SOURCE_DIR}/props.json PROPS) +string(JSON VER GET ${PROPS} version) -project( - Hyprland - DESCRIPTION "A Modern C++ Wayland Compositor" - VERSION ${VER}) - -include(CTest) -include(CheckIncludeFile) -include(GNUInstallDirs) +project(Hyprland + DESCRIPTION "A Modern C++ Wayland Compositor" + VERSION ${VER} +) set(HYPRLAND_VERSION ${VER}) set(PREFIX ${CMAKE_INSTALL_PREFIX}) -set(INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}) -set(BINDIR ${CMAKE_INSTALL_BINDIR}) +configure_file(hyprland.pc.in hyprland.pc @ONLY) set(CMAKE_MESSAGE_LOG_LEVEL "STATUS") message(STATUS "Gathering git info") -# Make shader files includable -execute_process(COMMAND ./scripts/generateShaderIncludes.sh - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - RESULT_VARIABLE HYPR_SHADER_GEN_RESULT) -if(NOT HYPR_SHADER_GEN_RESULT EQUAL 0) - message( - FATAL_ERROR - "Failed to generate shader includes (scripts/generateShaderIncludes.sh), exit code: ${HYPR_SHADER_GEN_RESULT}" - ) -endif() +# Get git info +# hash and branch +execute_process( + COMMAND git rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE) -find_package(PkgConfig REQUIRED) +execute_process( + COMMAND git rev-parse HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE) -# Try to find canihavesomecoffee's udis86 using pkgconfig vmd/udis86 does not -# provide a .pc file and won't be detected this way -pkg_check_modules(udis_dep IMPORTED_TARGET udis86>=1.7.2) +execute_process( + COMMAND sh -c "git show ${GIT_COMMIT_HASH} | head -n 5 | tail -n 1 | sed -e 's/#//g' -e 's/\"//g'" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT_MESSAGE + OUTPUT_STRIP_TRAILING_WHITESPACE) -# Find non-pkgconfig udis86, otherwise fallback to subproject -if(NOT udis_dep_FOUND) - find_library(udis_nopc udis86) - if(NOT("${udis_nopc}" MATCHES "udis_nopc-NOTFOUND")) - message(STATUS "Found udis86 at ${udis_nopc}") - else() - add_subdirectory("subprojects/udis86") - include_directories("subprojects/udis86") - message(STATUS "udis86 dependency not found, falling back to subproject") - endif() -endif() +execute_process( + COMMAND sh -c "git diff-index --quiet HEAD -- || echo \"dirty\"" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_DIRTY + OUTPUT_STRIP_TRAILING_WHITESPACE) -find_library(librt rt) -if("${librt}" MATCHES "librt-NOTFOUND") - unset(LIBRT) -else() - set(LIBRT rt) -endif() +execute_process( + COMMAND sh -c "git describe --tags" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_TAG + OUTPUT_STRIP_TRAILING_WHITESPACE) +# +# -if(CMAKE_BUILD_TYPE) - string(TOLOWER ${CMAKE_BUILD_TYPE} BUILDTYPE_LOWER) - if(BUILDTYPE_LOWER STREQUAL "release") - # Pass. - elseif(BUILDTYPE_LOWER STREQUAL "debug") - # Pass. - elseif(BUILDTYPE_LOWER STREQUAL "relwithdebinfo") - set(BUILDTYPE_LOWER "debugoptimized") - elseif(BUILDTYPE_LOWER STREQUAL "minsizerel") - set(BUILDTYPE_LOWER "minsize") - elseif(BUILDTYPE_LOWER STREQUAL "none") - set(BUILDTYPE_LOWER "plain") - else() - set(BUILDTYPE_LOWER "release") - endif() -else() - set(BUILDTYPE_LOWER "release") -endif() - -pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir) +find_program(WaylandScanner NAMES wayland-scanner) +message(STATUS "Found WaylandScanner at ${WaylandScanner}") +execute_process( + COMMAND pkg-config --variable=pkgdatadir wayland-protocols + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE WAYLAND_PROTOCOLS_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}") -pkg_get_variable(WAYLAND_SCANNER_PKGDATA_DIR wayland-scanner pkgdatadir) -message( - STATUS "Found wayland-scanner pkgdatadir at ${WAYLAND_SCANNER_PKGDATA_DIR}") if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG) - message(STATUS "Configuring Hyprland in Debug with CMake") - add_compile_definitions(HYPRLAND_DEBUG) - set(BUILD_TESTING ON) + message(STATUS "Configuring Hyprland in Debug with CMake") + add_compile_definitions(HYPRLAND_DEBUG) else() - add_compile_options(-O3) - message(STATUS "Configuring Hyprland in Release with CMake") - set(BUILD_TESTING OFF) + add_compile_options(-O3) + message(STATUS "Configuring Hyprland in Release with CMake") endif() -add_compile_definitions(HYPRLAND_VERSION="${HYPRLAND_VERSION}") - -include_directories(. "src/" "protocols/") - -set(CMAKE_CXX_STANDARD 26) -set(CXX_STANDARD_REQUIRED ON) -add_compile_options( - -Wall - -Wextra - -Wpedantic - -Wno-unused-parameter - -Wno-unused-value - -Wno-missing-field-initializers - -Wno-gnu-zero-variadic-macro-arguments - -Wno-narrowing - -Wno-pointer-arith - -Wno-clobbered - -frtti - -fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=) - -# disable lto as it may break plugins -add_compile_options(-fno-lto) - -set(CMAKE_EXECUTABLE_ENABLE_EXPORTS TRUE) -set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) +include_directories( + . + "subprojects/wlroots/include/" + "subprojects/wlroots/build/include/" + "subprojects/udis86/" + "protocols/") +set(CMAKE_CXX_STANDARD 23) +add_compile_definitions(WLR_USE_UNSTABLE) +add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-narrowing -Wno-pointer-arith) +add_link_options(-rdynamic) +set(CMAKE_ENABLE_EXPORTS TRUE) message(STATUS "Checking deps...") find_package(Threads REQUIRED) -set(GLES_VERSION "GLES3") -find_package(OpenGL REQUIRED COMPONENTS ${GLES_VERSION}) -find_package(glslang CONFIG REQUIRED) +find_package(PkgConfig REQUIRED) +find_package(OpenGL REQUIRED) +pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-server wayland-client wayland-cursor wayland-protocols cairo libdrm xkbcommon libinput pango pangocairo pixman-1) # we do not check for wlroots, as we provide it ourselves -set(AQUAMARINE_MINIMUM_VERSION 0.9.3) -set(HYPRLANG_MINIMUM_VERSION 0.6.7) -set(HYPRCURSOR_MINIMUM_VERSION 0.1.7) -set(HYPRUTILS_MINIMUM_VERSION 0.11.0) -set(HYPRGRAPHICS_MINIMUM_VERSION 0.1.6) +file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp") -pkg_check_modules(aquamarine_dep REQUIRED IMPORTED_TARGET aquamarine>=${AQUAMARINE_MINIMUM_VERSION}) -pkg_check_modules(hyprlang_dep REQUIRED IMPORTED_TARGET hyprlang>=${HYPRLANG_MINIMUM_VERSION}) -pkg_check_modules(hyprcursor_dep REQUIRED IMPORTED_TARGET hyprcursor>=${HYPRCURSOR_MINIMUM_VERSION}) -pkg_check_modules(hyprutils_dep REQUIRED IMPORTED_TARGET hyprutils>=${HYPRUTILS_MINIMUM_VERSION}) -pkg_check_modules(hyprgraphics_dep REQUIRED IMPORTED_TARGET hyprgraphics>=${HYPRGRAPHICS_MINIMUM_VERSION}) - -string(REPLACE "." ";" AQ_VERSION_LIST ${aquamarine_dep_VERSION}) -list(GET AQ_VERSION_LIST 0 AQ_VERSION_MAJOR) -list(GET AQ_VERSION_LIST 1 AQ_VERSION_MINOR) -list(GET AQ_VERSION_LIST 2 AQ_VERSION_PATCH) - -set(AQUAMARINE_VERSION "${aquamarine_dep_VERSION}") -set(AQUAMARINE_VERSION_MAJOR "${AQ_VERSION_MAJOR}") -set(AQUAMARINE_VERSION_MINOR "${AQ_VERSION_MINOR}") -set(AQUAMARINE_VERSION_PATCH "${AQ_VERSION_PATCH}") -set(HYPRLANG_VERSION "${hyprlang_dep_VERSION}") -set(HYPRUTILS_VERSION "${hyprutils_dep_VERSION}") -set(HYPRCURSOR_VERSION "${hyprcursor_dep_VERSION}") -set(HYPRGRAPHICS_VERSION "${hyprgraphics_dep_VERSION}") - - -find_package(Git QUIET) - -# Populate variables with env vars if present -set(GIT_COMMIT_HASH "$ENV{GIT_COMMIT_HASH}") -if(NOT GIT_COMMIT_HASH) - set(GIT_COMMIT_HASH "unknown") -endif() - -set(GIT_BRANCH "$ENV{GIT_BRANCH}") -if(NOT GIT_BRANCH) - set(GIT_BRANCH "unknown") -endif() - -set(GIT_COMMIT_MESSAGE "$ENV{GIT_COMMIT_MESSAGE}") -if(NOT GIT_COMMIT_MESSAGE) - set(GIT_COMMIT_MESSAGE "unknown") -endif() - -set(GIT_COMMIT_DATE "$ENV{GIT_COMMIT_DATE}") -if(NOT GIT_COMMIT_DATE) - set(GIT_COMMIT_DATE "unknown") -endif() - -set(GIT_DIRTY "$ENV{GIT_DIRTY}") -if(NOT GIT_DIRTY) - set(GIT_DIRTY "unknown") -endif() - -set(GIT_TAG "$ENV{GIT_TAG}") -if(NOT GIT_TAG) - set(GIT_TAG "unknown") -endif() - -set(GIT_COMMITS "$ENV{GIT_COMMITS}") -if(NOT GIT_COMMITS) - set(GIT_COMMITS "0") -endif() - -if(Git_FOUND) - execute_process( - COMMAND ${GIT_EXECUTABLE} rev-parse --show-toplevel - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE GIT_TOPLEVEL - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET - RESULT_VARIABLE GIT_TOPLEVEL_RESULT - ) - - if(GIT_TOPLEVEL_RESULT EQUAL 0) - message(STATUS "Detected git repository root: ${GIT_TOPLEVEL}") - - execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD - WORKING_DIRECTORY ${GIT_TOPLEVEL} - OUTPUT_VARIABLE GIT_COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND ${GIT_EXECUTABLE} branch --show-current - WORKING_DIRECTORY ${GIT_TOPLEVEL} - OUTPUT_VARIABLE GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND sh "-c" "${GIT_EXECUTABLE} show -s --format=%s --no-show-signature | sed \"s/\\\"/\'/g\"" - WORKING_DIRECTORY ${GIT_TOPLEVEL} - OUTPUT_VARIABLE GIT_COMMIT_MESSAGE OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND ${GIT_EXECUTABLE} show -s --format=%cd --date=local --no-show-signature - WORKING_DIRECTORY ${GIT_TOPLEVEL} - OUTPUT_VARIABLE GIT_COMMIT_DATE OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND ${GIT_EXECUTABLE} diff-index --quiet HEAD -- - WORKING_DIRECTORY ${GIT_TOPLEVEL} - RESULT_VARIABLE GIT_DIRTY_RESULT) - if(NOT GIT_DIRTY_RESULT EQUAL 0) - set(GIT_DIRTY "dirty") - else() - set(GIT_DIRTY "clean") - endif() - execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags - WORKING_DIRECTORY ${GIT_TOPLEVEL} - OUTPUT_VARIABLE GIT_TAG OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD - WORKING_DIRECTORY ${GIT_TOPLEVEL} - OUTPUT_VARIABLE GIT_COMMITS OUTPUT_STRIP_TRAILING_WHITESPACE) - else() - message(WARNING "No Git repository detected in ${CMAKE_SOURCE_DIR}") - endif() -endif() - -configure_file( - ${CMAKE_SOURCE_DIR}/src/version.h.in - ${CMAKE_SOURCE_DIR}/src/version.h - @ONLY -) - -set_source_files_properties(${CMAKE_SOURCE_DIR}/src/version.h PROPERTIES GENERATED TRUE) - -set(XKBCOMMON_MINIMUM_VERSION 1.11.0) -set(WAYLAND_SERVER_MINIMUM_VERSION 1.22.91) -set(WAYLAND_SERVER_PROTOCOLS_MINIMUM_VERSION 1.45) -set(LIBINPUT_MINIMUM_VERSION 1.28) - -pkg_check_modules( - deps - REQUIRED - IMPORTED_TARGET GLOBAL - xkbcommon>=${XKBCOMMON_MINIMUM_VERSION} - uuid - wayland-server>=${WAYLAND_SERVER_MINIMUM_VERSION} - wayland-protocols>=${WAYLAND_SERVER_PROTOCOLS_MINIMUM_VERSION} - cairo - pango - pangocairo - pixman-1 - xcursor - libdrm - libinput>=${LIBINPUT_MINIMUM_VERSION} - gbm - gio-2.0 - re2 - muparser - lcms2) - -find_package(hyprwayland-scanner 0.3.10 REQUIRED) - -file(GLOB_RECURSE SRCFILES "src/*.cpp") -get_filename_component(FULL_MAIN_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp ABSOLUTE) -list(REMOVE_ITEM SRCFILES "${FULL_MAIN_PATH}") - -set(TRACY_CPP_FILES "") -if(USE_TRACY) - set(TRACY_CPP_FILES "subprojects/tracy/public/TracyClient.cpp") - message(STATUS "Tracy enabled, TRACY_CPP_FILES: " ${TRACY_CPP_FILES}) -endif() - -add_library(hyprland_lib STATIC ${SRCFILES}) -add_executable(Hyprland src/main.cpp ${TRACY_CPP_FILES}) -target_link_libraries(Hyprland hyprland_lib) - -target_include_directories(hyprland_lib PUBLIC ${deps_INCLUDE_DIRS}) -target_include_directories(Hyprland PUBLIC ${deps_INCLUDE_DIRS}) - -set(USE_GPROF OFF) +add_executable(Hyprland ${SRCFILES}) if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG) - message(STATUS "Setting debug flags") + message(STATUS "Setting debug flags") - if(WITH_ASAN) - message(STATUS "Enabling ASan") + target_link_libraries(Hyprland asan) - target_link_libraries(hyprland_lib PUBLIC asan) - target_compile_options(hyprland_lib PUBLIC -fsanitize=address) - endif() - - add_compile_options(-fno-pie -fno-builtin) - add_link_options(-no-pie -fno-builtin) - if(USE_GPROF) - add_compile_options(-pg) - add_link_options(-pg) - endif() -endif() - -if(USE_TRACY) - message(STATUS "Tracy is turned on") - - option(TRACY_ENABLE "" ON) - option(TRACY_ON_DEMAND "" ON) - add_subdirectory(subprojects/tracy) - - add_compile_options(-fno-omit-frame-pointer) - - target_link_libraries(hyprland_lib PUBLIC Tracy::TracyClient) - - if(USE_TRACY_GPU) - message(STATUS "Tracy GPU Profiling is turned on") - add_compile_definitions(USE_TRACY_GPU) - endif() -endif() - -if(BUILT_WITH_NIX) - add_compile_definitions(BUILT_WITH_NIX) -endif() - -check_include_file("execinfo.h" EXECINFOH) -if(EXECINFOH) - message(STATUS "Configuration supports execinfo") - add_compile_definitions(HAS_EXECINFO) + add_compile_options(-pg -no-pie -fno-builtin -fsanitize=address) + add_link_options(-pg -no-pie -fno-builtin) endif() include(CheckLibraryExists) check_library_exists(execinfo backtrace "" HAVE_LIBEXECINFO) if(HAVE_LIBEXECINFO) - target_link_libraries(hyprland_lib PUBLIC execinfo) + target_link_libraries(Hyprland execinfo) endif() -check_include_file("sys/timerfd.h" HAS_TIMERFD) -pkg_check_modules(epoll IMPORTED_TARGET epoll-shim) -if(NOT HAS_TIMERFD AND epoll_FOUND) - target_link_libraries(hyprland_lib PUBLIC PkgConfig::epoll) -endif() - -check_include_file("sys/inotify.h" HAS_INOTIFY) -pkg_check_modules(inotify IMPORTED_TARGET libinotify) -if(NOT HAS_INOTIFY AND inotify_FOUND) - target_link_libraries(hyprland_lib PUBLIC PkgConfig::inotify) +if(LEGACY_RENDERER) + message(STATUS "Using the legacy GLES2 renderer!") + add_compile_definitions(LEGACY_RENDERER) endif() if(NO_XWAYLAND) - message(STATUS "Using the NO_XWAYLAND flag, disabling XWayland!") - add_compile_definitions(NO_XWAYLAND) + message(STATUS "Using the NO_XWAYLAND flag, disabling XWayland!") + add_compile_definitions(NO_XWAYLAND) else() - message(STATUS "XWAYLAND Enabled (NO_XWAYLAND not defined) checking deps...") - set(XWAYLAND_DEPENDENCIES - xcb - xcb-render - xcb-xfixes - xcb-icccm - xcb-composite - xcb-res - xcb-errors) - - pkg_check_modules( - xdeps - REQUIRED - IMPORTED_TARGET - ${XWAYLAND_DEPENDENCIES}) - - string(JOIN ", " PKGCONFIG_XWAYLAND_DEPENDENCIES ${XWAYLAND_DEPENDENCIES}) - string(PREPEND PKGCONFIG_XWAYLAND_DEPENDENCIES ", ") - - target_link_libraries(hyprland_lib PUBLIC PkgConfig::xdeps) + message(STATUS "XWAYLAND Enabled (NO_XWAYLAND not defined) checking deps...") + pkg_check_modules(xcbdep REQUIRED IMPORTED_TARGET xcb) + target_link_libraries(Hyprland PkgConfig::xcbdep) endif() -configure_file(hyprland.pc.in hyprland.pc @ONLY) - if(NO_SYSTEMD) - message(STATUS "SYSTEMD support is disabled...") + message(STATUS "SYSTEMD support is disabled...") else() - message(STATUS "SYSTEMD support is requested (NO_SYSTEMD not defined)...") - add_compile_definitions(USES_SYSTEMD) - - # session file -uwsm - if(NO_UWSM) - message(STATUS "UWSM support is disabled...") - else() - message(STATUS "UWSM support is enabled (NO_UWSM not defined)...") - install(FILES ${CMAKE_SOURCE_DIR}/systemd/hyprland-uwsm.desktop - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/wayland-sessions) - endif() + message(STATUS "SYSTEMD support is requested (NO_SYSTEMD not defined) checking deps...") + pkg_check_modules(LIBSYSTEMD libsystemd) + check_include_file("systemd/sd-daemon.h" SYSTEMDH) + if(LIBSYSTEMD_FOUND AND SYSTEMDH) + add_compile_definitions(USES_SYSTEMD) + target_link_libraries(Hyprland "${LIBSYSTEMD_LIBRARIES}") + else() + message(WARNING "Systemd support requested but libsystemd or systemd headers were not found") + endif() endif() +target_compile_definitions(Hyprland + PRIVATE + "GIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"" + "GIT_BRANCH=\"${GIT_BRANCH}\"" + "GIT_COMMIT_MESSAGE=\"${GIT_COMMIT_MESSAGE}\"" + "GIT_DIRTY=\"${GIT_DIRTY}\"" + "GIT_TAG=\"${GIT_TAG}\"") + +target_link_libraries(Hyprland rt) + set(CPACK_PROJECT_NAME ${PROJECT_NAME}) set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) include(CPack) -if(CMAKE_DISABLE_PRECOMPILE_HEADERS) - message(STATUS "Not using precompiled headers") -else() - message(STATUS "Setting precompiled headers") - target_precompile_headers(hyprland_lib PRIVATE - $<$:src/pch/pch.hpp>) -endif() - message(STATUS "Setting link libraries") -target_link_libraries( - hyprland_lib - PUBLIC - PkgConfig::aquamarine_dep - PkgConfig::hyprlang_dep - PkgConfig::hyprutils_dep - PkgConfig::hyprcursor_dep - PkgConfig::hyprgraphics_dep - PkgConfig::deps -) - -target_link_libraries( - Hyprland - ${LIBRT} - hyprland_lib) -if(udis_dep_FOUND) - target_link_libraries(hyprland_lib PUBLIC PkgConfig::udis_dep) -elseif(NOT("${udis_nopc}" MATCHES "udis_nopc-NOTFOUND")) - target_link_libraries(hyprland_lib PUBLIC ${udis_nopc}) -else() - target_link_libraries(hyprland_lib PUBLIC libudis86) -endif() - -# used by `make installheaders`, to ensure the headers are generated -add_custom_target(generate-protocol-headers) -set(PROTOCOL_SOURCES "") - -function(protocolnew protoPath protoName external) - if(external) - set(path ${protoPath}) - else() - set(path ${WAYLAND_PROTOCOLS_DIR}/${protoPath}) - endif() - add_custom_command( - OUTPUT ${CMAKE_SOURCE_DIR}/protocols/${protoName}.cpp - ${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp - COMMAND hyprwayland-scanner ${path}/${protoName}.xml - ${CMAKE_SOURCE_DIR}/protocols/ - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) - target_sources(hyprland_lib PRIVATE protocols/${protoName}.cpp - protocols/${protoName}.hpp) - target_sources(generate-protocol-headers - PRIVATE ${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp) - - list(APPEND PROTOCOL_SOURCES "${CMAKE_SOURCE_DIR}/protocols/${protoName}.cpp") - set(PROTOCOL_SOURCES "${PROTOCOL_SOURCES}" PARENT_SCOPE) - list(APPEND PROTOCOL_SOURCES "${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp") - set(PROTOCOL_SOURCES "${PROTOCOL_SOURCES}" PARENT_SCOPE) -endfunction() -function(protocolWayland) - add_custom_command( - OUTPUT ${CMAKE_SOURCE_DIR}/protocols/wayland.cpp - ${CMAKE_SOURCE_DIR}/protocols/wayland.hpp - COMMAND - hyprwayland-scanner --wayland-enums - ${WAYLAND_SCANNER_PKGDATA_DIR}/wayland.xml ${CMAKE_SOURCE_DIR}/protocols/ - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) - target_sources(hyprland_lib PRIVATE protocols/wayland.cpp protocols/wayland.hpp) - target_sources(generate-protocol-headers - PRIVATE ${CMAKE_SOURCE_DIR}/protocols/wayland.hpp) - - list(APPEND PROTOCOL_SOURCES "${CMAKE_SOURCE_DIR}/protocols/wayland.hpp") - set(PROTOCOL_SOURCES "${PROTOCOL_SOURCES}" PARENT_SCOPE) - list(APPEND PROTOCOL_SOURCES "${CMAKE_SOURCE_DIR}/protocols/wayland.cpp") - set(PROTOCOL_SOURCES "${PROTOCOL_SOURCES}" PARENT_SCOPE) +function(protocol protoPath protoName external) + if (external) + execute_process( + COMMAND ${WaylandScanner} server-header ${protoPath} protocols/${protoName}-protocol.h + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + execute_process( + COMMAND ${WaylandScanner} private-code ${protoPath} protocols/${protoName}-protocol.c + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + target_sources(Hyprland PRIVATE protocols/${protoName}-protocol.c) + else() + execute_process( + COMMAND ${WaylandScanner} server-header ${WAYLAND_PROTOCOLS_DIR}/${protoPath} protocols/${protoName}-protocol.h + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + execute_process( + COMMAND ${WaylandScanner} private-code ${WAYLAND_PROTOCOLS_DIR}/${protoPath} protocols/${protoName}-protocol.c + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + target_sources(Hyprland PRIVATE protocols/${protoName}-protocol.c) + endif() endfunction() -if(TARGET OpenGL::GL) - target_link_libraries(hyprland_lib PUBLIC OpenGL::EGL OpenGL::GL glslang::glslang glslang::glslang-default-resource-limits glslang::SPIRV Threads::Threads) -else() - target_link_libraries(hyprland_lib PUBLIC OpenGL::EGL OpenGL::GLES3 glslang::glslang glslang::glslang-default-resource-limits glslang::SPIRV Threads::Threads) -endif() +target_link_libraries(Hyprland PkgConfig::deps) -pkg_check_modules(hyprland_protocols_dep hyprland-protocols>=0.6.4) -if(hyprland_protocols_dep_FOUND) - pkg_get_variable(HYPRLAND_PROTOCOLS hyprland-protocols pkgdatadir) - message(STATUS "hyprland-protocols dependency set to ${HYPRLAND_PROTOCOLS}") -else() - set(HYPRLAND_PROTOCOLS "subprojects/hyprland-protocols") - message(STATUS "hyprland-protocols subproject set to ${HYPRLAND_PROTOCOLS}") -endif() - -protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-global-shortcuts-v1" - true) -protocolnew("unstable/text-input" "text-input-unstable-v1" false) -protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-toplevel-export-v1" - true) -protocolnew("protocols" "wlr-screencopy-unstable-v1" true) -protocolnew("protocols" "wlr-gamma-control-unstable-v1" true) -protocolnew("protocols" "wlr-foreign-toplevel-management-unstable-v1" true) -protocolnew("protocols" "wlr-output-power-management-unstable-v1" true) -protocolnew("protocols" "virtual-keyboard-unstable-v1" true) -protocolnew("protocols" "wlr-virtual-pointer-unstable-v1" true) -protocolnew("protocols" "input-method-unstable-v2" true) -protocolnew("protocols" "wlr-output-management-unstable-v1" true) -protocolnew("protocols" "kde-server-decoration" true) -protocolnew("protocols" "wlr-data-control-unstable-v1" true) -protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-focus-grab-v1" true) -protocolnew("protocols" "wlr-layer-shell-unstable-v1" true) -protocolnew("protocols" "wayland-drm" true) -protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-ctm-control-v1" true) -protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-surface-v1" true) -protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-lock-notify-v1" true) -protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-toplevel-mapping-v1" - true) - -protocolnew("staging/tearing-control" "tearing-control-v1" false) -protocolnew("staging/fractional-scale" "fractional-scale-v1" false) -protocolnew("unstable/xdg-output" "xdg-output-unstable-v1" false) -protocolnew("staging/cursor-shape" "cursor-shape-v1" false) -protocolnew("unstable/idle-inhibit" "idle-inhibit-unstable-v1" false) -protocolnew("unstable/relative-pointer" "relative-pointer-unstable-v1" false) -protocolnew("unstable/xdg-decoration" "xdg-decoration-unstable-v1" false) -protocolnew("staging/alpha-modifier" "alpha-modifier-v1" false) -protocolnew("staging/ext-foreign-toplevel-list" "ext-foreign-toplevel-list-v1" - false) -protocolnew("unstable/pointer-gestures" "pointer-gestures-unstable-v1" false) -protocolnew("unstable/keyboard-shortcuts-inhibit" - "keyboard-shortcuts-inhibit-unstable-v1" false) -protocolnew("unstable/text-input" "text-input-unstable-v3" false) -protocolnew("unstable/pointer-constraints" "pointer-constraints-unstable-v1" - false) -protocolnew("staging/xdg-activation" "xdg-activation-v1" false) -protocolnew("staging/ext-idle-notify" "ext-idle-notify-v1" false) -protocolnew("staging/ext-session-lock" "ext-session-lock-v1" false) -protocolnew("stable/tablet" "tablet-v2" false) -protocolnew("stable/presentation-time" "presentation-time" false) -protocolnew("stable/xdg-shell" "xdg-shell" false) -protocolnew("unstable/primary-selection" "primary-selection-unstable-v1" false) -protocolnew("staging/xwayland-shell" "xwayland-shell-v1" false) -protocolnew("stable/viewporter" "viewporter" false) -protocolnew("stable/linux-dmabuf" "linux-dmabuf-v1" false) -protocolnew("staging/drm-lease" "drm-lease-v1" false) -protocolnew("staging/linux-drm-syncobj" "linux-drm-syncobj-v1" false) -protocolnew("staging/xdg-dialog" "xdg-dialog-v1" false) -protocolnew("staging/single-pixel-buffer" "single-pixel-buffer-v1" false) -protocolnew("staging/security-context" "security-context-v1" false) -protocolnew("staging/content-type" "content-type-v1" false) -protocolnew("staging/color-management" "color-management-v1" false) -protocolnew("staging/xdg-toplevel-tag" "xdg-toplevel-tag-v1" false) -protocolnew("staging/xdg-system-bell" "xdg-system-bell-v1" false) -protocolnew("staging/ext-workspace" "ext-workspace-v1" false) -protocolnew("staging/ext-data-control" "ext-data-control-v1" false) -protocolnew("staging/pointer-warp" "pointer-warp-v1" false) -protocolnew("staging/fifo" "fifo-v1" false) -protocolnew("staging/commit-timing" "commit-timing-v1" false) -protocolnew("staging/ext-image-capture-source" "ext-image-capture-source-v1" false) -protocolnew("staging/ext-image-copy-capture" "ext-image-copy-capture-v1" false) - -protocolwayland() - -# tools -add_subdirectory(hyprctl) -add_subdirectory(start) - -if(NO_HYPRPM) - message(STATUS "hyprpm is disabled") -else() - add_subdirectory(hyprpm) - message(STATUS "hyprpm is enabled (NO_HYPRPM not defined)") -endif() - -# binary and symlink -install(TARGETS Hyprland) - -install( - CODE "execute_process( \ - COMMAND ${CMAKE_COMMAND} -E create_symlink \ - ${CMAKE_INSTALL_FULL_BINDIR}/Hyprland \ - \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/hyprland\" \ - )") -# session file -configure_file( - ${CMAKE_SOURCE_DIR}/example/hyprland.desktop.in - ${CMAKE_SOURCE_DIR}/example/hyprland.desktop - @ONLY +target_link_libraries(Hyprland + ${CMAKE_SOURCE_DIR}/subprojects/wlroots/build/libwlroots.so.12032 # wlroots is provided by us + OpenGL::EGL + OpenGL::GL + Threads::Threads + ${CMAKE_SOURCE_DIR}/subprojects/udis86/build/libudis86/liblibudis86.a ) -install(FILES ${CMAKE_SOURCE_DIR}/example/hyprland.desktop - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/wayland-sessions) -# allow Hyprland to find assets -add_compile_definitions(DATAROOTDIR="${CMAKE_INSTALL_FULL_DATAROOTDIR}") - -# installable assets -file(GLOB_RECURSE INSTALLABLE_ASSETS "assets/install/*") -install(FILES ${INSTALLABLE_ASSETS} - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/hypr) - -# default config -install(FILES ${CMAKE_SOURCE_DIR}/example/hyprland.conf - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/hypr) - -# portal config -install(FILES ${CMAKE_SOURCE_DIR}/assets/hyprland-portals.conf - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/xdg-desktop-portal) - -# man pages -file(GLOB_RECURSE MANPAGES "docs/*.1") -install(FILES ${MANPAGES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) - -# pkgconfig entry -install(FILES ${CMAKE_BINARY_DIR}/hyprland.pc - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) - -# protocol headers -set(HEADERS_PROTO "${CMAKE_CURRENT_SOURCE_DIR}/protocols") -install( - DIRECTORY ${HEADERS_PROTO} - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland - FILES_MATCHING - PATTERN "*.h*") - -# hyprland headers -set(HEADERS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src") -install( - DIRECTORY ${HEADERS_SRC} - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "*.inc") - -if(BUILD_TESTING OR WITH_TESTS) - message(STATUS "Building tests") - - # hyprtester - add_subdirectory(hyprtester) - - # GTest - find_package(GTest CONFIG REQUIRED) - include(GoogleTest) - file(GLOB_RECURSE TESTFILES "tests/*.cpp") - add_executable(hyprland_gtests ${TESTFILES}) - target_compile_options(hyprland_gtests PRIVATE --coverage) - target_link_options(hyprland_gtests PRIVATE --coverage) - target_include_directories( - hyprland_gtests - PUBLIC "./include" - PRIVATE "./src" "./src/include" "./protocols" "${CMAKE_BINARY_DIR}") - - target_link_libraries(hyprland_gtests hyprland_lib GTest::gtest_main) - - gtest_discover_tests(hyprland_gtests) - - # Enable coverage in main hyprland lib - target_compile_options(hyprland_lib PRIVATE --coverage) - target_link_options(hyprland_lib PRIVATE --coverage) - target_link_libraries(hyprland_lib PUBLIC gcov) - - # Enable coverage in hyprland exe - target_compile_options(Hyprland PRIVATE --coverage) - target_link_options(Hyprland PRIVATE --coverage) - target_link_libraries(Hyprland gcov) -endif() - -if(BUILD_TESTING) - message(STATUS "Testing is enabled") - - enable_testing() - add_custom_target(tests) - - add_dependencies(tests hyprland_gtests) - -else() - message(STATUS "Testing is disabled") -endif() +protocol("protocols/ext-workspace-unstable-v1.xml" "ext-workspace-unstable-v1" true) +protocol("protocols/idle.xml" "idle" true) +protocol("protocols/pointer-constraints-unstable-v1.xml" "pointer-constraints-unstable-v1" true) +protocol("protocols/tablet-unstable-v2.xml" "tablet-unstable-v2" true) +protocol("protocols/wlr-foreign-toplevel-management-unstable-v1.xml" "wlr-foreign-toplevel-management-unstable-v1" true) +protocol("protocols/wlr-layer-shell-unstable-v1.xml" "wlr-layer-shell-unstable-v1" true) +protocol("protocols/wlr-output-power-management-unstable-v1.xml" "wlr-output-power-management-unstable-v1" true) +protocol("protocols/wlr-screencopy-unstable-v1.xml" "wlr-screencopy-unstable-v1" true) +protocol("subprojects/hyprland-protocols/protocols/hyprland-global-shortcuts-v1.xml" "hyprland-global-shortcuts-v1" true) +protocol("subprojects/hyprland-protocols/protocols/hyprland-toplevel-export-v1.xml" "hyprland-toplevel-export-v1" true) +protocol("stable/xdg-shell/xdg-shell.xml" "xdg-shell" false) +protocol("unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml" "linux-dmabuf-unstable-v1" false) +protocol("staging/fractional-scale/fractional-scale-v1.xml" "fractional-scale-v1" false) +protocol("unstable/text-input/text-input-unstable-v1.xml" "text-input-unstable-v1" false) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 3c41db0e..00000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,96 +0,0 @@ -## Goal - -Our goal is to provide a space where it is safe for everyone to contribute to, -and get support for, open-source software in a respectful and cooperative -manner. - -We value all contributions and want to make this organization and its -surrounding community a place for everyone. - -As members, contributors, and everyone else who may participate in the -development, we strive to keep the entire experience civil. - -## Standards - -Our community standards exist in order to make sure everyone feels comfortable -contributing to the project(s) together. - -Our standards are: - - Do not harass, attack, or in any other way discriminate against anyone, including -for their protected traits, including, but not limited to, sex, religion, race, -appearance, gender, identity, nationality, sexuality, etc. - - Do not go off-topic, do not post spam. - - Treat everyone with respect. - -Examples of breaking each rule respectively include: - - Harassment, bullying or inappropriate jokes about another person. - - Posting distasteful imagery, trolling, or posting things unrelated to the topic at hand. - - Treating someone as worse because of their lack of understanding of an issue. - -## Enforcement - -Enforcement of this CoC is done by the members of the hyprwm organization. - -We, as the organization, will strive our best to keep this community civil and -following the standards outlined above. - -### Reporting incidents - -If you believe an incident of breaking our standards has occurred, but nobody has -taken appropriate action, you can privately contact the people responsible for dealing -with such incidents in multiple ways: - -***E-Mail*** - - `vaxry[at]vaxry.net` - - `mihai[at]fufexan.net` - -***Discord*** - - `@vaxry` - - `@fufexan` - -***Matrix*** - - `@vaxry:matrix.vaxry.net` - - `@fufexan:matrix.org` - -We, as members, guarantee your privacy and will not share those reports with anyone. - -## Enforcement Strategy - -Depending on the severity of the infraction, any action from the list below may be applied. -Please keep in mind cases are reviewed on a per-case basis and members are the ultimate -deciding factor in the type of punishment. - -If the matter would benefit from an outside opinion, a member might reach for more opinions -from people unrelated to the organization, however, the final decision regarding the action -to be taken is still up to the member. - -For example, if the matter at hand regards a representative of a marginalized group or minority, -the member might ask for a first-hand opinion from another representative of such group. - -### Correction/Edit - -If your message is found to be misleading or poorly worded, a member might -edit your message. - -### Warning/Deletion - -If your message is found inappropriate, a member might give you a public or private warning, -and/or delete your message. - -### Mute - -If your message is disruptive, or you have been repeatedly violating the standards, -a member might mute (or temporarily ban) you. - -### Ban - -If your message is hateful, very disruptive, or other, less serious infractions are repeated -ignoring previous punishments, a member might ban you permanently. - -## Scope - -This CoC shall apply to all projects ran under the `hyprwm` organization and all _official_ communities -outside of GitHub. - -However, it is worth noting that official communities outside of GitHub might have their own, -additional sets of rules. diff --git a/LICENSE b/LICENSE index efdec21a..8ec509bd 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2022-2026, vaxerski +Copyright (c) 2022-2023, vaxerski All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/Makefile b/Makefile index 852fcddf..25538384 100644 --- a/Makefile +++ b/Makefile @@ -1,57 +1,123 @@ PREFIX = /usr/local -stub: - @echo "Do not run $(MAKE) directly without any arguments. Please refer to the wiki on how to compile Hyprland." +legacyrenderer: + cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DLEGACY_RENDERER:BOOL=true -S . -B ./build -G Ninja + cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` + +legacyrendererdebug: + cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DLEGACY_RENDERER:BOOL=true -S . -B ./build -G Ninja + cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` release: - cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -S . -B ./build + cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build -G Ninja cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` debug: - cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DTESTS=true -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -S . -B ./build + cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -S . -B ./build -G Ninja cmake --build ./build --config Debug --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` -nopch: - cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON -S . -B ./build - cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` - clear: rm -rf build - rm -f ./protocols/*.h ./protocols/*.c ./protocols/*.cpp ./protocols/*.hpp - rm -f ./hyprctl/hw-protocols/*.cpp ./hyprctl/hw-protocols/*.hpp + rm -f ./protocols/*-protocol.h ./protocols/*-protocol.c + rm -f ./hyprctl/hyprctl + rm -rf ./subprojects/wlroots/build all: $(MAKE) clear + $(MAKE) fixwlr + cd ./subprojects/wlroots && meson setup build/ --buildtype=release && ninja -C build/ && mkdir -p ${PREFIX}/lib/ && cp ./build/libwlroots.so.12032 ${PREFIX}/lib/ || echo "Could not install libwlroots to ${PREFIX}/lib/libwlroots.so.12032" + cd subprojects/udis86 && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B./build -G Ninja && cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` $(MAKE) release + $(MAKE) -C hyprctl all install: - cmake --install ./build + $(MAKE) clear + $(MAKE) fixwlr + cd ./subprojects/wlroots && meson setup build/ --buildtype=release && ninja -C build/ && mkdir -p ${PREFIX}/lib/ && cp ./build/libwlroots.so.12032 ${PREFIX}/lib/ || echo "Could not install libwlroots to ${PREFIX}/lib/libwlroots.so.12032" + cd subprojects/udis86 && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B./build -G Ninja && cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` && cd ../.. + $(MAKE) release + $(MAKE) -C hyprctl all -uninstall: - xargs rm < ./build/install_manifest.txt + mkdir -p ${PREFIX}/share/wayland-sessions + mkdir -p ${PREFIX}/bin + cp -f ./build/Hyprland ${PREFIX}/bin + cp -f ./hyprctl/hyprctl ${PREFIX}/bin + if [ ! -f ${PREFIX}/share/wayland-sessions/hyprland.desktop ]; then cp ./example/hyprland.desktop ${PREFIX}/share/wayland-sessions; fi + mkdir -p ${PREFIX}/share/hyprland + cp ./assets/wall_2K.png ${PREFIX}/share/hyprland + cp ./assets/wall_4K.png ${PREFIX}/share/hyprland + cp ./assets/wall_8K.png ${PREFIX}/share/hyprland -pluginenv: - @echo -en "$(MAKE) pluginenv has been deprecated.\nPlease run $(MAKE) all && sudo $(MAKE) installheaders\n" - @exit 1 + mkdir -p ${PREFIX}/share/man/man1 + install -m644 ./docs/*.1 ${PREFIX}/share/man/man1 -installheaders: - @if [ ! -f ./src/version.h ]; then echo -en "You need to run $(MAKE) all first.\n" && exit 1; fi - - # remove previous headers from hyprpm's dir - rm -fr ${PREFIX}/include/hyprland mkdir -p ${PREFIX}/include/hyprland mkdir -p ${PREFIX}/include/hyprland/protocols + mkdir -p ${PREFIX}/include/hyprland/wlroots mkdir -p ${PREFIX}/share/pkgconfig - - cmake --build ./build --config Release --target generate-protocol-headers - - find src -type f \( -name '*.hpp' -o -name '*.h' -o -name '*.inc' \) -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland - cp ./protocols/*.h* ${PREFIX}/include/hyprland/protocols + + find src -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland + cd subprojects/wlroots/include && find . -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland/wlroots && cd ../../.. + cp ./protocols/*-protocol.h ${PREFIX}/include/hyprland/protocols cp ./build/hyprland.pc ${PREFIX}/share/pkgconfig if [ -d /usr/share/pkgconfig ]; then cp ./build/hyprland.pc /usr/share/pkgconfig 2>/dev/null || true; fi - chmod -R 755 ${PREFIX}/include/hyprland - chmod 755 ${PREFIX}/share/pkgconfig +cleaninstall: + echo -en "$(MAKE) cleaninstall has been DEPRECATED, you should avoid using it in the future.\nRunning $(MAKE) install instead...\n" + $(MAKE) install + +uninstall: + rm -f ${PREFIX}/share/wayland-sessions/hyprland.desktop + rm -f ${PREFIX}/bin/Hyprland + rm -f ${PREFIX}/bin/hyprctl + rm -f ${PREFIX}/lib/libwlroots.so.12032 + rm -rf ${PREFIX}/share/hyprland + rm -f ${PREFIX}/share/man/man1/Hyprland.1 + rm -f ${PREFIX}/share/man/man1/hyprctl.1 + +fixwlr: + sed -E -i -e 's/(soversion = 12)([^032]|$$)/soversion = 12032/g' subprojects/wlroots/meson.build + + rm -rf ./subprojects/wlroots/build + +config: + $(MAKE) fixwlr + + meson setup subprojects/wlroots/build subprojects/wlroots --prefix=${PREFIX} --buildtype=release -Dwerror=false -Dexamples=false + ninja -C subprojects/wlroots/build/ + + ninja -C subprojects/wlroots/build/ install + + cd subprojects/udis86 && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build -G Ninja && cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` + +pluginenv: + cd subprojects/udis86 && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build -G Ninja && cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` + + $(MAKE) fixwlr + + meson setup subprojects/wlroots/build subprojects/wlroots --prefix=${PREFIX} --buildtype=release -Dwerror=false -Dexamples=false + ninja -C subprojects/wlroots/build/ + + cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build -G Ninja + + mkdir -p ${PREFIX}/include/hyprland + mkdir -p ${PREFIX}/include/hyprland/protocols + mkdir -p ${PREFIX}/include/hyprland/wlroots + mkdir -p ${PREFIX}/share/pkgconfig + + find src -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland + cd subprojects/wlroots/include && find . -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland/wlroots && cd ../../.. + cp ./protocols/*-protocol.h ${PREFIX}/include/hyprland/protocols + cp ./build/hyprland.pc ${PREFIX}/share/pkgconfig + if [ -d /usr/share/pkgconfig ]; then cp ./build/hyprland.pc /usr/share/pkgconfig 2>/dev/null || true; fi + +configdebug: + $(MAKE) fixwlr + + meson setup subprojects/wlroots/build subprojects/wlroots --prefix=${PREFIX} --buildtype=debug -Dwerror=false -Dexamples=false -Db_sanitize=address + ninja -C subprojects/wlroots/build/ + + ninja -C subprojects/wlroots/build/ install man: pandoc ./docs/Hyprland.1.rst \ @@ -69,31 +135,3 @@ man: --variable=section:1 \ --from rst \ --to man > ./docs/hyprctl.1 - -asan: - @echo -en "!!WARNING!!\nOnly run this in the TTY.\n" - @pidof Hyprland > /dev/null && echo -ne "Refusing to run with Hyprland running.\n" || echo "" - @pidof Hyprland > /dev/null && exit 1 || echo "" - - rm -rf ./wayland - #git reset --hard - - @echo -en "If you want to apply a patch, input its path (leave empty for none):\n" - @read patchvar; \ - if [ -n "$$patchvar" ]; then patch -p1 < "$$patchvar" || echo ""; else echo "No patch specified"; fi - - git clone --recursive https://gitlab.freedesktop.org/wayland/wayland - cd wayland && patch -p1 < ../scripts/waylandStatic.diff && meson setup build --buildtype=debug -Db_sanitize=address -Ddocumentation=false && ninja -C build && cd .. - cp ./wayland/build/src/libwayland-server.a . - @echo "Wayland done" - - patch -p1 < ./scripts/hyprlandStaticAsan.diff - cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DWITH_ASAN:STRING=True -DUSE_TRACY:STRING=False -DUSE_TRACY_GPU:STRING=False -S . -B ./build - cmake --build ./build --config Debug --target all - @echo "Hyprland done" - - ASAN_OPTIONS="detect_odr_violation=0,log_path=asan.log" HYPRLAND_NO_CRASHREPORTER=1 ./build/Hyprland -c ~/.config/hypr/hyprland.conf - -test: - $(MAKE) debug - ./build/hyprtester/hyprtester -c hyprtester/test.conf -b ./build/Hyprland -p hyprtester/plugin/hyprtestplugin.so diff --git a/README.md b/README.md index bb74c4e4..516bcf28 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,22 @@
-banner +banner
-[![Badge Workflow]][Workflow] +![Badge Workflow] [![Badge License]][License] ![Badge Language] [![Badge Pull Requests]][Pull Requests] [![Badge Issues]][Issues] ![Badge Hi Mom]
+[![Badge Discord]][Discord]
-Hyprland is a 100% independent, dynamic tiling Wayland compositor that doesn't sacrifice on its looks. +Hyprland is a dynamic tiling Wayland compositor based on wlroots that doesn't sacrifice on its looks. -It provides the latest Wayland features, is highly customizable, has all the eyecandy, the most powerful plugins, -easy IPC, much more QoL stuff than other compositors and more... +It supports multiple layouts, fancy effects, has a very flexible IPC model allowing for a lot of customization, a powerful plugin system and more.

@@ -32,29 +32,40 @@ easy IPC, much more QoL stuff than other compositors and more...
+ +# Notice + +Hyprland is still in pretty early development compared to some other Wayland compositors. + +Although Hyprland is pretty stable, it may have some bugs. # Features -- All of the eyecandy: gradient borders, blur, animations, shadows and much more -- A lot of customization -- 100% independent, no wlroots, no libweston, no kwin, no mutter. -- Custom bezier curves for the best animations -- Powerful plugin support -- Built-in plugin manager -- Tearing support for better gaming performance - Easily expandable and readable codebase -- Fast and active development -- Not afraid to provide bleeding-edge features +- Plugin support - Config reloaded instantly upon saving +- Custom bezier curve based animations +- Dual Kawase blur +- Drop shadows +- Rounded corners +- Gradient borders - Fully dynamic workspaces -- Two built-in layouts and more available as plugins +- Closely follows `wlroots-git` - Global keybinds passed to your apps of choice +- A lot of customization +- Bundled wlroots +- Window/layer fade in/out - Tiling/pseudotiling/floating/fullscreen windows +- Switching workspaces between window modes on the fly - Special workspaces (scratchpads) -- Window groups (tabbed mode) -- Powerful window/monitor/layer rules +- Window/monitor rules - Socket-based IPC -- Native IME and Input Panels Support +- `wlr_ext` workspaces protocol support +- Event system for bash scripts +- Full damage tracking +- Docks support +- Drawing tablet support +- Native IME + Input panels support - and much more...
@@ -79,13 +90,22 @@ easy IPC, much more QoL stuff than other compositors and more...

+# Stars Over Time + +
+ +[![Stars Preview]][Stars] + +
+
+ # Special Thanks
-**[wlroots]** - *For powering Hyprland in the past* +**[wlroots]** - *For their amazing library* **[tinywl]** - *For showing how 2 do stuff* @@ -100,7 +120,8 @@ easy IPC, much more QoL stuff than other compositors and more... -[Configure]: https://wiki.hypr.land/Configuring/ +[Configure]: https://wiki.hyprland.org/Configuring/Configuring-Hyprland/ +[Discord]: https://discord.gg/hQ9XvMUjjr [Stars]: https://starchart.cc/hyprwm/Hyprland [Hypr]: https://github.com/hyprwm/Hypr @@ -108,10 +129,9 @@ easy IPC, much more QoL stuff than other compositors and more... [Issues]: https://github.com/hyprwm/Hyprland/issues [Todo]: https://github.com/hyprwm/Hyprland/projects?type=beta -[Contribute]: https://wiki.hypr.land/Contributing-and-Debugging/ -[Install]: https://wiki.hypr.land/Getting-Started/Installation/ -[Quick Start]: https://wiki.hypr.land/Getting-Started/Master-Tutorial/ -[Workflow]: https://github.com/hyprwm/Hyprland/actions/workflows/ci.yaml +[Contribute]: https://wiki.hyprland.org/Contributing-and-Debugging/ +[Install]: https://wiki.hyprland.org/Getting-Started/Installation/ +[Quick Start]: https://wiki.hyprland.org/Getting-Started/Master-Tutorial/ [License]: LICENSE @@ -122,19 +142,21 @@ easy IPC, much more QoL stuff than other compositors and more... [Wayfire]: https://github.com/WayfireWM/wayfire [TinyWl]: https://gitlab.freedesktop.org/wlroots/wlroots/-/blob/master/tinywl/tinywl.c [Sway]: https://github.com/swaywm/sway -[DWL]: https://codeberg.org/dwl/dwl +[DWL]: https://github.com/djpohly/dwl -[Preview A]: https://i.ibb.co/XxFY75Mk/greerggergerhtrytghjnyhjn.png -[Preview B]: https://i.ibb.co/C1yTb0r/falf.png -[Preview C]: https://i.ibb.co/2Yc4q835/hyprland-preview-b.png +[Stars Preview]: https://starchart.cc/vaxerski/Hyprland.svg +[Preview A]: https://i.ibb.co/SX7GbYR/winter-rice.png +[Preview B]: https://i.ibb.co/B3GJg28/20221126-20h53m26s-grim.png +[Preview C]: https://i.imgur.com/pC6YF1Y.png [Badge Workflow]: https://github.com/hyprwm/Hyprland/actions/workflows/ci.yaml/badge.svg +[Badge Discord]: https://img.shields.io/badge/Join%20the-Discord%20server-6666ff [Badge Issues]: https://img.shields.io/github/issues/hyprwm/Hyprland [Badge Pull Requests]: https://img.shields.io/github/issues-pr/hyprwm/Hyprland [Badge Language]: https://img.shields.io/github/languages/top/hyprwm/Hyprland diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 187165ce..00000000 --- a/SECURITY.md +++ /dev/null @@ -1,32 +0,0 @@ -# Hyprland Development Security Policy - -If you have a bug that affects the security of your system, you may -want to privately disclose it instead of making it immediately public. - -## Supported versions - -_Only_ the most recent release on Github is supported. There are no LTS releases. - -## What is not a security issue - -Some examples of issues that should not be reported as security issues: - -- An app can execute a command when ran outside of a sandbox -- An app can write / read hyprland sockets when ran outside of a sandbox -- Crashes -- Things that are protected via permissions when the permission system is disabled - -## What is a security issue - -Some examples of issues that should be reported as security issues: - -- Sandboxed application executing arbitrary code via Hyprland -- Application being able to modify Hyprland's code on the fly -- Application being able to keylog / track user's activity beyond what the wayland protocols allow - -## How to report security issues - -Please report your security issues via either of these channels: -- Mail: `vaxry [at] vaxry [dot] net` -- Matrix: `@vaxry:matrix.vaxry.net` -- Discord: `@vaxry` diff --git a/VERSION b/VERSION deleted file mode 100644 index 524456c7..00000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.54.0 diff --git a/assets/header.svg b/assets/header.svg index a2b32551..c8cf8222 100644 --- a/assets/header.svg +++ b/assets/header.svg @@ -1,64 +1,72 @@ - - -
# Reporting suggestions Suggestions are welcome. -Many features can be implemented using bash scripts and Hyprland sockets, read up on those [Here](https://wiki.hypr.land/IPC). Please do not suggest features that can be implemented as such. +Many features can be implemented using bash scripts and Hyprland sockets, read up on those [Here](https://wiki.hyprland.org/IPC). Please do not suggest features that can be implemented as such.
@@ -34,20 +34,20 @@ If your bug crashes Hyprland, append additionally: ## Obtaining the Hyprland log If you are in a TTY, and the hyprland session that crashed was the last one you launched, the log will be printed with ``` -cat $XDG_RUNTIME_DIR/hypr/$(ls -t $XDG_RUNTIME_DIR/hypr | head -n 1)/hyprland.log +cat /tmp/hypr/$(ls -t /tmp/hypr/ | head -n 1)/hyprland.log ``` feel free to send it to a file, save, copy, etc. if you are in a Hyprland session, and you want the log of the last session, use ``` -cat $XDG_RUNTIME_DIR/hypr/$(ls -t $XDG_RUNTIME_DIR/hypr | head -n 2 | tail -n 1)/hyprland.log +cat /tmp/hypr/$(ls -t /tmp/hypr/ | head -n 2 | tail -n 1)/hyprland.log ``` -basically, directories in $XDG_RUNTIME_DIR/hypr are your sessions. +basically, directories in /tmp/hypr are your sessions. ## Obtaining the Hyprland Crash Report (v0.22.0beta and up) -If you have `$XDG_CACHE_HOME` set, the crash report directory is `$XDG_CACHE_HOME/hyprland`. If not, it's `$HOME/.cache/hyprland`. +If you have `$XDG_CACHE_HOME` set, the crash report directory is `$XDG_CACHE_HOME/hyprland`. If not, it's `~/.hyprland` Go to the crash report directory and you should find a file named `hyprlandCrashReport[XXXX].txt` where `[XXXX]` is the PID of the process that crashed. @@ -70,7 +70,7 @@ A debug coredump provides more information for debugging and may speed up the pr Make sure you're on latest git. Run `git pull --recurse-submodules` to sync everything. -1. [Compile Hyprland with debug mode](http://wiki.hypr.land/Contributing-and-Debugging/#build-in-debug-mode) +1. [Compile Hyprland with debug mode](http://wiki.hyprland.org/Contributing-and-Debugging/#build-in-debug-mode) > Note: The config file used will be `hyprlandd.conf` instead of `hyprland.conf` 2. `cd ~` diff --git a/docs/hyprctl.1 b/docs/hyprctl.1 index 61cb84fd..27a9141a 100644 --- a/docs/hyprctl.1 +++ b/docs/hyprctl.1 @@ -1,20 +1,6 @@ -.\" Automatically generated by Pandoc 3.1.3 +.\" Automatically generated by Pandoc 2.9.2.1 .\" -.\" Define V font for inline verbatim, using C font in formats -.\" that render this, and otherwise B font. -.ie "\f[CB]x\f[]"x" \{\ -. ftr V B -. ftr VI BI -. ftr VB B -. ftr VBI BI -.\} -.el \{\ -. ftr V CR -. ftr VI CI -. ftr VB CB -. ftr VBI CBI -.\} -.TH "hyprctl" "1" "" "" "hyprctl User Manual" +.TH "hyprctl" "1" "03 Apr 2023" "" "hyprctl User Manual" .hy .SH NAME .PP diff --git a/docs/meson.build b/docs/meson.build new file mode 100644 index 00000000..a5d7e737 --- /dev/null +++ b/docs/meson.build @@ -0,0 +1,2 @@ +install_man ('Hyprland.1') +install_man ('hyprctl.1') diff --git a/example/examplePlugin/Makefile b/example/examplePlugin/Makefile new file mode 100644 index 00000000..ea5f3e6d --- /dev/null +++ b/example/examplePlugin/Makefile @@ -0,0 +1,8 @@ +# compile with HYPRLAND_HEADERS= make all +# make sure that the path above is to the root hl repo directory, NOT src/ +# and that you have ran `make protocols` in the hl dir. + +all: + g++ -shared -fPIC --no-gnu-unique main.cpp customLayout.cpp customDecoration.cpp -o examplePlugin.so -g -I "/usr/include/pixman-1" -I "/usr/include/libdrm" -I "${HYPRLAND_HEADERS}" -I "${HYPRLAND_HEADERS}/subprojects/wlroots/include" -I "${HYPRLAND_HEADERS}/subprojects/wlroots/include" -I "${HYPRLAND_HEADERS}/subprojects/wlroots/build/include" -std=c++23 +clean: + rm ./examplePlugin.so diff --git a/example/examplePlugin/customDecoration.cpp b/example/examplePlugin/customDecoration.cpp new file mode 100644 index 00000000..d336d4e8 --- /dev/null +++ b/example/examplePlugin/customDecoration.cpp @@ -0,0 +1,74 @@ +#include "customDecoration.hpp" +#include "../../src/Window.hpp" +#include "../../src/Compositor.hpp" +#include "globals.hpp" + +CCustomDecoration::CCustomDecoration(CWindow* pWindow) { + m_pWindow = pWindow; + m_vLastWindowPos = pWindow->m_vRealPosition.vec(); + m_vLastWindowSize = pWindow->m_vRealSize.vec(); +} + +CCustomDecoration::~CCustomDecoration() { + damageEntire(); +} + +SWindowDecorationExtents CCustomDecoration::getWindowDecorationExtents() { + return m_seExtents; +} + +void CCustomDecoration::draw(CMonitor* pMonitor, float a, const Vector2D& offset) { + if (!g_pCompositor->windowValidMapped(m_pWindow)) + return; + + if (!m_pWindow->m_sSpecialRenderData.decorate) + return; + + static auto* const PCOLOR = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:example:border_color")->intValue; + static auto* const PROUNDING = &HyprlandAPI::getConfigValue(PHANDLE, "decoration:rounding")->intValue; + static auto* const PBORDERSIZE = &HyprlandAPI::getConfigValue(PHANDLE, "general:border_size")->intValue; + + const auto ROUNDING = !m_pWindow->m_sSpecialRenderData.rounding ? + 0 : + (m_pWindow->m_sAdditionalConfigData.rounding.toUnderlying() == -1 ? *PROUNDING : m_pWindow->m_sAdditionalConfigData.rounding.toUnderlying()); + + // draw the border + wlr_box fullBox = {(int)(m_vLastWindowPos.x - *PBORDERSIZE), (int)(m_vLastWindowPos.y - *PBORDERSIZE), (int)(m_vLastWindowSize.x + 2.0 * *PBORDERSIZE), + (int)(m_vLastWindowSize.y + 2.0 * *PBORDERSIZE)}; + + fullBox.x -= pMonitor->vecPosition.x; + fullBox.y -= pMonitor->vecPosition.y; + + m_seExtents = {{m_vLastWindowPos.x - fullBox.x - pMonitor->vecPosition.x + 2, m_vLastWindowPos.y - fullBox.y - pMonitor->vecPosition.y + 2}, + {fullBox.x + fullBox.width + pMonitor->vecPosition.x - m_vLastWindowPos.x - m_vLastWindowSize.x + 2, + fullBox.y + fullBox.height + pMonitor->vecPosition.y - m_vLastWindowPos.y - m_vLastWindowSize.y + 2}}; + + fullBox.x += offset.x; + fullBox.y += offset.y; + + if (fullBox.width < 1 || fullBox.height < 1) + return; // don't draw invisible shadows + + g_pHyprOpenGL->scissor((wlr_box*)nullptr); + + scaleBox(&fullBox, pMonitor->scale); + g_pHyprOpenGL->renderBorder(&fullBox, CColor(*PCOLOR), *PROUNDING * pMonitor->scale + *PBORDERSIZE * 2, a); +} + +eDecorationType CCustomDecoration::getDecorationType() { + return DECORATION_CUSTOM; +} + +void CCustomDecoration::updateWindow(CWindow* pWindow) { + + m_vLastWindowPos = pWindow->m_vRealPosition.vec(); + m_vLastWindowSize = pWindow->m_vRealSize.vec(); + + damageEntire(); +} + +void CCustomDecoration::damageEntire() { + wlr_box dm = {(int)(m_vLastWindowPos.x - m_seExtents.topLeft.x), (int)(m_vLastWindowPos.y - m_seExtents.topLeft.y), + (int)(m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x), (int)m_seExtents.topLeft.y}; + g_pHyprRenderer->damageBox(&dm); +} \ No newline at end of file diff --git a/example/examplePlugin/customDecoration.hpp b/example/examplePlugin/customDecoration.hpp new file mode 100644 index 00000000..a08b48bf --- /dev/null +++ b/example/examplePlugin/customDecoration.hpp @@ -0,0 +1,29 @@ +#pragma once + +#define WLR_USE_UNSTABLE + +#include "../../src/render/decorations/IHyprWindowDecoration.hpp" + +class CCustomDecoration : public IHyprWindowDecoration { + public: + CCustomDecoration(CWindow*); + virtual ~CCustomDecoration(); + + virtual SWindowDecorationExtents getWindowDecorationExtents(); + + virtual void draw(CMonitor*, float a, const Vector2D& offset); + + virtual eDecorationType getDecorationType(); + + virtual void updateWindow(CWindow*); + + virtual void damageEntire(); + + private: + SWindowDecorationExtents m_seExtents; + + CWindow* m_pWindow = nullptr; + + Vector2D m_vLastWindowPos; + Vector2D m_vLastWindowSize; +}; \ No newline at end of file diff --git a/example/examplePlugin/customLayout.cpp b/example/examplePlugin/customLayout.cpp new file mode 100644 index 00000000..fcc51394 --- /dev/null +++ b/example/examplePlugin/customLayout.cpp @@ -0,0 +1,80 @@ +#include "customLayout.hpp" +#include "../../src/Compositor.hpp" +#include "globals.hpp" + +void CHyprCustomLayout::onWindowCreatedTiling(CWindow* pWindow) { + const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID); + const auto SIZE = PMONITOR->vecSize; + + // these are used for focus and move calculations, and are *required* to touch for moving focus to work properly. + pWindow->m_vPosition = Vector2D{(SIZE.x / 2.0) * (m_vWindowData.size() % 2), (SIZE.y / 2.0) * (int)(m_vWindowData.size() > 1)}; + pWindow->m_vSize = SIZE / 2.0; + + // this is the actual pos and size of the window (where it's rendered) + pWindow->m_vRealPosition = pWindow->m_vPosition + Vector2D{10, 10}; + pWindow->m_vRealSize = pWindow->m_vSize - Vector2D{20, 20}; + + const auto PDATA = &m_vWindowData.emplace_back(); + PDATA->pWindow = pWindow; +} + +void CHyprCustomLayout::onWindowRemovedTiling(CWindow* pWindow) { + std::erase_if(m_vWindowData, [&](const auto& other) { return other.pWindow == pWindow; }); +} + +bool CHyprCustomLayout::isWindowTiled(CWindow* pWindow) { + return std::find_if(m_vWindowData.begin(), m_vWindowData.end(), [&](const auto& other) { return other.pWindow == pWindow; }) != m_vWindowData.end(); +} + +void CHyprCustomLayout::recalculateMonitor(const int& eIdleInhibitMode) { + ; // empty +} + +void CHyprCustomLayout::recalculateWindow(CWindow* pWindow) { + ; // empty +} + +void CHyprCustomLayout::resizeActiveWindow(const Vector2D& delta, CWindow* pWindow) { + ; // empty +} + +void CHyprCustomLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreenMode mode, bool on) { + ; // empty +} + +std::any CHyprCustomLayout::layoutMessage(SLayoutMessageHeader header, std::string content) { + return ""; +} + +SWindowRenderLayoutHints CHyprCustomLayout::requestRenderHints(CWindow* pWindow) { + return {}; +} + +void CHyprCustomLayout::switchWindows(CWindow* pWindowA, CWindow* pWindowB) { + ; // empty +} + +void CHyprCustomLayout::alterSplitRatio(CWindow* pWindow, float delta, bool exact) { + ; // empty +} + +std::string CHyprCustomLayout::getLayoutName() { + return "custom"; +} + +void CHyprCustomLayout::replaceWindowDataWith(CWindow* from, CWindow* to) { + ; // empty +} + +void CHyprCustomLayout::onEnable() { + for (auto& w : g_pCompositor->m_vWindows) { + if (w->isHidden() || !w->m_bIsMapped || w->m_bFadingOut || w->m_bIsFloating) + continue; + + onWindowCreatedTiling(w.get()); + } +} + +void CHyprCustomLayout::onDisable() { + m_vWindowData.clear(); +} \ No newline at end of file diff --git a/example/examplePlugin/customLayout.hpp b/example/examplePlugin/customLayout.hpp new file mode 100644 index 00000000..974882c2 --- /dev/null +++ b/example/examplePlugin/customLayout.hpp @@ -0,0 +1,32 @@ +#pragma once + +#define WLR_USE_UNSTABLE + +#include "../../src/layout/IHyprLayout.hpp" + +struct SWindowData { + CWindow* pWindow = nullptr; +}; + +class CHyprCustomLayout : public IHyprLayout { + public: + virtual void onWindowCreatedTiling(CWindow*); + virtual void onWindowRemovedTiling(CWindow*); + virtual bool isWindowTiled(CWindow*); + virtual void recalculateMonitor(const int&); + virtual void recalculateWindow(CWindow*); + virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr); + virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool); + virtual std::any layoutMessage(SLayoutMessageHeader, std::string); + virtual SWindowRenderLayoutHints requestRenderHints(CWindow*); + virtual void switchWindows(CWindow*, CWindow*); + virtual void alterSplitRatio(CWindow*, float, bool); + virtual std::string getLayoutName(); + virtual void replaceWindowDataWith(CWindow* from, CWindow* to); + + virtual void onEnable(); + virtual void onDisable(); + + private: + std::vector m_vWindowData; +}; \ No newline at end of file diff --git a/hyprtester/plugin/src/globals.hpp b/example/examplePlugin/globals.hpp similarity index 100% rename from hyprtester/plugin/src/globals.hpp rename to example/examplePlugin/globals.hpp diff --git a/example/examplePlugin/main.cpp b/example/examplePlugin/main.cpp new file mode 100644 index 00000000..ef829ae0 --- /dev/null +++ b/example/examplePlugin/main.cpp @@ -0,0 +1,95 @@ +#define WLR_USE_UNSTABLE + +#include "globals.hpp" + +#include +#include +#include "customLayout.hpp" +#include "customDecoration.hpp" + +#include +#include + +// Methods +inline std::unique_ptr g_pCustomLayout; +inline CFunctionHook* g_pFocusHook = nullptr; +inline CFunctionHook* g_pMotionHook = nullptr; +inline CFunctionHook* g_pMouseDownHook = nullptr; +typedef void (*origFocusWindow)(void*, CWindow*, wlr_surface*); +typedef void (*origMotion)(wlr_seat*, uint32_t, double, double); +typedef void (*origMouseDownNormal)(void*, wlr_pointer_button_event*); + +// Do NOT change this function. +APICALL EXPORT std::string PLUGIN_API_VERSION() { + return HYPRLAND_API_VERSION; +} + +static void onActiveWindowChange(void* self, std::any data) { + try { + auto* const PWINDOW = std::any_cast(data); + + HyprlandAPI::addNotification(PHANDLE, "[ExamplePlugin] Active window: " + (PWINDOW ? PWINDOW->m_szTitle : "None"), CColor{0.f, 0.5f, 1.f, 1.f}, 5000); + } catch (std::bad_any_cast& e) { HyprlandAPI::addNotification(PHANDLE, "[ExamplePlugin] Active window: None", CColor{0.f, 0.5f, 1.f, 1.f}, 5000); } +} + +static void onNewWindow(void* self, std::any data) { + auto* const PWINDOW = std::any_cast(data); + + HyprlandAPI::addWindowDecoration(PHANDLE, PWINDOW, new CCustomDecoration(PWINDOW)); +} + +void hkFocusWindow(void* thisptr, CWindow* pWindow, wlr_surface* pSurface) { + // HyprlandAPI::addNotification(PHANDLE, getFormat("FocusWindow with %lx %lx", pWindow, pSurface), CColor{0.f, 1.f, 1.f, 1.f}, 5000); + (*(origFocusWindow)g_pFocusHook->m_pOriginal)(thisptr, pWindow, pSurface); +} + +void hkNotifyMotion(wlr_seat* wlr_seat, uint32_t time_msec, double sx, double sy) { + // HyprlandAPI::addNotification(PHANDLE, getFormat("NotifyMotion with %lf %lf", sx, sy), CColor{0.f, 1.f, 1.f, 1.f}, 5000); + (*(origMotion)g_pMotionHook->m_pOriginal)(wlr_seat, time_msec, sx, sy); +} + +void hkProcessMouseDownNormal(void* thisptr, wlr_pointer_button_event* e) { + // HyprlandAPI::addNotification(PHANDLE, "Mouse down normal!", CColor{0.8f, 0.2f, 0.5f, 1.0f}, 5000); + (*(origMouseDownNormal)g_pMouseDownHook->m_pOriginal)(thisptr, e); +} + +APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { + PHANDLE = handle; + + HyprlandAPI::addNotification(PHANDLE, "Hello World from an example plugin!", CColor{0.f, 1.f, 1.f, 1.f}, 5000); + + HyprlandAPI::registerCallbackDynamic(PHANDLE, "activeWindow", [&](void* self, std::any data) { onActiveWindowChange(self, data); }); + HyprlandAPI::registerCallbackDynamic(PHANDLE, "openWindow", [&](void* self, std::any data) { onNewWindow(self, data); }); + + g_pCustomLayout = std::make_unique(); + + HyprlandAPI::addLayout(PHANDLE, "custom", g_pCustomLayout.get()); + + HyprlandAPI::addConfigValue(PHANDLE, "plugin:example:border_color", SConfigValue{.intValue = configStringToInt("rgb(44ee44)")}); + + HyprlandAPI::addDispatcher(PHANDLE, "example", [](std::string arg) { HyprlandAPI::addNotification(PHANDLE, "Arg passed: " + arg, CColor{0.5f, 0.5f, 0.7f, 1.0f}, 5000); }); + + // Hook a public member + g_pFocusHook = HyprlandAPI::createFunctionHook(PHANDLE, (void*)&CCompositor::focusWindow, (void*)&hkFocusWindow); + // Hook a public non-member + g_pMotionHook = HyprlandAPI::createFunctionHook(PHANDLE, (void*)&wlr_seat_pointer_notify_motion, (void*)&hkNotifyMotion); + // Hook a private member + static const auto METHODS = HyprlandAPI::findFunctionsByName(PHANDLE, "processMouseDownNormal"); + g_pMouseDownHook = HyprlandAPI::createFunctionHook(PHANDLE, METHODS[0].address, (void*)&hkProcessMouseDownNormal); + + // fancy notifications + HyprlandAPI::addNotificationV2(PHANDLE, {{"text", "Example hint"}, {"time", (uint64_t)10000}, {"color", CColor(0.2, 0.2, 0.9, 1.0)}, {"icon", ICON_HINT}}); + + // Enable our hooks + g_pFocusHook->hook(); + g_pMotionHook->hook(); + g_pMouseDownHook->hook(); + + HyprlandAPI::reloadConfig(); + + return {"ExamplePlugin", "An example plugin", "Vaxry", "1.0"}; +} + +APICALL EXPORT void PLUGIN_EXIT() { + HyprlandAPI::invokeHyprctlCommand("seterror", "disable"); +} \ No newline at end of file diff --git a/example/hyprland.conf b/example/hyprland.conf index 15b0e4f7..a896d080 100644 --- a/example/hyprland.conf +++ b/example/hyprland.conf @@ -1,205 +1,28 @@ # This is an example Hyprland config file. +# # Refer to the wiki for more information. -# https://wiki.hypr.land/Configuring/ +# # Please note not all available settings / options are set here. # For a full list, see the wiki +# -# You can split this configuration into multiple files -# Create your files separately and then link them to this file like this: -# source = ~/.config/hypr/myColors.conf - - -################ -### MONITORS ### -################ - -# See https://wiki.hypr.land/Configuring/Monitors/ +# See https://wiki.hyprland.org/Configuring/Monitors/ monitor=,preferred,auto,auto -################### -### MY PROGRAMS ### -################### +# See https://wiki.hyprland.org/Configuring/Keywords/ for more -# See https://wiki.hypr.land/Configuring/Keywords/ - -# Set programs that you use -$terminal = kitty -$fileManager = dolphin -$menu = hyprlauncher - - -################# -### AUTOSTART ### -################# - -# Autostart necessary processes (like notifications daemons, status bars, etc.) -# Or execute your favorite apps at launch like this: - -# exec-once = $terminal -# exec-once = nm-applet & +# Execute your favorite apps at launch # exec-once = waybar & hyprpaper & firefox +# Source a file (multi-file configs) +# source = ~/.config/hypr/myColors.conf -############################# -### ENVIRONMENT VARIABLES ### -############################# - -# See https://wiki.hypr.land/Configuring/Environment-variables/ - +# Some default env vars. env = XCURSOR_SIZE,24 -env = HYPRCURSOR_SIZE,24 - -################### -### PERMISSIONS ### -################### - -# See https://wiki.hypr.land/Configuring/Permissions/ -# Please note permission changes here require a Hyprland restart and are not applied on-the-fly -# for security reasons - -# ecosystem { -# enforce_permissions = 1 -# } - -# permission = /usr/(bin|local/bin)/grim, screencopy, allow -# permission = /usr/(lib|libexec|lib64)/xdg-desktop-portal-hyprland, screencopy, allow -# permission = /usr/(bin|local/bin)/hyprpm, plugin, allow - - -##################### -### LOOK AND FEEL ### -##################### - -# Refer to https://wiki.hypr.land/Configuring/Variables/ - -# https://wiki.hypr.land/Configuring/Variables/#general -general { - gaps_in = 5 - gaps_out = 20 - - border_size = 2 - - # https://wiki.hypr.land/Configuring/Variables/#variable-types for info about colors - col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg - col.inactive_border = rgba(595959aa) - - # Set to true enable resizing windows by clicking and dragging on borders and gaps - resize_on_border = false - - # Please see https://wiki.hypr.land/Configuring/Tearing/ before you turn this on - allow_tearing = false - - layout = dwindle -} - -# https://wiki.hypr.land/Configuring/Variables/#decoration -decoration { - rounding = 10 - rounding_power = 2 - - # Change transparency of focused and unfocused windows - active_opacity = 1.0 - inactive_opacity = 1.0 - - shadow { - enabled = true - range = 4 - render_power = 3 - color = rgba(1a1a1aee) - } - - # https://wiki.hypr.land/Configuring/Variables/#blur - blur { - enabled = true - size = 3 - passes = 1 - - vibrancy = 0.1696 - } -} - -# https://wiki.hypr.land/Configuring/Variables/#animations -animations { - enabled = yes, please :) - - # Default curves, see https://wiki.hypr.land/Configuring/Animations/#curves - # NAME, X0, Y0, X1, Y1 - bezier = easeOutQuint, 0.23, 1, 0.32, 1 - bezier = easeInOutCubic, 0.65, 0.05, 0.36, 1 - bezier = linear, 0, 0, 1, 1 - bezier = almostLinear, 0.5, 0.5, 0.75, 1 - bezier = quick, 0.15, 0, 0.1, 1 - - # Default animations, see https://wiki.hypr.land/Configuring/Animations/ - # NAME, ONOFF, SPEED, CURVE, [STYLE] - animation = global, 1, 10, default - animation = border, 1, 5.39, easeOutQuint - animation = windows, 1, 4.79, easeOutQuint - animation = windowsIn, 1, 4.1, easeOutQuint, popin 87% - animation = windowsOut, 1, 1.49, linear, popin 87% - animation = fadeIn, 1, 1.73, almostLinear - animation = fadeOut, 1, 1.46, almostLinear - animation = fade, 1, 3.03, quick - animation = layers, 1, 3.81, easeOutQuint - animation = layersIn, 1, 4, easeOutQuint, fade - animation = layersOut, 1, 1.5, linear, fade - animation = fadeLayersIn, 1, 1.79, almostLinear - animation = fadeLayersOut, 1, 1.39, almostLinear - animation = workspaces, 1, 1.94, almostLinear, fade - animation = workspacesIn, 1, 1.21, almostLinear, fade - animation = workspacesOut, 1, 1.94, almostLinear, fade - animation = zoomFactor, 1, 7, quick -} - -# Ref https://wiki.hypr.land/Configuring/Workspace-Rules/ -# "Smart gaps" / "No gaps when only" -# uncomment all if you wish to use that. -# workspace = w[tv1], gapsout:0, gapsin:0 -# workspace = f[1], gapsout:0, gapsin:0 -# windowrule { -# name = no-gaps-wtv1 -# match:float = false -# match:workspace = w[tv1] -# -# border_size = 0 -# rounding = 0 -# } -# -# windowrule { -# name = no-gaps-f1 -# match:float = false -# match:workspace = f[1] -# -# border_size = 0 -# rounding = 0 -# } - -# See https://wiki.hypr.land/Configuring/Dwindle-Layout/ for more -dwindle { - pseudotile = true # Master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below - preserve_split = true # You probably want this -} - -# See https://wiki.hypr.land/Configuring/Master-Layout/ for more -master { - new_status = master -} - -# https://wiki.hypr.land/Configuring/Variables/#misc -misc { - force_default_wallpaper = -1 # Set to 0 or 1 to disable the anime mascot wallpapers - disable_hyprland_logo = false # If true disables the random hyprland logo / anime girl background. :( -} - - -############# -### INPUT ### -############# - -# https://wiki.hypr.land/Configuring/Variables/#input +# For all categories, see https://wiki.hyprland.org/Configuring/Variables/ input { kb_layout = us kb_variant = @@ -209,40 +32,96 @@ input { follow_mouse = 1 - sensitivity = 0 # -1.0 - 1.0, 0 means no modification. - touchpad { natural_scroll = false } + + sensitivity = 0 # -1.0 - 1.0, 0 means no modification. } -# See https://wiki.hypr.land/Configuring/Gestures -gesture = 3, horizontal, workspace +general { + # See https://wiki.hyprland.org/Configuring/Variables/ for more + + gaps_in = 5 + gaps_out = 20 + border_size = 2 + col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg + col.inactive_border = rgba(595959aa) + + layout = dwindle +} + +decoration { + # See https://wiki.hyprland.org/Configuring/Variables/ for more + + rounding = 10 + blur = true + blur_size = 3 + blur_passes = 1 + blur_new_optimizations = true + + drop_shadow = true + shadow_range = 4 + shadow_render_power = 3 + col.shadow = rgba(1a1a1aee) +} + +animations { + enabled = true + + # Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more + + bezier = myBezier, 0.05, 0.9, 0.1, 1.05 + + animation = windows, 1, 7, myBezier + animation = windowsOut, 1, 7, default, popin 80% + animation = border, 1, 10, default + animation = borderangle, 1, 8, default + animation = fade, 1, 7, default + animation = workspaces, 1, 6, default +} + +dwindle { + # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more + pseudotile = true # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below + preserve_split = true # you probably want this +} + +master { + # See https://wiki.hyprland.org/Configuring/Master-Layout/ for more + new_is_master = true +} + +gestures { + # See https://wiki.hyprland.org/Configuring/Variables/ for more + workspace_swipe = false +} # Example per-device config -# See https://wiki.hypr.land/Configuring/Keywords/#per-device-input-configs for more -device { - name = epic-mouse-v1 +# See https://wiki.hyprland.org/Configuring/Keywords/#executing for more +device:epic-mouse-v1 { sensitivity = -0.5 } +# Example windowrule v1 +# windowrule = float, ^(kitty)$ +# Example windowrule v2 +# windowrulev2 = float,class:^(kitty)$,title:^(kitty)$ +# See https://wiki.hyprland.org/Configuring/Window-Rules/ for more -################### -### KEYBINDINGS ### -################### -# See https://wiki.hypr.land/Configuring/Keywords/ -$mainMod = SUPER # Sets "Windows" key as main modifier +# See https://wiki.hyprland.org/Configuring/Keywords/ for more +$mainMod = SUPER -# Example binds, see https://wiki.hypr.land/Configuring/Binds/ for more -bind = $mainMod, Q, exec, $terminal +# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more +bind = $mainMod, Q, exec, kitty bind = $mainMod, C, killactive, -bind = $mainMod, M, exec, command -v hyprshutdown >/dev/null 2>&1 && hyprshutdown || hyprctl dispatch exit -bind = $mainMod, E, exec, $fileManager +bind = $mainMod, M, exit, +bind = $mainMod, E, exec, dolphin bind = $mainMod, V, togglefloating, -bind = $mainMod, R, exec, $menu +bind = $mainMod, R, exec, wofi --show drun bind = $mainMod, P, pseudo, # dwindle -bind = $mainMod, J, layoutmsg, togglesplit # dwindle +bind = $mainMod, J, togglesplit, # dwindle # Move focus with mainMod + arrow keys bind = $mainMod, left, movefocus, l @@ -274,10 +153,6 @@ bind = $mainMod SHIFT, 8, movetoworkspace, 8 bind = $mainMod SHIFT, 9, movetoworkspace, 9 bind = $mainMod SHIFT, 0, movetoworkspace, 10 -# Example special workspace (scratchpad) -bind = $mainMod, S, togglespecialworkspace, magic -bind = $mainMod SHIFT, S, movetoworkspace, special:magic - # Scroll through existing workspaces with mainMod + scroll bind = $mainMod, mouse_down, workspace, e+1 bind = $mainMod, mouse_up, workspace, e-1 @@ -285,57 +160,3 @@ bind = $mainMod, mouse_up, workspace, e-1 # Move/resize windows with mainMod + LMB/RMB and dragging bindm = $mainMod, mouse:272, movewindow bindm = $mainMod, mouse:273, resizewindow - -# Laptop multimedia keys for volume and LCD brightness -bindel = ,XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ -bindel = ,XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- -bindel = ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle -bindel = ,XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle -bindel = ,XF86MonBrightnessUp, exec, brightnessctl -e4 -n2 set 5%+ -bindel = ,XF86MonBrightnessDown, exec, brightnessctl -e4 -n2 set 5%- - -# Requires playerctl -bindl = , XF86AudioNext, exec, playerctl next -bindl = , XF86AudioPause, exec, playerctl play-pause -bindl = , XF86AudioPlay, exec, playerctl play-pause -bindl = , XF86AudioPrev, exec, playerctl previous - -############################## -### WINDOWS AND WORKSPACES ### -############################## - -# See https://wiki.hypr.land/Configuring/Window-Rules/ for more -# See https://wiki.hypr.land/Configuring/Workspace-Rules/ for workspace rules - -# Example windowrules that are useful - -windowrule { - # Ignore maximize requests from all apps. You'll probably like this. - name = suppress-maximize-events - match:class = .* - - suppress_event = maximize -} - -windowrule { - # Fix some dragging issues with XWayland - name = fix-xwayland-drags - match:class = ^$ - match:title = ^$ - match:xwayland = true - match:float = true - match:fullscreen = false - match:pin = false - - no_focus = true -} - -# Hyprland-run windowrule -windowrule { - name = move-hyprland-run - - match:class = hyprland-run - - move = 20 monitor_h-120 - float = yes -} diff --git a/example/hyprland.desktop b/example/hyprland.desktop new file mode 100644 index 00000000..57ad076f --- /dev/null +++ b/example/hyprland.desktop @@ -0,0 +1,5 @@ +[Desktop Entry] +Name=Hyprland +Comment=An intelligent dynamic tiling Wayland compositor +Exec=Hyprland +Type=Application \ No newline at end of file diff --git a/example/hyprland.desktop.in b/example/hyprland.desktop.in deleted file mode 100644 index d8e87d60..00000000 --- a/example/hyprland.desktop.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -Name=Hyprland -Comment=An intelligent dynamic tiling Wayland compositor -Exec=@PREFIX@/@CMAKE_INSTALL_BINDIR@/start-hyprland -Type=Application -DesktopNames=Hyprland -Keywords=tiling;wayland;compositor; diff --git a/example/launch.json b/example/launch.json index e60cc900..c47bdb72 100644 --- a/example/launch.json +++ b/example/launch.json @@ -22,6 +22,5 @@ } ] }, - ] } \ No newline at end of file diff --git a/example/meson.build b/example/meson.build new file mode 100644 index 00000000..ccfc4e00 --- /dev/null +++ b/example/meson.build @@ -0,0 +1,2 @@ +install_data('hyprland.conf', install_dir: join_paths(get_option('datadir'), 'hyprland'), install_tag: 'runtime') +install_data('hyprland.desktop', install_dir: join_paths(get_option('datadir'), 'wayland-sessions'), install_tag: 'runtime') diff --git a/example/screenShader.frag b/example/screenShader.frag index 71598e51..5eeac17a 100644 --- a/example/screenShader.frag +++ b/example/screenShader.frag @@ -1,19 +1,16 @@ // // Example blue light filter shader. -// - -#version 300 es +// precision mediump float; -in vec2 v_texcoord; -layout(location = 0) out vec4 fragColor; +varying vec2 v_texcoord; uniform sampler2D tex; void main() { - vec4 pixColor = texture(tex, v_texcoord); + vec4 pixColor = texture2D(tex, v_texcoord); pixColor[2] *= 0.8; - fragColor = pixColor; + gl_FragColor = pixColor; } diff --git a/flake.lock b/flake.lock index 4a89c0fc..cf742942 100644 --- a/flake.lock +++ b/flake.lock @@ -1,177 +1,17 @@ { "nodes": { - "aquamarine": { - "inputs": { - "hyprutils": [ - "hyprutils" - ], - "hyprwayland-scanner": [ - "hyprwayland-scanner" - ], - "nixpkgs": [ - "nixpkgs" - ], - "systems": [ - "systems" - ] - }, - "locked": { - "lastModified": 1772292445, - "narHash": "sha256-4F1Q7U313TKUDDovCC96m/Za4wZcJ3yqtu4eSrj8lk8=", - "owner": "hyprwm", - "repo": "aquamarine", - "rev": "1dbbba659c1cef0b0202ce92cadfe13bae550e8f", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "aquamarine", - "type": "github" - } - }, - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1767039857, - "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", - "owner": "NixOS", - "repo": "flake-compat", - "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "flake-compat", - "type": "github" - } - }, - "gitignore": { - "inputs": { - "nixpkgs": [ - "pre-commit-hooks", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1709087332, - "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, - "hyprcursor": { - "inputs": { - "hyprlang": [ - "hyprlang" - ], - "nixpkgs": [ - "nixpkgs" - ], - "systems": [ - "systems" - ] - }, - "locked": { - "lastModified": 1753964049, - "narHash": "sha256-lIqabfBY7z/OANxHoPeIrDJrFyYy9jAM4GQLzZ2feCM=", - "owner": "hyprwm", - "repo": "hyprcursor", - "rev": "44e91d467bdad8dcf8bbd2ac7cf49972540980a5", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprcursor", - "type": "github" - } - }, - "hyprgraphics": { - "inputs": { - "hyprutils": [ - "hyprutils" - ], - "nixpkgs": [ - "nixpkgs" - ], - "systems": [ - "systems" - ] - }, - "locked": { - "lastModified": 1770511807, - "narHash": "sha256-suKmSbSk34uPOJDTg/GbPrKEJutzK08vj0VoTvAFBCA=", - "owner": "hyprwm", - "repo": "hyprgraphics", - "rev": "7c75487edd43a71b61adb01cae8326d277aab683", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprgraphics", - "type": "github" - } - }, - "hyprland-guiutils": { - "inputs": { - "aquamarine": [ - "aquamarine" - ], - "hyprgraphics": [ - "hyprgraphics" - ], - "hyprlang": [ - "hyprlang" - ], - "hyprtoolkit": "hyprtoolkit", - "hyprutils": [ - "hyprutils" - ], - "hyprwayland-scanner": [ - "hyprwayland-scanner" - ], - "nixpkgs": [ - "nixpkgs" - ], - "systems": [ - "systems" - ] - }, - "locked": { - "lastModified": 1767023960, - "narHash": "sha256-R2HgtVS1G3KSIKAQ77aOZ+Q0HituOmPgXW9nBNkpp3Q=", - "owner": "hyprwm", - "repo": "hyprland-guiutils", - "rev": "c2e906261142f5dd1ee0bfc44abba23e2754c660", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprland-guiutils", - "type": "github" - } - }, "hyprland-protocols": { "inputs": { "nixpkgs": [ "nixpkgs" - ], - "systems": [ - "systems" ] }, "locked": { - "lastModified": 1765214753, - "narHash": "sha256-P9zdGXOzToJJgu5sVjv7oeOGPIIwrd9hAUAP3PsmBBs=", + "lastModified": 1681065697, + "narHash": "sha256-QPzwwlGKX95tl6ZEshboZbEwwAXww6lNLdVYd6T9Mrc=", "owner": "hyprwm", "repo": "hyprland-protocols", - "rev": "3f3860b869014c00e8b9e0528c7b4ddc335c21ab", + "rev": "4d29e48433270a2af06b8bc711ca1fe5109746cd", "type": "github" }, "original": { @@ -180,156 +20,13 @@ "type": "github" } }, - "hyprlang": { - "inputs": { - "hyprutils": [ - "hyprutils" - ], - "nixpkgs": [ - "nixpkgs" - ], - "systems": [ - "systems" - ] - }, - "locked": { - "lastModified": 1771866172, - "narHash": "sha256-fYFoXhQLrm1rD8vSFKQBOEX4OGCuJdLt1amKfHd5GAw=", - "owner": "hyprwm", - "repo": "hyprlang", - "rev": "0b219224910e7642eb0ed49f0db5ec3d008e3e41", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprlang", - "type": "github" - } - }, - "hyprtoolkit": { - "inputs": { - "aquamarine": [ - "hyprland-guiutils", - "aquamarine" - ], - "hyprgraphics": [ - "hyprland-guiutils", - "hyprgraphics" - ], - "hyprlang": [ - "hyprland-guiutils", - "hyprlang" - ], - "hyprutils": [ - "hyprland-guiutils", - "hyprutils" - ], - "hyprwayland-scanner": [ - "hyprland-guiutils", - "hyprwayland-scanner" - ], - "nixpkgs": [ - "hyprland-guiutils", - "nixpkgs" - ], - "systems": [ - "hyprland-guiutils", - "systems" - ] - }, - "locked": { - "lastModified": 1764592794, - "narHash": "sha256-7CcO+wbTJ1L1NBQHierHzheQGPWwkIQug/w+fhTAVuU=", - "owner": "hyprwm", - "repo": "hyprtoolkit", - "rev": "5cfe0743f0e608e1462972303778d8a0859ee63e", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprtoolkit", - "type": "github" - } - }, - "hyprutils": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ], - "systems": [ - "systems" - ] - }, - "locked": { - "lastModified": 1771271487, - "narHash": "sha256-41gEiUS0Pyw3L/ge1l8MXn61cK14VAhgWB/JV8s/oNI=", - "owner": "hyprwm", - "repo": "hyprutils", - "rev": "340a792e3b3d482c4ae5f66d27a9096bdee6d76d", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprutils", - "type": "github" - } - }, - "hyprwayland-scanner": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ], - "systems": [ - "systems" - ] - }, - "locked": { - "lastModified": 1770501770, - "narHash": "sha256-NWRM6+YxTRv+bT9yvlhhJ2iLae1B1pNH3mAL5wi2rlQ=", - "owner": "hyprwm", - "repo": "hyprwayland-scanner", - "rev": "0bd8b6cde9ec27d48aad9e5b4deefb3746909d40", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprwayland-scanner", - "type": "github" - } - }, - "hyprwire": { - "inputs": { - "hyprutils": [ - "hyprutils" - ], - "nixpkgs": [ - "nixpkgs" - ], - "systems": [ - "systems" - ] - }, - "locked": { - "lastModified": 1771606233, - "narHash": "sha256-F3PLUqQ/TwgR70U+UeOqJnihJZ2EuunzojYC4g5xHr0=", - "owner": "hyprwm", - "repo": "hyprwire", - "rev": "06c7f1f8c4194786c8400653c4efc49dc14c0f3a", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprwire", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1772198003, - "narHash": "sha256-I45esRSssFtJ8p/gLHUZ1OUaaTaVLluNkABkk6arQwE=", + "lastModified": 1683014792, + "narHash": "sha256-6Va9iVtmmsw4raBc3QKvQT2KT/NGRWlvUlJj46zN8B8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "dd9b079222d43e1943b6ebd802f04fd959dc8e61", + "rev": "1a411f23ba299db155a5b45d5e145b85a7aafc42", "type": "github" }, "original": { @@ -339,58 +36,30 @@ "type": "github" } }, - "pre-commit-hooks": { - "inputs": { - "flake-compat": "flake-compat", - "gitignore": "gitignore", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1772024342, - "narHash": "sha256-+eXlIc4/7dE6EcPs9a2DaSY3fTA9AE526hGqkNID3Wg=", - "owner": "cachix", - "repo": "git-hooks.nix", - "rev": "6e34e97ed9788b17796ee43ccdbaf871a5c2b476", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "git-hooks.nix", - "type": "github" - } - }, "root": { "inputs": { - "aquamarine": "aquamarine", - "hyprcursor": "hyprcursor", - "hyprgraphics": "hyprgraphics", - "hyprland-guiutils": "hyprland-guiutils", "hyprland-protocols": "hyprland-protocols", - "hyprlang": "hyprlang", - "hyprutils": "hyprutils", - "hyprwayland-scanner": "hyprwayland-scanner", - "hyprwire": "hyprwire", "nixpkgs": "nixpkgs", - "pre-commit-hooks": "pre-commit-hooks", - "systems": "systems", + "wlroots": "wlroots", "xdph": "xdph" } }, - "systems": { + "wlroots": { + "flake": false, "locked": { - "lastModified": 1689347949, - "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", - "owner": "nix-systems", - "repo": "default-linux", - "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", - "type": "github" + "host": "gitlab.freedesktop.org", + "lastModified": 1682436395, + "narHash": "sha256-GGEjkQO9m7YLYIXIXM76HWdhjg4Ye+oafOtyaFAYKI4=", + "owner": "wlroots", + "repo": "wlroots", + "rev": "6830bfc17fd94709e2cdd4da0af989f102a26e59", + "type": "gitlab" }, "original": { - "owner": "nix-systems", - "repo": "default-linux", - "type": "github" + "host": "gitlab.freedesktop.org", + "owner": "wlroots", + "repo": "wlroots", + "type": "gitlab" } }, "xdph": { @@ -398,28 +67,16 @@ "hyprland-protocols": [ "hyprland-protocols" ], - "hyprlang": [ - "hyprlang" - ], - "hyprutils": [ - "hyprutils" - ], - "hyprwayland-scanner": [ - "hyprwayland-scanner" - ], "nixpkgs": [ "nixpkgs" - ], - "systems": [ - "systems" ] }, "locked": { - "lastModified": 1761431178, - "narHash": "sha256-xzjC1CV3+wpUQKNF+GnadnkeGUCJX+vgaWIZsnz9tzI=", + "lastModified": 1682439384, + "narHash": "sha256-zHDa8LCZs05TZHQSIZ3ucwyMPglBGHcqTBzfkLjYXTM=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "4b8801228ff958d028f588f0c2b911dbf32297f9", + "rev": "c0e233955568fbea4e859336f6d3d14d51294d7c", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 6d695bfb..cbabc558 100644 --- a/flake.nix +++ b/flake.nix @@ -4,206 +4,91 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - # - systems.url = "github:nix-systems/default-linux"; - - aquamarine = { - url = "github:hyprwm/aquamarine"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.systems.follows = "systems"; - inputs.hyprutils.follows = "hyprutils"; - inputs.hyprwayland-scanner.follows = "hyprwayland-scanner"; - }; - - hyprcursor = { - url = "github:hyprwm/hyprcursor"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.systems.follows = "systems"; - inputs.hyprlang.follows = "hyprlang"; - }; - - hyprgraphics = { - url = "github:hyprwm/hyprgraphics"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.systems.follows = "systems"; - inputs.hyprutils.follows = "hyprutils"; + wlroots = { + url = "gitlab:wlroots/wlroots?host=gitlab.freedesktop.org"; + flake = false; }; hyprland-protocols = { url = "github:hyprwm/hyprland-protocols"; inputs.nixpkgs.follows = "nixpkgs"; - inputs.systems.follows = "systems"; - }; - - hyprland-guiutils = { - url = "github:hyprwm/hyprland-guiutils"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.systems.follows = "systems"; - inputs.aquamarine.follows = "aquamarine"; - inputs.hyprgraphics.follows = "hyprgraphics"; - inputs.hyprutils.follows = "hyprutils"; - inputs.hyprlang.follows = "hyprlang"; - inputs.hyprwayland-scanner.follows = "hyprwayland-scanner"; - }; - - hyprlang = { - url = "github:hyprwm/hyprlang"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.systems.follows = "systems"; - inputs.hyprutils.follows = "hyprutils"; - }; - - hyprutils = { - url = "github:hyprwm/hyprutils"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.systems.follows = "systems"; - }; - - hyprwayland-scanner = { - url = "github:hyprwm/hyprwayland-scanner"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.systems.follows = "systems"; - }; - - hyprwire = { - url = "github:hyprwm/hyprwire"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.systems.follows = "systems"; - inputs.hyprutils.follows = "hyprutils"; }; xdph = { url = "github:hyprwm/xdg-desktop-portal-hyprland"; inputs.nixpkgs.follows = "nixpkgs"; - inputs.systems.follows = "systems"; inputs.hyprland-protocols.follows = "hyprland-protocols"; - inputs.hyprlang.follows = "hyprlang"; - inputs.hyprutils.follows = "hyprutils"; - inputs.hyprwayland-scanner.follows = "hyprwayland-scanner"; - }; - - pre-commit-hooks = { - url = "github:cachix/git-hooks.nix"; - inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = - inputs@{ - self, - nixpkgs, - systems, - ... - }: - let - inherit (nixpkgs) lib; - eachSystem = lib.genAttrs (import systems); - pkgsFor = eachSystem ( - system: - import nixpkgs { - localSystem = system; - overlays = with self.overlays; [ - hyprland-packages - hyprland-extras - ]; - } - ); - pkgsCrossFor = eachSystem ( - system: crossSystem: - import nixpkgs { - localSystem = system; - inherit crossSystem; - overlays = with self.overlays; [ - hyprland-packages - hyprland-extras - ]; - } - ); - pkgsDebugFor = eachSystem ( - system: - import nixpkgs { - localSystem = system; - overlays = with self.overlays; [ - hyprland-debug - ]; - } - ); - pkgsDebugCrossFor = eachSystem ( - system: crossSystem: - import nixpkgs { - localSystem = system; - inherit crossSystem; - overlays = with self.overlays; [ - hyprland-debug - ]; - } - ); - in - { - overlays = import ./nix/overlays.nix { inherit self lib inputs; }; + outputs = inputs @ { + self, + nixpkgs, + ... + }: let + lib = nixpkgs.lib.extend (import ./nix/lib.nix); + genSystems = lib.genAttrs [ + # Add more systems if they are supported + "aarch64-linux" + "x86_64-linux" + ]; - checks = eachSystem ( - system: - (lib.filterAttrs ( - n: _: (lib.hasPrefix "hyprland" n) && !(lib.hasSuffix "debug" n) - ) self.packages.${system}) - // { - inherit (self.packages.${system}) xdg-desktop-portal-hyprland; - pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run { - src = ./.; - hooks = { - hyprland-treewide-formatter = { - enable = true; - entry = "${self.formatter.${system}}/bin/hyprland-treewide-formatter"; - pass_filenames = false; - excludes = [ "subprojects" ]; - always_run = true; - }; - }; - }; - } - // (import ./nix/tests inputs pkgsFor.${system}) - ); - - packages = eachSystem (system: { - default = self.packages.${system}.hyprland; - inherit (pkgsFor.${system}) - # hyprland-packages - hyprland - hyprland-unwrapped - hyprland-with-tests - # hyprland-extras - xdg-desktop-portal-hyprland - ; - inherit (pkgsDebugFor.${system}) hyprland-debug; - hyprland-cross = (pkgsCrossFor.${system} "aarch64-linux").hyprland; - hyprland-debug-cross = (pkgsDebugCrossFor.${system} "aarch64-linux").hyprland-debug; + pkgsFor = genSystems (system: + import nixpkgs { + inherit system; + overlays = [ + self.overlays.hyprland-packages + self.overlays.wlroots-hyprland + inputs.hyprland-protocols.overlays.default + ]; }); - - devShells = eachSystem (system: { + in { + overlays = + (import ./nix/overlays.nix {inherit self lib inputs;}) + // { default = - pkgsFor.${system}.mkShell.override - { - inherit (self.packages.${system}.default) stdenv; - } - { - name = "hyprland-shell"; - hardeningDisable = [ "fortify" ]; - inputsFrom = [ pkgsFor.${system}.hyprland ]; - packages = [ pkgsFor.${system}.clang-tools ]; - inherit (self.checks.${system}.pre-commit-check) shellHook; - }; + lib.mkJoinedOverlays + (with self.overlays; [ + hyprland-packages + hyprland-extras + wlroots-hyprland + ]); + }; + + checks = genSystems (system: + (lib.filterAttrs + (n: _: (lib.hasPrefix "hyprland" n) && !(lib.hasSuffix "debug" n)) + self.packages.${system}) + // { + inherit (self.packages.${system}) xdg-desktop-portal-hyprland; }); - formatter = eachSystem (system: pkgsFor.${system}.callPackage ./nix/formatter.nix { }); + packages = genSystems (system: + (self.overlays.default pkgsFor.${system} pkgsFor.${system}) + // { + default = self.packages.${system}.hyprland; + }); - nixosModules.default = import ./nix/module.nix inputs; - homeManagerModules.default = import ./nix/hm-module.nix self; + devShells = genSystems (system: { + default = pkgsFor.${system}.mkShell { + name = "hyprland-shell"; + nativeBuildInputs = with pkgsFor.${system}; [cmake]; + buildInputs = [self.packages.${system}.wlroots-hyprland]; + inputsFrom = [ + self.packages.${system}.wlroots-hyprland + self.packages.${system}.hyprland + ]; + }; + }); - # Hydra build jobs - # Recent versions of Hydra can aggregate jobsets from 'hydraJobs' instead of a release.nix - # or similar. Remember to filter large or incompatible attributes here. More eval jobs can - # be added by merging, e.g., self.packages // self.devShells. - hydraJobs = self.packages; - }; + formatter = genSystems (system: pkgsFor.${system}.alejandra); + + nixosModules.default = import ./nix/module.nix inputs; + homeManagerModules.default = import ./nix/hm-module.nix self; + }; + + nixConfig = { + extra-substituters = ["https://hyprland.cachix.org"]; + extra-trusted-public-keys = ["hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="]; + }; } diff --git a/hyprctl/CMakeLists.txt b/hyprctl/CMakeLists.txt deleted file mode 100644 index 7071ede9..00000000 --- a/hyprctl/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -cmake_minimum_required(VERSION 3.19) - -project( - hyprctl - DESCRIPTION "Control utility for Hyprland" -) - -pkg_check_modules(hyprctl_deps REQUIRED IMPORTED_TARGET hyprutils>=0.2.4 hyprwire re2) - -file(GLOB_RECURSE HYPRCTL_SRCFILES CONFIGURE_DEPENDS "src/*.cpp" "hw-protocols/*.cpp" "include/*.hpp") - -add_executable(hyprctl ${HYPRCTL_SRCFILES}) - -target_link_libraries(hyprctl PUBLIC PkgConfig::hyprctl_deps) -target_include_directories(hyprctl PRIVATE "hw-protocols") - -# Hyprwire - -function(hyprprotocol protoPath protoName) - set(path ${CMAKE_CURRENT_SOURCE_DIR}/${protoPath}) - add_custom_command( - OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/${protoName}-client.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/${protoName}-client.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/${protoName}-spec.hpp - COMMAND hyprwire-scanner --client ${path}/${protoName}.xml - ${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/ - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - target_sources(hyprctl PRIVATE hw-protocols/${protoName}-client.cpp - hw-protocols/${protoName}-client.hpp - hw-protocols/${protoName}-spec.hpp) -endfunction() - -hyprprotocol(hw-protocols hyprpaper_core) - -# binary -install(TARGETS hyprctl) - -# shell completions -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/hyprctl.bash - DESTINATION ${CMAKE_INSTALL_DATADIR}/bash-completion/completions - RENAME hyprctl) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/hyprctl.fish - DESTINATION ${CMAKE_INSTALL_DATADIR}/fish/vendor_completions.d) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/hyprctl.zsh - DESTINATION ${CMAKE_INSTALL_DATADIR}/zsh/site-functions - RENAME _hyprctl) diff --git a/hyprctl/Makefile b/hyprctl/Makefile new file mode 100644 index 00000000..ec819918 --- /dev/null +++ b/hyprctl/Makefile @@ -0,0 +1,4 @@ +all: + $(CXX) -std=c++2b ./main.cpp -o ./hyprctl +clean: + rm ./hyprctl diff --git a/hyprctl/hw-protocols/hyprpaper_core.xml b/hyprctl/hw-protocols/hyprpaper_core.xml deleted file mode 100644 index 3d26a102..00000000 --- a/hyprctl/hw-protocols/hyprpaper_core.xml +++ /dev/null @@ -1,172 +0,0 @@ - - - - BSD 3-Clause License - - Copyright (c) 2025, Hypr Development - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - - - This is the core manager object for hyprpaper operations - - - - - Creates a wallpaper object - - - - - - - Emitted when a new monitor is added. - - - - - - - Emitted when a monitor is removed. - - - - - - - Destroys this object. Children remain alive until destroyed. - - - - - - Creates a status object - - - - - - - - - - - - - - - - - - - - - - - - - This is an object describing a wallpaper - - - - - Set a file path for the wallpaper. This has to be an absolute path from the fs root. - This is required. - - - - - - - Set a fit mode for the wallpaper. This is set to cover by default. - - - - - - - Set a monitor for the wallpaper. Setting this to empty (or not setting at all) will - treat this as a wildcard fallback. - - See hyprpaper_core_manager.add_monitor and hyprpaper_core_manager.remove_monitor - for tracking monitor names. - - - - - - - Applies this object's state to the wallpaper state. Will emit .success on success, - and .failed on failure. - - This object becomes inert after .succeess or .failed, the only valid operation - is to destroy it afterwards. - - - - - - Wallpaper was applied successfully. - - - - - - Wallpaper was not applied. See the error field for more information. - - - - - - - Destroys this object. - - - - - - - This is an object which will emit various status updates. - - - - - Sends the active wallpaper for a given monitor. This will be emitted - immediately after binding, and then every time the path changes. - - - - - - - - Destroys this object. - - - - diff --git a/hyprctl/hyprctl.bash b/hyprctl/hyprctl.bash deleted file mode 100644 index ba541653..00000000 --- a/hyprctl/hyprctl.bash +++ /dev/null @@ -1,128 +0,0 @@ -_hyprctl_cmd_1 () { - hyprctl monitors | awk '/Monitor/{ print $2 }' -} - -_hyprctl_cmd_3 () { - hyprctl clients | awk '/class/{print $2}' -} - -_hyprctl_cmd_2 () { - hyprctl devices | sed -n '/Keyboard at/{n; s/^\s\+//; p}' -} - -_hyprctl_cmd_0 () { - hyprpm list | awk '/Plugin/{print $4}' -} - -_hyprctl () { - if [[ $(type -t _get_comp_words_by_ref) != function ]]; then - echo _get_comp_words_by_ref: function not defined. Make sure the bash-completions system package is installed - return 1 - fi - - local words cword - _get_comp_words_by_ref -n "$COMP_WORDBREAKS" words cword - - declare -a literals=(resizeactive 2 changegroupactive -r moveintogroup forceallowsinput 4 ::= systeminfo all layouts setprop animationstyle switchxkblayout create denywindowfromgroup headless activebordercolor exec setcursor wayland focusurgentorlast workspacerules movecurrentworkspacetomonitor movetoworkspacesilent hyprpaper alpha inactivebordercolor movegroupwindow movecursortocorner movewindowpixel prev movewindow globalshortcuts clients dimaround setignoregrouplock splash execr monitors 0 forcenoborder -q animations 1 nomaxsize splitratio moveactive pass swapnext devices layers rounding lockactivegroup 5 moveworkspacetomonitor -f -i --quiet forcenodim pin 0 1 forceopaque forcenoshadow setfloating minsize alphaoverride sendshortcut workspaces cyclenext alterzorder togglegroup lockgroups bordersize dpms focuscurrentorlast -1 --batch notify remove instances 1 3 moveoutofgroup killactive 2 movetoworkspace movecursor configerrors closewindow swapwindow tagwindow forcerendererreload centerwindow auto focuswindow seterror nofocus alphafullscreen binds version -h togglespecialworkspace fullscreen windowdancecompat 0 keyword toggleopaque 3 --instance togglefloating renameworkspace alphafullscreenoverride activeworkspace x11 kill forceopaqueoverriden output global dispatch reload forcenoblur -j event --help disable -1 activewindow keepaspectratio dismissnotify focusmonitor movefocus plugin exit workspace fullscreenstate getoption alphainactiveoverride alphainactive decorations settiled config-only descriptions resizewindowpixel fakefullscreen rollinglog swapactiveworkspaces submap next movewindoworgroup cursorpos forcenoanims focusworkspaceoncurrentmonitor maxsize sendkeystate) - declare -A literal_transitions - literal_transitions[0]="([120]=14 [43]=2 [125]=21 [81]=2 [3]=21 [51]=2 [50]=2 [128]=2 [89]=2 [58]=21 [8]=2 [10]=2 [11]=3 [130]=4 [13]=5 [97]=6 [101]=2 [102]=21 [133]=7 [100]=2 [137]=2 [22]=2 [19]=2 [140]=8 [25]=2 [143]=2 [107]=9 [146]=10 [69]=2 [33]=2 [34]=2 [78]=21 [114]=2 [37]=2 [151]=2 [116]=2 [121]=13 [123]=21 [39]=11 [42]=21 [79]=15 [118]=12)" - literal_transitions[1]="([81]=2 [51]=2 [50]=2 [128]=2 [8]=2 [89]=2 [10]=2 [11]=3 [130]=4 [13]=5 [97]=6 [101]=2 [133]=7 [100]=2 [22]=2 [19]=2 [137]=2 [140]=8 [25]=2 [143]=2 [107]=9 [146]=10 [69]=2 [33]=2 [34]=2 [114]=2 [37]=2 [151]=2 [116]=2 [39]=11 [118]=12 [121]=13 [120]=14 [79]=15 [43]=2)" - literal_transitions[3]="([139]=2 [63]=16 [64]=16 [45]=16 [105]=16 [27]=2 [26]=2 [52]=4 [5]=16 [66]=2 [67]=16 [129]=16 [113]=16 [12]=2 [74]=4 [99]=2 [35]=16 [152]=16 [98]=16 [59]=16 [117]=16 [41]=16 [17]=2 [138]=16 [154]=2 [122]=16)" - literal_transitions[6]="([126]=2)" - literal_transitions[10]="([56]=2)" - literal_transitions[11]="([9]=2)" - literal_transitions[12]="([14]=19 [80]=22)" - literal_transitions[13]="([142]=2)" - literal_transitions[14]="([0]=2 [84]=2 [2]=2 [85]=2 [4]=2 [87]=2 [88]=2 [90]=2 [91]=2 [92]=2 [93]=2 [94]=2 [96]=2 [15]=2 [18]=2 [103]=2 [21]=2 [104]=2 [23]=2 [24]=2 [28]=2 [29]=2 [30]=2 [108]=2 [111]=2 [32]=2 [112]=2 [36]=2 [38]=2 [119]=2 [124]=2 [46]=2 [47]=2 [48]=2 [49]=2 [53]=2 [55]=2 [131]=2 [132]=2 [134]=2 [135]=2 [60]=2 [136]=20 [141]=2 [65]=2 [144]=2 [145]=2 [68]=2 [147]=2 [70]=2 [71]=2 [72]=2 [73]=2 [148]=2 [75]=2 [76]=2 [150]=2 [153]=2)" - literal_transitions[15]="([86]=4 [6]=4 [109]=4 [61]=4 [77]=4 [54]=4 [62]=4)" - literal_transitions[16]="([40]=2 [44]=2)" - literal_transitions[17]="([7]=23)" - literal_transitions[18]="([31]=2 [149]=2)" - literal_transitions[19]="([95]=2 [16]=2 [115]=2 [20]=2)" - literal_transitions[20]="([106]=2 [82]=2 [127]=2 [1]=2 [83]=2)" - literal_transitions[23]="([57]=21 [110]=21)" - declare -A match_anything_transitions=([6]=17 [7]=2 [0]=1 [22]=2 [5]=18 [4]=2 [2]=17 [18]=2 [11]=17 [8]=2 [9]=2 [13]=17 [10]=17 [1]=1) - declare -A subword_transitions - - local state=0 - local word_index=1 - while [[ $word_index -lt $cword ]]; do - local word=${words[$word_index]} - - if [[ -v "literal_transitions[$state]" ]]; then - declare -A state_transitions - eval "state_transitions=${literal_transitions[$state]}" - - local word_matched=0 - for literal_id in $(seq 0 $((${#literals[@]} - 1))); do - if [[ ${literals[$literal_id]} = "$word" ]]; then - if [[ -v "state_transitions[$literal_id]" ]]; then - state=${state_transitions[$literal_id]} - word_index=$((word_index + 1)) - word_matched=1 - break - fi - fi - done - if [[ $word_matched -ne 0 ]]; then - continue - fi - fi - - if [[ -v "match_anything_transitions[$state]" ]]; then - state=${match_anything_transitions[$state]} - word_index=$((word_index + 1)) - continue - fi - - return 1 - done - - - local -a matches=() - - local prefix="${words[$cword]}" - if [[ -v "literal_transitions[$state]" ]]; then - local state_transitions_initializer=${literal_transitions[$state]} - declare -A state_transitions - eval "state_transitions=$state_transitions_initializer" - - for literal_id in "${!state_transitions[@]}"; do - local literal="${literals[$literal_id]}" - if [[ $literal = "${prefix}"* ]]; then - matches+=("$literal ") - fi - done - fi - declare -A commands - commands=([7]=0 [22]=1 [8]=3 [5]=2) - if [[ -v "commands[$state]" ]]; then - local command_id=${commands[$state]} - local completions=() - readarray -t completions < <(_hyprctl_cmd_${command_id} "$prefix" | cut -f1) - for item in "${completions[@]}"; do - if [[ $item = "${prefix}"* ]]; then - matches+=("$item") - fi - done - fi - - - local shortest_suffix="$prefix" - for ((i=0; i < ${#COMP_WORDBREAKS}; i++)); do - local char="${COMP_WORDBREAKS:$i:1}" - local candidate=${prefix##*$char} - if [[ ${#candidate} -lt ${#shortest_suffix} ]]; then - shortest_suffix=$candidate - fi - done - local superfluous_prefix="" - if [[ "$shortest_suffix" != "$prefix" ]]; then - local superfluous_prefix=${prefix%$shortest_suffix} - fi - COMPREPLY=("${matches[@]#$superfluous_prefix}") - - return 0 -} - -complete -o nospace -F _hyprctl hyprctl diff --git a/hyprctl/hyprctl.fish b/hyprctl/hyprctl.fish deleted file mode 100644 index 6ad32041..00000000 --- a/hyprctl/hyprctl.fish +++ /dev/null @@ -1,235 +0,0 @@ -function _hyprctl_2 - set 1 $argv[1] - hyprctl monitors | awk '/Monitor/{ print $2 }' -end - -function _hyprctl_4 - set 1 $argv[1] - hyprctl clients | awk '/class/{print $2}' -end - -function _hyprctl_3 - set 1 $argv[1] - hyprctl devices | sed -n '/Keyboard at/{n; s/^\s\+//; p}' -end - -function _hyprctl_1 - set 1 $argv[1] - hyprpm list | awk '/Plugin/{print $4}' -end - -function _hyprctl - set COMP_LINE (commandline --cut-at-cursor) - - set COMP_WORDS - echo $COMP_LINE | read --tokenize --array COMP_WORDS - if string match --quiet --regex '.*\s$' $COMP_LINE - set COMP_CWORD (math (count $COMP_WORDS) + 1) - else - set COMP_CWORD (count $COMP_WORDS) - end - - set literals "resizeactive" "2" "changegroupactive" "-r" "moveintogroup" "forceallowsinput" "4" "::=" "systeminfo" "all" "layouts" "setprop" "animationstyle" "switchxkblayout" "create" "denywindowfromgroup" "headless" "activebordercolor" "exec" "setcursor" "wayland" "focusurgentorlast" "workspacerules" "movecurrentworkspacetomonitor" "movetoworkspacesilent" "hyprpaper" "alpha" "inactivebordercolor" "movegroupwindow" "movecursortocorner" "movewindowpixel" "prev" "movewindow" "globalshortcuts" "clients" "dimaround" "setignoregrouplock" "splash" "execr" "monitors" "0" "forcenoborder" "-q" "animations" "1" "nomaxsize" "splitratio" "moveactive" "pass" "swapnext" "devices" "layers" "rounding" "lockactivegroup" "5" "moveworkspacetomonitor" "-f" "-i" "--quiet" "forcenodim" "pin" "0" "1" "forceopaque" "forcenoshadow" "setfloating" "minsize" "alphaoverride" "sendshortcut" "workspaces" "cyclenext" "alterzorder" "togglegroup" "lockgroups" "bordersize" "dpms" "focuscurrentorlast" "-1" "--batch" "notify" "remove" "instances" "1" "3" "moveoutofgroup" "killactive" "2" "movetoworkspace" "movecursor" "configerrors" "closewindow" "swapwindow" "tagwindow" "forcerendererreload" "centerwindow" "auto" "focuswindow" "seterror" "nofocus" "alphafullscreen" "binds" "version" "-h" "togglespecialworkspace" "fullscreen" "windowdancecompat" "0" "keyword" "toggleopaque" "3" "--instance" "togglefloating" "renameworkspace" "alphafullscreenoverride" "activeworkspace" "x11" "kill" "forceopaqueoverriden" "output" "global" "dispatch" "reload" "forcenoblur" "-j" "event" "--help" "disable" "-1" "activewindow" "keepaspectratio" "dismissnotify" "focusmonitor" "movefocus" "plugin" "exit" "workspace" "fullscreenstate" "getoption" "alphainactiveoverride" "alphainactive" "decorations" "settiled" "config-only" "descriptions" "resizewindowpixel" "fakefullscreen" "rollinglog" "swapactiveworkspaces" "submap" "next" "movewindoworgroup" "cursorpos" "forcenoanims" "focusworkspaceoncurrentmonitor" "maxsize" "sendkeystate" - - set descriptions - set descriptions[1] "Resize the active window" - set descriptions[2] "Fullscreen" - set descriptions[3] "Switch to the next window in a group" - set descriptions[4] "Refresh state after issuing the command" - set descriptions[5] "Move the active window into a group" - set descriptions[7] "CONFUSED" - set descriptions[9] "Print system info" - set descriptions[11] "List all layouts available (including plugin ones)" - set descriptions[12] "Set a property of a window" - set descriptions[14] "Set the xkb layout index for a keyboard" - set descriptions[16] "Prohibit the active window from becoming or being inserted into group" - set descriptions[19] "Execute a shell command" - set descriptions[20] "Set the cursor theme and reloads the cursor manager" - set descriptions[22] "Focus the urgent window or the last window" - set descriptions[23] "Get the list of defined workspace rules" - set descriptions[24] "Move the active workspace to a monitor" - set descriptions[25] "Move window doesn't switch to the workspace" - set descriptions[26] "Interact with hyprpaper if present" - set descriptions[29] "Swap the active window with the next or previous in a group" - set descriptions[30] "Move the cursor to the corner of the active window" - set descriptions[31] "Move a selected window" - set descriptions[33] "Move the active window in a direction or to a monitor" - set descriptions[34] "Lists all global shortcuts" - set descriptions[35] "List all windows with their properties" - set descriptions[37] "Temporarily enable or disable binds:ignore_group_lock" - set descriptions[38] "Print the current random splash" - set descriptions[39] "Execute a raw shell command" - set descriptions[40] "List active outputs with their properties" - set descriptions[43] "Disable output" - set descriptions[44] "Gets the current config info about animations and beziers" - set descriptions[47] "Change the split ratio" - set descriptions[48] "Move the active window" - set descriptions[49] "Pass the key to a specified window" - set descriptions[50] "Swap the focused window with the next window" - set descriptions[51] "List all connected keyboards and mice" - set descriptions[52] "List the layers" - set descriptions[54] "Lock the focused group" - set descriptions[55] "OK" - set descriptions[56] "Move a workspace to a monitor" - set descriptions[58] "Specify the Hyprland instance" - set descriptions[59] "Disable output" - set descriptions[61] "Pin a window" - set descriptions[62] "WARNING" - set descriptions[63] "INFO" - set descriptions[66] "Set the current window's floating state to true" - set descriptions[69] "On shortcut X sends shortcut Y to a specified window" - set descriptions[70] "List all workspaces with their properties" - set descriptions[71] "Focus the next window on a workspace" - set descriptions[72] "Modify the window stack order of the active or specified window" - set descriptions[73] "Toggle the current active window into a group" - set descriptions[74] "Lock the groups" - set descriptions[76] "Set all monitors' DPMS status" - set descriptions[77] "Switch focus from current to previously focused window" - set descriptions[78] "No Icon" - set descriptions[79] "Execute a batch of commands separated by ;" - set descriptions[80] "Send a notification using the built-in Hyprland notification system" - set descriptions[82] "List all running Hyprland instances and their info" - set descriptions[83] "Maximize no fullscreen" - set descriptions[84] "Maximize and fullscreen" - set descriptions[85] "Move the active window out of a group" - set descriptions[86] "Close the active window" - set descriptions[87] "HINT" - set descriptions[88] "Move the focused window to a workspace" - set descriptions[89] "Move the cursor to a specified position" - set descriptions[90] "List all current config parsing errors" - set descriptions[91] "Close a specified window" - set descriptions[92] "Swap the active window with another window" - set descriptions[93] "Apply a tag to the window" - set descriptions[94] "Force the renderer to reload all resources and outputs" - set descriptions[95] "Center the active window" - set descriptions[97] "Focus the first window matching" - set descriptions[98] "Set the hyprctl error string" - set descriptions[101] "List all registered binds" - set descriptions[102] "Print the Hyprland version: flags, commit and branch of build" - set descriptions[103] "Prints the help message" - set descriptions[104] "Toggle a special workspace on/off" - set descriptions[105] "Toggle the focused window's fullscreen state" - set descriptions[107] "None" - set descriptions[108] "Issue a keyword to call a config keyword dynamically" - set descriptions[109] "Toggle the current window to always be opaque" - set descriptions[110] "ERROR" - set descriptions[111] "Specify the Hyprland instance" - set descriptions[112] "Toggle the current window's floating state" - set descriptions[113] "Rename a workspace" - set descriptions[115] "Get the active workspace name and its properties" - set descriptions[117] "Get into a kill mode, where you can kill an app by clicking on it" - set descriptions[119] "Allows adding/removing fake outputs to a specific backend" - set descriptions[120] "Execute a Global Shortcut using the GlobalShortcuts portal" - set descriptions[121] "Issue a dispatch to call a keybind dispatcher with an arg" - set descriptions[122] "Force reload the config" - set descriptions[124] "Output in JSON format" - set descriptions[125] "Emits a custom event to socket2" - set descriptions[126] "Prints the help message" - set descriptions[128] "Current" - set descriptions[129] "Get the active window name and its properties" - set descriptions[131] "Dismiss all or up to amount of notifications" - set descriptions[132] "Focus a monitor" - set descriptions[133] "Move the focus in a direction" - set descriptions[134] "Interact with a plugin" - set descriptions[135] "Exit the compositor with no questions asked" - set descriptions[136] "Change the workspace" - set descriptions[137] "Sets the focused window’s fullscreen mode and the one sent to the client" - set descriptions[138] "Get the config option status (values)" - set descriptions[141] "List all decorations and their info" - set descriptions[142] "Set the current window's floating state to false" - set descriptions[144] "Return a parsable JSON with all the config options, descriptions, value types and ranges" - set descriptions[145] "Resize a selected window" - set descriptions[146] "Toggle the focused window's internal fullscreen state" - set descriptions[147] "Print tail of the log" - set descriptions[148] "Swap the active workspaces between two monitors" - set descriptions[149] "Change the current mapping group" - set descriptions[151] "Behave as moveintogroup" - set descriptions[152] "Get the current cursor pos in global layout coordinates" - set descriptions[154] "Focus the requested workspace" - - set literal_transitions - set literal_transitions[1] "set inputs 121 44 126 82 4 52 51 129 90 59 9 11 12 131 14 98 102 103 134 101 138 23 20 141 26 144 108 147 70 34 35 79 115 38 152 117 122 124 40 43 80 119; set tos 15 3 22 3 22 3 3 3 3 22 3 3 4 5 6 7 3 22 8 3 3 3 3 9 3 3 10 11 3 3 3 22 3 3 3 3 14 22 12 22 16 13" - set literal_transitions[2] "set inputs 82 52 51 129 9 90 11 12 131 14 98 102 134 101 23 20 138 141 26 144 108 147 70 34 35 115 38 152 117 40 119 122 121 80 44; set tos 3 3 3 3 3 3 3 4 5 6 7 3 8 3 3 3 3 9 3 3 10 11 3 3 3 3 3 3 3 12 13 14 15 16 3" - set literal_transitions[4] "set inputs 140 64 65 46 106 28 27 53 6 67 68 130 114 13 75 100 36 153 99 60 118 42 18 139 155 123; set tos 3 17 17 17 17 3 3 5 17 3 17 17 17 3 5 3 17 17 17 17 17 17 3 17 3 17" - set literal_transitions[7] "set inputs 127; set tos 3" - set literal_transitions[11] "set inputs 57; set tos 3" - set literal_transitions[12] "set inputs 10; set tos 3" - set literal_transitions[13] "set inputs 15 81; set tos 20 23" - set literal_transitions[14] "set inputs 143; set tos 3" - set literal_transitions[15] "set inputs 1 85 3 86 5 88 89 91 92 93 94 95 97 16 19 104 22 105 24 25 29 30 31 109 112 33 113 37 39 120 125 47 48 49 50 54 56 132 133 135 136 61 137 142 66 145 146 69 148 71 72 73 74 149 76 77 151 154; set tos 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 21 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3" - set literal_transitions[16] "set inputs 87 7 110 62 78 55 63; set tos 5 5 5 5 5 5 5" - set literal_transitions[17] "set inputs 41 45; set tos 3 3" - set literal_transitions[18] "set inputs 8; set tos 24" - set literal_transitions[19] "set inputs 32 150; set tos 3 3" - set literal_transitions[20] "set inputs 96 17 116 21; set tos 3 3 3 3" - set literal_transitions[21] "set inputs 107 83 128 2 84; set tos 3 3 3 3 3" - set literal_transitions[24] "set inputs 58 111; set tos 22 22" - - set match_anything_transitions_from 7 8 1 23 6 5 3 19 12 9 10 14 11 2 - set match_anything_transitions_to 18 3 2 3 19 3 18 3 18 3 3 18 18 2 - - set state 1 - set word_index 2 - while test $word_index -lt $COMP_CWORD - set -- word $COMP_WORDS[$word_index] - - if set --query literal_transitions[$state] && test -n $literal_transitions[$state] - set --erase inputs - set --erase tos - eval $literal_transitions[$state] - - if contains -- $word $literals - set literal_matched 0 - for literal_id in (seq 1 (count $literals)) - if test $literals[$literal_id] = $word - set index (contains --index -- $literal_id $inputs) - set state $tos[$index] - set word_index (math $word_index + 1) - set literal_matched 1 - break - end - end - if test $literal_matched -ne 0 - continue - end - end - end - - if set --query match_anything_transitions_from[$state] && test -n $match_anything_transitions_from[$state] - set index (contains --index -- $state $match_anything_transitions_from) - set state $match_anything_transitions_to[$index] - set word_index (math $word_index + 1) - continue - end - - return 1 - end - - if set --query literal_transitions[$state] && test -n $literal_transitions[$state] - set --erase inputs - set --erase tos - eval $literal_transitions[$state] - for literal_id in $inputs - if test -n $descriptions[$literal_id] - printf '%s\t%s\n' $literals[$literal_id] $descriptions[$literal_id] - else - printf '%s\n' $literals[$literal_id] - end - end - end - - set command_states 8 23 9 6 - set command_ids 1 2 4 3 - if contains $state $command_states - set index (contains --index $state $command_states) - set function_id $command_ids[$index] - set function_name _hyprctl_$function_id - set --erase inputs - set --erase tos - $function_name "$COMP_WORDS[$COMP_CWORD]" - end - - return 0 -end - -complete --command hyprctl --no-files --arguments "(_hyprctl)" diff --git a/hyprctl/hyprctl.usage b/hyprctl/hyprctl.usage deleted file mode 100644 index e13fc9d5..00000000 --- a/hyprctl/hyprctl.usage +++ /dev/null @@ -1,164 +0,0 @@ -# This is a file fed to complgen to generate bash/fish/zsh completions -# Repo: https://github.com/adaszko/complgen -# Generate completion scripts: "complgen aot --bash-script hyprctl.bash --fish-script hyprctl.fish --zsh-script hyprctl.zsh ./hyprctl.usage" - -hyprctl []... - - ::= (-i | --instance) "Specify the Hyprland instance" - | (-j) "Output in JSON format" - | (-r) "Refresh state after issuing the command" - | (--batch) "Execute a batch of commands separated by ;" - | (-q | --quiet) "Disable output" - | (-h | --help) "Prints the help message" - ; - - ::= {{{ hyprctl clients | awk '/class/{print $2}' }}}; - - ::= {{{ hyprpm list | awk '/Plugin/{print $4}' }}}; - - ::= {{{ hyprctl monitors | awk '/Monitor/{ print $2 }' }}}; - - ::= {{{ hyprctl devices | sed -n '/Keyboard at/{n; s/^\s\+//; p}' }}}; - - ::= (0) "WARNING" - | (1) "INFO" - | (2) "HINT" - | (3) "ERROR" - | (4) "CONFUSED" - | (5) "OK" - | (-1) "No Icon" - ; - - ::= (animationstyle) - | (rounding ) - | (bordersize ) - | (forcenoblur (0 | 1)) - | (forceopaque (0 | 1)) - | (forceopaqueoverriden (0 | 1)) - | (forceallowsinput (0 | 1)) - | (forcenoanims (0 | 1)) - | (forcenoborder (0 | 1)) - | (forcenodim (0 | 1)) - | (forcenoshadow (0 | 1)) - | (nofocus (0 | 1)) - | (windowdancecompat (0 | 1)) - | (nomaxsize (0 | 1)) - | (minsize) - | (maxsize) - | (dimaround (0 | 1)) - | (keepaspectratio (0 | 1)) - | (alphaoverride (0 | 1)) - | (alpha) - | (alphainactiveoverride (0 | 1)) - | (alphainactive) - | (alphafullscreenoverride (0 | 1)) - | (alphafullscreen) - | (activebordercolor) - | (inactivebordercolor) - ; - - - ::= (activewindow) "Get the active window name and its properties" - | (activeworkspace) "Get the active workspace name and its properties" - | (animations) "Gets the current config info about animations and beziers" - | (binds) "List all registered binds" - | (clients) "List all windows with their properties" - | (configerrors) "List all current config parsing errors" - | (cursorpos) "Get the current cursor pos in global layout coordinates" - | (decorations ) "List all decorations and their info" - | (descriptions) "Return a parsable JSON with all the config options, descriptions, value types and ranges" - | (devices) "List all connected keyboards and mice" - | (dismissnotify ) "Dismiss all or up to amount of notifications" - | (dispatch ) "Issue a dispatch to call a keybind dispatcher with an arg" - | (getoption) "Get the config option status (values)" - | (globalshortcuts) "Lists all global shortcuts" - | (hyprpaper) "Interact with hyprpaper if present" - | (instances) "List all running Hyprland instances and their info" - | (keyword ) "Issue a keyword to call a config keyword dynamically" - | (kill) "Get into a kill mode, where you can kill an app by clicking on it" - | (layers) "List the layers" - | (layouts) "List all layouts available (including plugin ones)" - | (monitors [all]) "List active outputs with their properties" - | (notify ) "Send a notification using the built-in Hyprland notification system" - | (output (create (wayland | x11 | headless | auto) | remove )) "Allows adding/removing fake outputs to a specific backend" - | (plugin ) "Interact with a plugin" - | (reload [config-only]) "Force reload the config" - | (rollinglog [-f]) "Print tail of the log" - | (setcursor) "Set the cursor theme and reloads the cursor manager" - | (seterror [disable]) "Set the hyprctl error string" - | (setprop ) "Set a property of a window" - | (splash) "Print the current random splash" - | (switchxkblayout (next | prev | )) "Set the xkb layout index for a keyboard" - | (systeminfo) "Print system info" - | (version) "Print the Hyprland version: flags, commit and branch of build" - | (workspacerules) "Get the list of defined workspace rules" - | (workspaces) "List all workspaces with their properties" - ; - - ::= (-1) "Current" - | (0) "None" - | (1) "Maximize no fullscreen" - | (2) "Fullscreen" - | (3) "Maximize and fullscreen" - ; - - ::= (exec) "Execute a shell command" - | (execr) "Execute a raw shell command" - | (pass) "Pass the key to a specified window" - | (sendshortcut) "On shortcut X sends shortcut Y to a specified window" - | (sendkeystate) "Send a key with specific state (down/repeat/up) to a specified window (window must keep focus for events to continue)" - | (killactive) "Close the active window" - | (closewindow) "Close a specified window" - | (workspace) "Change the workspace" - | (movetoworkspace) "Move the focused window to a workspace" - | (movetoworkspacesilent) "Move window doesn't switch to the workspace" - | (togglefloating) "Toggle the current window's floating state" - | (setfloating) "Set the current window's floating state to true" - | (settiled) "Set the current window's floating state to false" - | (fullscreen) "Toggle the focused window's fullscreen state" - | (fakefullscreen) "Toggle the focused window's internal fullscreen state" - | (fullscreenstate ) "Sets the focused window’s fullscreen mode and the one sent to the client" - | (dpms) "Set all monitors' DPMS status" - | (pin) "Pin a window" - | (movefocus) "Move the focus in a direction" - | (movewindow) "Move the active window in a direction or to a monitor" - | (swapwindow) "Swap the active window with another window" - | (centerwindow) "Center the active window" - | (resizeactive) "Resize the active window" - | (moveactive) "Move the active window" - | (resizewindowpixel) "Resize a selected window" - | (movewindowpixel) "Move a selected window" - | (cyclenext) "Focus the next window on a workspace" - | (swapnext) "Swap the focused window with the next window" - | (tagwindow) "Apply a tag to the window" - | (focuswindow) "Focus the first window matching" - | (focusmonitor) "Focus a monitor" - | (splitratio) "Change the split ratio" - | (toggleopaque) "Toggle the current window to always be opaque" - | (movecursortocorner) "Move the cursor to the corner of the active window" - | (movecursor) "Move the cursor to a specified position" - | (renameworkspace) "Rename a workspace" - | (exit) "Exit the compositor with no questions asked" - | (forcerendererreload) "Force the renderer to reload all resources and outputs" - | (movecurrentworkspacetomonitor) "Move the active workspace to a monitor" - | (focusworkspaceoncurrentmonitor) "Focus the requested workspace" - | (moveworkspacetomonitor) "Move a workspace to a monitor" - | (swapactiveworkspaces) "Swap the active workspaces between two monitors" - | (alterzorder) "Modify the window stack order of the active or specified window" - | (togglespecialworkspace) "Toggle a special workspace on/off" - | (focusurgentorlast) "Focus the urgent window or the last window" - | (togglegroup) "Toggle the current active window into a group" - | (changegroupactive) "Switch to the next window in a group" - | (focuscurrentorlast) "Switch focus from current to previously focused window" - | (lockgroups) "Lock the groups" - | (lockactivegroup) "Lock the focused group" - | (moveintogroup) "Move the active window into a group" - | (moveoutofgroup) "Move the active window out of a group" - | (movewindoworgroup) "Behave as moveintogroup" - | (movegroupwindow) "Swap the active window with the next or previous in a group" - | (denywindowfromgroup) "Prohibit the active window from becoming or being inserted into group" - | (setignoregrouplock) "Temporarily enable or disable binds:ignore_group_lock" - | (global) "Execute a Global Shortcut using the GlobalShortcuts portal" - | (submap) "Change the current mapping group" - | (event) "Emits a custom event to socket2" - ; diff --git a/hyprctl/hyprctl.zsh b/hyprctl/hyprctl.zsh deleted file mode 100644 index e0c48ab0..00000000 --- a/hyprctl/hyprctl.zsh +++ /dev/null @@ -1,274 +0,0 @@ -#compdef hyprctl - -_hyprctl_cmd_1 () { - hyprctl monitors | awk '/Monitor/{ print $2 }' -} - -_hyprctl_cmd_3 () { - hyprctl clients | awk '/class/{print $2}' -} - -_hyprctl_cmd_2 () { - hyprctl devices | sed -n '/Keyboard at/{n; s/^\s\+//; p}' -} - -_hyprctl_cmd_0 () { - hyprpm list | awk '/Plugin/{print $4}' -} - -_hyprctl () { - local -a literals=("resizeactive" "2" "changegroupactive" "-r" "moveintogroup" "forceallowsinput" "4" "::=" "systeminfo" "all" "layouts" "setprop" "animationstyle" "switchxkblayout" "create" "denywindowfromgroup" "headless" "activebordercolor" "exec" "setcursor" "wayland" "focusurgentorlast" "workspacerules" "movecurrentworkspacetomonitor" "movetoworkspacesilent" "hyprpaper" "alpha" "inactivebordercolor" "movegroupwindow" "movecursortocorner" "movewindowpixel" "prev" "movewindow" "globalshortcuts" "clients" "dimaround" "setignoregrouplock" "splash" "execr" "monitors" "0" "forcenoborder" "-q" "animations" "1" "nomaxsize" "splitratio" "moveactive" "pass" "swapnext" "devices" "layers" "rounding" "lockactivegroup" "5" "moveworkspacetomonitor" "-f" "-i" "--quiet" "forcenodim" "pin" "0" "1" "forceopaque" "forcenoshadow" "setfloating" "minsize" "alphaoverride" "sendshortcut" "workspaces" "cyclenext" "alterzorder" "togglegroup" "lockgroups" "bordersize" "dpms" "focuscurrentorlast" "-1" "--batch" "notify" "remove" "instances" "1" "3" "moveoutofgroup" "killactive" "2" "movetoworkspace" "movecursor" "configerrors" "closewindow" "swapwindow" "tagwindow" "forcerendererreload" "centerwindow" "auto" "focuswindow" "seterror" "nofocus" "alphafullscreen" "binds" "version" "-h" "togglespecialworkspace" "fullscreen" "windowdancecompat" "0" "keyword" "toggleopaque" "3" "--instance" "togglefloating" "renameworkspace" "alphafullscreenoverride" "activeworkspace" "x11" "kill" "forceopaqueoverriden" "output" "global" "dispatch" "reload" "forcenoblur" "-j" "event" "--help" "disable" "-1" "activewindow" "keepaspectratio" "dismissnotify" "focusmonitor" "movefocus" "plugin" "exit" "workspace" "fullscreenstate" "getoption" "alphainactiveoverride" "alphainactive" "decorations" "settiled" "config-only" "descriptions" "resizewindowpixel" "fakefullscreen" "rollinglog" "swapactiveworkspaces" "submap" "next" "movewindoworgroup" "cursorpos" "forcenoanims" "focusworkspaceoncurrentmonitor" "maxsize" "sendkeystate") - - local -A descriptions - descriptions[1]="Resize the active window" - descriptions[2]="Fullscreen" - descriptions[3]="Switch to the next window in a group" - descriptions[4]="Refresh state after issuing the command" - descriptions[5]="Move the active window into a group" - descriptions[7]="CONFUSED" - descriptions[9]="Print system info" - descriptions[11]="List all layouts available (including plugin ones)" - descriptions[12]="Set a property of a window" - descriptions[14]="Set the xkb layout index for a keyboard" - descriptions[16]="Prohibit the active window from becoming or being inserted into group" - descriptions[19]="Execute a shell command" - descriptions[20]="Set the cursor theme and reloads the cursor manager" - descriptions[22]="Focus the urgent window or the last window" - descriptions[23]="Get the list of defined workspace rules" - descriptions[24]="Move the active workspace to a monitor" - descriptions[25]="Move window doesn't switch to the workspace" - descriptions[26]="Interact with hyprpaper if present" - descriptions[29]="Swap the active window with the next or previous in a group" - descriptions[30]="Move the cursor to the corner of the active window" - descriptions[31]="Move a selected window" - descriptions[33]="Move the active window in a direction or to a monitor" - descriptions[34]="Lists all global shortcuts" - descriptions[35]="List all windows with their properties" - descriptions[37]="Temporarily enable or disable binds:ignore_group_lock" - descriptions[38]="Print the current random splash" - descriptions[39]="Execute a raw shell command" - descriptions[40]="List active outputs with their properties" - descriptions[43]="Disable output" - descriptions[44]="Gets the current config info about animations and beziers" - descriptions[47]="Change the split ratio" - descriptions[48]="Move the active window" - descriptions[49]="Pass the key to a specified window" - descriptions[50]="Swap the focused window with the next window" - descriptions[51]="List all connected keyboards and mice" - descriptions[52]="List the layers" - descriptions[54]="Lock the focused group" - descriptions[55]="OK" - descriptions[56]="Move a workspace to a monitor" - descriptions[58]="Specify the Hyprland instance" - descriptions[59]="Disable output" - descriptions[61]="Pin a window" - descriptions[62]="WARNING" - descriptions[63]="INFO" - descriptions[66]="Set the current window's floating state to true" - descriptions[69]="On shortcut X sends shortcut Y to a specified window" - descriptions[70]="List all workspaces with their properties" - descriptions[71]="Focus the next window on a workspace" - descriptions[72]="Modify the window stack order of the active or specified window" - descriptions[73]="Toggle the current active window into a group" - descriptions[74]="Lock the groups" - descriptions[76]="Set all monitors' DPMS status" - descriptions[77]="Switch focus from current to previously focused window" - descriptions[78]="No Icon" - descriptions[79]="Execute a batch of commands separated by ;" - descriptions[80]="Send a notification using the built-in Hyprland notification system" - descriptions[82]="List all running Hyprland instances and their info" - descriptions[83]="Maximize no fullscreen" - descriptions[84]="Maximize and fullscreen" - descriptions[85]="Move the active window out of a group" - descriptions[86]="Close the active window" - descriptions[87]="HINT" - descriptions[88]="Move the focused window to a workspace" - descriptions[89]="Move the cursor to a specified position" - descriptions[90]="List all current config parsing errors" - descriptions[91]="Close a specified window" - descriptions[92]="Swap the active window with another window" - descriptions[93]="Apply a tag to the window" - descriptions[94]="Force the renderer to reload all resources and outputs" - descriptions[95]="Center the active window" - descriptions[97]="Focus the first window matching" - descriptions[98]="Set the hyprctl error string" - descriptions[101]="List all registered binds" - descriptions[102]="Print the Hyprland version: flags, commit and branch of build" - descriptions[103]="Prints the help message" - descriptions[104]="Toggle a special workspace on/off" - descriptions[105]="Toggle the focused window's fullscreen state" - descriptions[107]="None" - descriptions[108]="Issue a keyword to call a config keyword dynamically" - descriptions[109]="Toggle the current window to always be opaque" - descriptions[110]="ERROR" - descriptions[111]="Specify the Hyprland instance" - descriptions[112]="Toggle the current window's floating state" - descriptions[113]="Rename a workspace" - descriptions[115]="Get the active workspace name and its properties" - descriptions[117]="Get into a kill mode, where you can kill an app by clicking on it" - descriptions[119]="Allows adding/removing fake outputs to a specific backend" - descriptions[120]="Execute a Global Shortcut using the GlobalShortcuts portal" - descriptions[121]="Issue a dispatch to call a keybind dispatcher with an arg" - descriptions[122]="Force reload the config" - descriptions[124]="Output in JSON format" - descriptions[125]="Emits a custom event to socket2" - descriptions[126]="Prints the help message" - descriptions[128]="Current" - descriptions[129]="Get the active window name and its properties" - descriptions[131]="Dismiss all or up to amount of notifications" - descriptions[132]="Focus a monitor" - descriptions[133]="Move the focus in a direction" - descriptions[134]="Interact with a plugin" - descriptions[135]="Exit the compositor with no questions asked" - descriptions[136]="Change the workspace" - descriptions[137]="Sets the focused window’s fullscreen mode and the one sent to the client" - descriptions[138]="Get the config option status (values)" - descriptions[141]="List all decorations and their info" - descriptions[142]="Set the current window's floating state to false" - descriptions[144]="Return a parsable JSON with all the config options, descriptions, value types and ranges" - descriptions[145]="Resize a selected window" - descriptions[146]="Toggle the focused window's internal fullscreen state" - descriptions[147]="Print tail of the log" - descriptions[148]="Swap the active workspaces between two monitors" - descriptions[149]="Change the current mapping group" - descriptions[151]="Behave as moveintogroup" - descriptions[152]="Get the current cursor pos in global layout coordinates" - descriptions[154]="Focus the requested workspace" - - local -A literal_transitions - literal_transitions[1]="([121]=15 [44]=3 [126]=22 [82]=3 [4]=22 [52]=3 [51]=3 [129]=3 [90]=3 [59]=22 [9]=3 [11]=3 [12]=4 [131]=5 [14]=6 [98]=7 [102]=3 [103]=22 [134]=8 [101]=3 [138]=3 [23]=3 [20]=3 [141]=9 [26]=3 [144]=3 [108]=10 [147]=11 [70]=3 [34]=3 [35]=3 [79]=22 [115]=3 [38]=3 [152]=3 [117]=3 [122]=14 [124]=22 [40]=12 [43]=22 [80]=16 [119]=13)" - literal_transitions[2]="([82]=3 [52]=3 [51]=3 [129]=3 [9]=3 [90]=3 [11]=3 [12]=4 [131]=5 [14]=6 [98]=7 [102]=3 [134]=8 [101]=3 [23]=3 [20]=3 [138]=3 [141]=9 [26]=3 [144]=3 [108]=10 [147]=11 [70]=3 [34]=3 [35]=3 [115]=3 [38]=3 [152]=3 [117]=3 [40]=12 [119]=13 [122]=14 [121]=15 [80]=16 [44]=3)" - literal_transitions[4]="([140]=3 [64]=17 [65]=17 [46]=17 [106]=17 [28]=3 [27]=3 [53]=5 [6]=17 [67]=3 [68]=17 [130]=17 [114]=17 [13]=3 [75]=5 [100]=3 [36]=17 [153]=17 [99]=17 [60]=17 [118]=17 [42]=17 [18]=3 [139]=17 [155]=3 [123]=17)" - literal_transitions[7]="([127]=3)" - literal_transitions[11]="([57]=3)" - literal_transitions[12]="([10]=3)" - literal_transitions[13]="([15]=20 [81]=23)" - literal_transitions[14]="([143]=3)" - literal_transitions[15]="([1]=3 [85]=3 [3]=3 [86]=3 [5]=3 [88]=3 [89]=3 [91]=3 [92]=3 [93]=3 [94]=3 [95]=3 [97]=3 [16]=3 [19]=3 [104]=3 [22]=3 [105]=3 [24]=3 [25]=3 [29]=3 [30]=3 [31]=3 [109]=3 [112]=3 [33]=3 [113]=3 [37]=3 [39]=3 [120]=3 [125]=3 [47]=3 [48]=3 [49]=3 [50]=3 [54]=3 [56]=3 [132]=3 [133]=3 [135]=3 [136]=3 [61]=3 [137]=21 [142]=3 [66]=3 [145]=3 [146]=3 [69]=3 [148]=3 [71]=3 [72]=3 [73]=3 [74]=3 [149]=3 [76]=3 [77]=3 [151]=3 [154]=3)" - literal_transitions[16]="([87]=5 [7]=5 [110]=5 [62]=5 [78]=5 [55]=5 [63]=5)" - literal_transitions[17]="([41]=3 [45]=3)" - literal_transitions[18]="([8]=24)" - literal_transitions[19]="([32]=3 [150]=3)" - literal_transitions[20]="([96]=3 [17]=3 [116]=3 [21]=3)" - literal_transitions[21]="([107]=3 [83]=3 [128]=3 [2]=3 [84]=3)" - literal_transitions[24]="([58]=22 [111]=22)" - - local -A match_anything_transitions - match_anything_transitions=([7]=18 [8]=3 [1]=2 [23]=3 [6]=19 [5]=3 [3]=18 [19]=3 [12]=18 [9]=3 [10]=3 [14]=18 [11]=18 [2]=2) - - declare -A subword_transitions - - local state=1 - local word_index=2 - while [[ $word_index -lt $CURRENT ]]; do - if [[ -v "literal_transitions[$state]" ]]; then - local -A state_transitions - eval "state_transitions=${literal_transitions[$state]}" - - local word=${words[$word_index]} - local word_matched=0 - for ((literal_id = 1; literal_id <= $#literals; literal_id++)); do - if [[ ${literals[$literal_id]} = "$word" ]]; then - if [[ -v "state_transitions[$literal_id]" ]]; then - state=${state_transitions[$literal_id]} - word_index=$((word_index + 1)) - word_matched=1 - break - fi - fi - done - if [[ $word_matched -ne 0 ]]; then - continue - fi - fi - - if [[ -v "match_anything_transitions[$state]" ]]; then - state=${match_anything_transitions[$state]} - word_index=$((word_index + 1)) - continue - fi - - return 1 - done - - completions_no_description_trailing_space=() - completions_no_description_no_trailing_space=() - completions_trailing_space=() - suffixes_trailing_space=() - descriptions_trailing_space=() - completions_no_trailing_space=() - suffixes_no_trailing_space=() - descriptions_no_trailing_space=() - - if [[ -v "literal_transitions[$state]" ]]; then - local -A state_transitions - eval "state_transitions=${literal_transitions[$state]}" - - for literal_id in ${(k)state_transitions}; do - if [[ -v "descriptions[$literal_id]" ]]; then - completions_trailing_space+=("${literals[$literal_id]}") - suffixes_trailing_space+=("${literals[$literal_id]}") - descriptions_trailing_space+=("${descriptions[$literal_id]}") - else - completions_no_description_trailing_space+=("${literals[$literal_id]}") - fi - done - fi - local -A commands=([8]=0 [23]=1 [9]=3 [6]=2) - - if [[ -v "commands[$state]" ]]; then - local command_id=${commands[$state]} - local output=$(_hyprctl_cmd_${command_id} "${words[$CURRENT]}") - local -a command_completions=("${(@f)output}") - for line in ${command_completions[@]}; do - local parts=(${(@s: :)line}) - if [[ -v "parts[2]" ]]; then - completions_trailing_space+=("${parts[1]}") - suffixes_trailing_space+=("${parts[1]}") - descriptions_trailing_space+=("${parts[2]}") - else - completions_no_description_trailing_space+=("${parts[1]}") - fi - done - fi - - local maxlen=0 - for suffix in ${suffixes_trailing_space[@]}; do - if [[ ${#suffix} -gt $maxlen ]]; then - maxlen=${#suffix} - fi - done - for suffix in ${suffixes_no_trailing_space[@]}; do - if [[ ${#suffix} -gt $maxlen ]]; then - maxlen=${#suffix} - fi - done - - for ((i = 1; i <= $#suffixes_trailing_space; i++)); do - if [[ -z ${descriptions_trailing_space[$i]} ]]; then - descriptions_trailing_space[$i]="${(r($maxlen)( ))${suffixes_trailing_space[$i]}}" - else - descriptions_trailing_space[$i]="${(r($maxlen)( ))${suffixes_trailing_space[$i]}} -- ${descriptions_trailing_space[$i]}" - fi - done - - for ((i = 1; i <= $#suffixes_no_trailing_space; i++)); do - if [[ -z ${descriptions_no_trailing_space[$i]} ]]; then - descriptions_no_trailing_space[$i]="${(r($maxlen)( ))${suffixes_no_trailing_space[$i]}}" - else - descriptions_no_trailing_space[$i]="${(r($maxlen)( ))${suffixes_no_trailing_space[$i]}} -- ${descriptions_no_trailing_space[$i]}" - fi - done - - compadd -Q -a completions_no_description_trailing_space - compadd -Q -S ' ' -a completions_no_description_no_trailing_space - compadd -l -Q -a -d descriptions_trailing_space completions_trailing_space - compadd -l -Q -S '' -a -d descriptions_no_trailing_space completions_no_trailing_space - return 0 -} - -if [[ $ZSH_EVAL_CONTEXT =~ :file$ ]]; then - compdef _hyprctl hyprctl -else - _hyprctl -fi diff --git a/hyprctl/main.cpp b/hyprctl/main.cpp new file mode 100644 index 00000000..31efcd16 --- /dev/null +++ b/hyprctl/main.cpp @@ -0,0 +1,388 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +const std::string USAGE = R"#(usage: hyprctl [(opt)flags] [command] [(opt)args] + +commands: + monitors + workspaces + activeworkspace + clients + activewindow + layers + devices + binds + dispatch + keyword + version + kill + splash + hyprpaper + reload + setcursor + getoption + cursorpos + switchxkblayout + seterror + setprop + plugin + notify + globalshortcuts + +flags: + -j -> output in JSON + --batch -> execute a batch of commands, separated by ';' +)#"; + +#define PAD + +void request(std::string arg, int minArgs = 0) { + const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0); + + const auto ARGS = std::count(arg.begin(), arg.end(), ' '); + + if (ARGS < minArgs) { + std::cout << "Not enough arguments, expected at least " << minArgs; + return; + } + + if (SERVERSOCKET < 0) { + std::cout << "Couldn't open a socket (1)"; + return; + } + + // get the instance signature + auto instanceSig = getenv("HYPRLAND_INSTANCE_SIGNATURE"); + + if (!instanceSig) { + std::cout << "HYPRLAND_INSTANCE_SIGNATURE was not set! (Is Hyprland running?)"; + return; + } + + std::string instanceSigStr = std::string(instanceSig); + + sockaddr_un serverAddress = {0}; + serverAddress.sun_family = AF_UNIX; + + std::string socketPath = "/tmp/hypr/" + instanceSigStr + "/.socket.sock"; + + strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1); + + if (connect(SERVERSOCKET, (sockaddr*)&serverAddress, SUN_LEN(&serverAddress)) < 0) { + std::cout << "Couldn't connect to " << socketPath << ". (3)"; + return; + } + + auto sizeWritten = write(SERVERSOCKET, arg.c_str(), arg.length()); + + if (sizeWritten < 0) { + std::cout << "Couldn't write (4)"; + return; + } + + std::string reply = ""; + char buffer[8192] = {0}; + + sizeWritten = read(SERVERSOCKET, buffer, 8192); + + if (sizeWritten < 0) { + std::cout << "Couldn't read (5)"; + return; + } + + reply += std::string(buffer, sizeWritten); + + while (sizeWritten == 8192) { + sizeWritten = read(SERVERSOCKET, buffer, 8192); + if (sizeWritten < 0) { + std::cout << "Couldn't read (5)"; + return; + } + reply += std::string(buffer, sizeWritten); + } + + close(SERVERSOCKET); + + std::cout << reply; +} + +void requestHyprpaper(std::string arg) { + const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0); + + if (SERVERSOCKET < 0) { + std::cout << "Couldn't open a socket (1)"; + return; + } + + // get the instance signature + auto instanceSig = getenv("HYPRLAND_INSTANCE_SIGNATURE"); + + if (!instanceSig) { + std::cout << "HYPRLAND_INSTANCE_SIGNATURE was not set! (Is Hyprland running?)"; + return; + } + + std::string instanceSigStr = std::string(instanceSig); + + sockaddr_un serverAddress = {0}; + serverAddress.sun_family = AF_UNIX; + + std::string socketPath = "/tmp/hypr/" + instanceSigStr + "/.hyprpaper.sock"; + + strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1); + + if (connect(SERVERSOCKET, (sockaddr*)&serverAddress, SUN_LEN(&serverAddress)) < 0) { + std::cout << "Couldn't connect to " << socketPath << ". (3)"; + return; + } + + auto sizeWritten = write(SERVERSOCKET, arg.c_str(), arg.length()); + + if (sizeWritten < 0) { + std::cout << "Couldn't write (4)"; + return; + } + + char buffer[8192] = {0}; + + sizeWritten = read(SERVERSOCKET, buffer, 8192); + + if (sizeWritten < 0) { + std::cout << "Couldn't read (5)"; + return; + } + + close(SERVERSOCKET); + + std::cout << std::string(buffer); +} + +int dispatchRequest(int argc, char** argv) { + + if (argc < 3) { + std::cout << "Usage: hyprctl dispatch \n\ + Execute a hyprland keybind dispatcher with the given argument"; + return 1; + } + + std::string rq = "/dispatch"; + + for (int i = 2; i < argc; i++) { + if (!strcmp(argv[i], "--")) + continue; + rq += " " + std::string(argv[i]); + } + + request(rq); + return 0; +} + +int keywordRequest(int argc, char** argv) { + if (argc < 4) { + std::cout << "Usage: hyprctl keyword \n\ + Execute a hyprland keyword with the given argument"; + return 1; + } + + std::string rq = "/keyword"; + + for (int i = 2; i < argc; i++) + rq += " " + std::string(argv[i]); + + request(rq); + return 0; +} + +int hyprpaperRequest(int argc, char** argv) { + if (argc < 4) { + std::cout << "Usage: hyprctl hyprpaper \n\ + Execute a hyprpaper command with the given argument"; + return 1; + } + + std::string rq = std::string(argv[2]) + " " + std::string(argv[3]); + + requestHyprpaper(rq); + return 0; +} + +int setcursorRequest(int argc, char** argv) { + if (argc < 4) { + std::cout << "Usage: hyprctl setcursor \n\ + Sets the cursor theme for everything except GTK and reloads the cursor"; + return 1; + } + + std::string rq = "setcursor "; + for (size_t i = 2; i < argc; ++i) + rq += std::string(argv[i]) + " "; + rq.pop_back(); + + request(rq); + return 0; +} + +int outputRequest(int argc, char** argv) { + if (argc < 4) { + std::cout << "Usage: hyprctl output \n\ + creates / destroys a fake output\n\ + with create, name is the backend name to use (available: auto, x11, wayland, headless)\n\ + with destroy, name is the output name to destroy"; + return 1; + } + + std::string rq = "output " + std::string(argv[2]) + " " + std::string(argv[3]); + + request(rq); + return 0; +} + +void batchRequest(std::string arg) { + std::string rq = "[[BATCH]]" + arg.substr(arg.find_first_of(" ") + 1); + + request(rq); +} + +std::deque splitArgs(int argc, char** argv) { + std::deque result; + + for (auto i = 1 /* skip the executable */; i < argc; ++i) + result.push_back(std::string(argv[i])); + + return result; +} + +bool isNumber(const std::string& str, bool allowfloat) { + if (str.empty()) + return false; + return std::ranges::all_of(str.begin(), str.end(), [&](char c) { return isdigit(c) != 0 || c == '-' || (allowfloat && c == '.'); }); +} + +int main(int argc, char** argv) { + int bflag = 0, sflag = 0, index, c; + bool parseArgs = true; + + if (argc < 2) { + printf("%s\n", USAGE.c_str()); + return 1; + } + + std::string fullRequest = ""; + std::string fullArgs = ""; + const auto ARGS = splitArgs(argc, argv); + + for (auto i = 0; i < ARGS.size(); ++i) { + if (ARGS[i] == "--") { + // Stop parsing arguments after -- + parseArgs = false; + continue; + } + if (parseArgs && (ARGS[i][0] == '-') && !isNumber(ARGS[i], true) /* For stuff like -2 */) { + // parse + if (ARGS[i] == "-j" && !fullArgs.contains("j")) { + fullArgs += "j"; + } else if (ARGS[i] == "--batch") { + fullRequest = "--batch "; + } else { + printf("%s\n", USAGE.c_str()); + return 1; + } + + continue; + } + + fullRequest += ARGS[i] + " "; + } + + if (fullRequest.empty()) { + printf("%s\n", USAGE.c_str()); + return 1; + } + + fullRequest.pop_back(); // remove trailing space + + fullRequest = fullArgs + "/" + fullRequest; + + int exitStatus = 0; + + if (fullRequest.contains("/--batch")) + batchRequest(fullRequest); + else if (fullRequest.contains("/monitors")) + request(fullRequest); + else if (fullRequest.contains("/clients")) + request(fullRequest); + else if (fullRequest.contains("/workspaces")) + request(fullRequest); + else if (fullRequest.contains("/activeworkspace")) + request(fullRequest); + else if (fullRequest.contains("/activewindow")) + request(fullRequest); + else if (fullRequest.contains("/layers")) + request(fullRequest); + else if (fullRequest.contains("/version")) + request(fullRequest); + else if (fullRequest.contains("/kill")) + request(fullRequest); + else if (fullRequest.contains("/splash")) + request(fullRequest); + else if (fullRequest.contains("/devices")) + request(fullRequest); + else if (fullRequest.contains("/reload")) + request(fullRequest); + else if (fullRequest.contains("/getoption")) + request(fullRequest); + else if (fullRequest.contains("/binds")) + request(fullRequest); + else if (fullRequest.contains("/cursorpos")) + request(fullRequest); + else if (fullRequest.contains("/animations")) + request(fullRequest); + else if (fullRequest.contains("/globalshortcuts")) + request(fullRequest); + else if (fullRequest.contains("/switchxkblayout")) + request(fullRequest, 2); + else if (fullRequest.contains("/seterror")) + request(fullRequest, 1); + else if (fullRequest.contains("/setprop")) + request(fullRequest, 3); + else if (fullRequest.contains("/plugin")) + request(fullRequest, 1); + else if (fullRequest.contains("/notify")) + request(fullRequest, 2); + else if (fullRequest.contains("/output")) + exitStatus = outputRequest(argc, argv); + else if (fullRequest.contains("/setcursor")) + exitStatus = setcursorRequest(argc, argv); + else if (fullRequest.contains("/dispatch")) + exitStatus = dispatchRequest(argc, argv); + else if (fullRequest.contains("/keyword")) + exitStatus = keywordRequest(argc, argv); + else if (fullRequest.contains("/hyprpaper")) + exitStatus = hyprpaperRequest(argc, argv); + else if (fullRequest.contains("/--help")) + printf("%s", USAGE.c_str()); + else { + printf("%s\n", USAGE.c_str()); + return 1; + } + + printf("\n"); + return exitStatus; +} diff --git a/hyprctl/meson.build b/hyprctl/meson.build new file mode 100644 index 00000000..2b941d6d --- /dev/null +++ b/hyprctl/meson.build @@ -0,0 +1,3 @@ +executable('hyprctl', 'main.cpp', + install: true +) diff --git a/hyprctl/src/Strings.hpp b/hyprctl/src/Strings.hpp deleted file mode 100644 index 549d84bb..00000000 --- a/hyprctl/src/Strings.hpp +++ /dev/null @@ -1,183 +0,0 @@ -#pragma once - -#include - -const std::string_view USAGE = R"#(usage: hyprctl [flags] [args...|--help] - -commands: - activewindow → Gets the active window name and its properties - activeworkspace → Gets the active workspace and its properties - animations → Gets the current config'd info about animations - and beziers - binds → Lists all registered binds - clients → Lists all windows with their properties - configerrors → Lists all current config parsing errors - cursorpos → Gets the current cursor position in global layout - coordinates - decorations → Lists all decorations and their info - devices → Lists all connected keyboards and mice - dismissnotify [amount] → Dismisses all or up to AMOUNT notifications - dispatch [args] → Issue a dispatch to call a keybind - dispatcher with arguments - getoption