Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Hyprland Advanced Gestures with libinput-gestures #42

Closed
mecattaf opened this issue May 15, 2024 · 5 comments
Closed

Hyprland Advanced Gestures with libinput-gestures #42

mecattaf opened this issue May 15, 2024 · 5 comments

Comments

@mecattaf
Copy link

Hi team wayblue,

First off than you so much for this project.

I am currently working on my custom hyprland image. I am blocked on adding advanced gestures, using libinput-gestures as per the hyprland docs.

I have already created a COPR repo for the latest libinput gestures. You can find the spec file here.

The relevant parts of my recipe.yml are below:

  - type: rpm-ostree
    repos:
      - https://copr.fedorainfracloud.org/coprs/mecattaf/libinput-gestures/repo/fedora-%OS_VERSION%/mecattaf-libinput-gestures-fedora-%OS_VERSION%.repo
    install:
      - wmctrl
      - wtype
      - libinput-gestures

  - type: systemd
  - system:
    enabled:
     - input-groupadd.service

Drawing inspiration from wayblue's method for setting SDDM, I created the following files:

  1. /config/systemd/system/input-groupadd.service
[Unit]
Description=Create input group and user on system boot
Before=graphical.target
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/etc/input/input-groupadd
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
  1. /config/files/usr/etc/input/input-groupadd
#!/bin/bash

# Create the input group if it does not exist
if ! getent group input > /dev/null; then
    groupadd -r input
fi

# Ensure the group creation is complete
sleep 1

# Add the current user to the input group if not already a member
if ! id -nG "$USER" | grep -qw "input"; then
    usermod -aG input "$USER"
fi

However something is broken, here is the output of journalctl -u input-groupadd.service:

May 15 09:31:45 fedora systemd[1]: Starting input-groupadd.service - Create input group and user on system boot...
May 15 09:31:45 fedora input-groupadd[6007]: gpasswd: group 'input' does not exist in /etc/group
May 15 09:31:45 fedora systemd[1]: input-groupadd.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED
May 15 09:31:45 fedora systemd[1]: input-groupadd.service: Failed with result 'exit-code'.
May 15 09:31:45 fedora systemd[1]: Failed to start input-groupadd.service - Create input group and user on system boot.

Any ideas on how to fix this?
Once this works I will add a PR so that other wayblue users may leverage advanced gestures with their hyprland.

@RoyalOughtness
Copy link
Collaborator

Any ideas on how to fix this?

Let's discuss this further on the discord

Once this works I will add a PR so that other wayblue users may leverage advanced gestures with their hyprland.

So far the rule of thumb in this repo has been to wait until these WM packages are added to the fedora repos before pulling them in. This ensures a baseline packaging quality standard.

@mecattaf
Copy link
Author

I modified the input-groupadd script:

#!/bin/bash

LOGFILE="/tmp/input-groupadd.log"

{
    echo "Script started at $(date)"

    # Determine the intended user from /etc/passwd
    target_user=$(awk -F: '$3>=1000 && $3<65534 {print $1; exit}' /etc/passwd)
    echo "Target user: $target_user"

    # Exit if no valid user is found
    if [ -z "$target_user" ]; then
        echo "No valid non-root user found."
        exit 1
    fi

    # Check if the input group exists
    if getent group input > /dev/null; then
        echo "Group 'input' already exists."
    else
        echo "Creating group 'input'"
        groupadd -r input
        if [ $? -ne 0 ]; then
            echo "Failed to create group 'input'."
            exit 1
        fi
    fi

    # Add the user to the input group
    echo "Adding user '$target_user' to group 'input'"
    usermod -aG input "$target_user"
    if [ $? -ne 0 ]; then
        echo "Failed to add user '$target_user' to group 'input'."
        exit 1
    else
        echo "User '$target_user' added to group 'input' successfully."
    fi

    echo "Script finished at $(date)"
} >> $LOGFILE 2>&1

Here is the LOGFILE in question

Script started at Wed May 15 04:42:25 PM EDT 2024
Target user: dev
Group 'input' already exists.
Adding user 'dev' to group 'input'
User 'dev' added to group 'input' successfully.
Script finished at Wed May 15 04:42:25 PM EDT 2024

This shows that it did attempt to add the "dev" user to group input

The systemd unit is now running to completion
May 15 16:42:25 fedora systemd[1]: Starting input-groupadd.service - Create input group on system boot...
May 15 16:42:25 fedora systemd[1]: Finished input-groupadd.service - Create input group on system boot.

Some more outputs that may be useful:

❯ getent group input
input:x:104:

~
❯ id dev
uid=1000(dev) gid=1000(dev) groups=1000(dev),10(wheel)

The problem is clearly a permissions problem. Maybe it's due to Fedora Atomic? I copied the logic from how wayblue sets SDDM as the display manager. This script works in their case

getent group sddm > /dev/null || groupadd -r sddm
getent passwd sddm > /dev/null || useradd -r -g sddm -c "SDDM Greeter Account" -d /var/lib/sddm -s /usr/sbin/nologin sddm

Any thoughts?

@mecattaf
Copy link
Author

For future reference:
I manually added my user to the input group.
I identified the input group

getent group input
input:x:104:

Then from the CLI:

sudo setenforce 0
sudo su
vi /etc/group

and added the line
input:x:104:{user}

Then I was able to run
libinput-gestures-setup autostart
libinput-gestures-setup start
libinput-gestures-setup status

@gmpinder
Copy link

The relevant parts of my recipe.yml are below:

  - type: rpm-ostree
    repos:
      - https://copr.fedorainfracloud.org/coprs/mecattaf/libinput-gestures/repo/fedora-%OS_VERSION%/mecattaf-libinput-gestures-fedora-%OS_VERSION%.repo
    install:
      - wmctrl
      - wtype
      - libinput-gestures

  - type: systemd
  - system:
    enabled:
     - input-groupadd.service

FYI, your systemd module is misconfigured. It should look like this:

  - type: systemd
    system:
      enabled:
        - sddm-boot.service
        - input-groupadd.service
        - tailscaled.service
      disabled:
        - rpm-ostree-countme.timer

@RoyalOughtness
Copy link
Collaborator

thanks @gmpinder

@mecattaf you may want to join the blue-build discord for general bluebuild support, if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants