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

Add: Allow requestHyprpaper() and request() to return exit codes instead of void. #6083

Merged
merged 1 commit into from
May 15, 2024

Conversation

rofe33
Copy link
Contributor

@rofe33 rofe33 commented May 15, 2024

Describe your PR, what does it fix/add?

It allows request() and requestHyprpaper() to return exit codes.

This allows other script to check for the hyprctl return code, to diagnose the command.

For example, in python:

    # ...
    hyprpaper = subprocess.run(
        [
            'hyprctl',
            'hyprpaper',
        ],
        capture_output=True,
    )

    # Check returncode and not the stdout string
    if (hyprpaper.returncode == 3 or
            hyprpaper.stdout.decode().strip().endswith('(3)')):
        print('Is hyprpaper running?')
        sys.exit(34)
     # ...

This code is from a script that I've created, to change randomly wallpapers for all the monitors.

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

What should be the exit code for:

    // request() function (line 98)
    if (ARGS < minArgs) {
        std::cout << "Not enough arguments, expected at least " << minArgs;
        return -1;
    }

All the other exit codes are the ones available in the string, for example:

    if (SERVERSOCKET < 0) {
        std::cout << "Couldn't open a socket (1)";
        return 1;
    }

Is it ready for merging, or does it need work?

Yes.

Copy link
Member

@vaxerski vaxerski left a comment

Choose a reason for hiding this comment

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

ok, thanks

@vaxerski vaxerski merged commit 3fe5280 into hyprwm:main May 15, 2024
10 checks passed
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

Successfully merging this pull request may close these issues.

2 participants