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

No Options possible #245

Open
Dr0med4r opened this issue Jun 10, 2024 · 6 comments · May be fixed by #252
Open

No Options possible #245

Dr0med4r opened this issue Jun 10, 2024 · 6 comments · May be fixed by #252

Comments

@Dr0med4r
Copy link

There is a bug introduced by #238 (Client/ydotool.c#L137) that when you use ydotool type -f file.txt there is a Not a valid option error.
The problem is, that it is checked if the option is help or version else exit. But now you can't use other options in subcommands.

@LKS90
Copy link

LKS90 commented Jun 28, 2024

Yeah, can't do anything with mousemove, no matter what I try:

host@device:~/ydotool/build$ ./ydotool mousemove -x 100 -y 100
./ydotool: invalid option -- 'x'
Not a valid option

Usage: ydotool [...]

The other options also don't work:

./ydotool mousemove
Usage: mousemove [OPTION]... [-x <xpos> -y <ypos>] [-- <xpos> <ypos>]
Move mouse pointer or wheel.

Options:
  -w, --wheel                Move mouse wheel relatively
  -a, --absolute             Use absolute position, not applicable to wheel
  -x, --xpos                 X position
  -y, --ypos                 Y position
  -h, --help                 Display this help and exit

You need to disable mouse speed acceleration for correct absolute movement.

let's try the absolute option:

./ydotool mousemove -a 100 100
./ydotool: invalid option -- 'a'
Not a valid option

Usage: ydotool [OPTION] <cmd> <args>
Options:
  -h, --help                 Display this help and exit
  -V, --version              Show version information
Available commands:
  click
  mousemove

@Enkidu-Aururu
Copy link

Enkidu-Aururu commented Jul 4, 2024

I see the same problem "invalid option" everywhere when using build from present master

$ ydotool -V
ydotool version(or hash):
v1.0.4-32-gac76271

Version before #238 works.

@aeleos
Copy link

aeleos commented Aug 3, 2024

I compiled the master branch and had the same issue. Switching to commit e573cfb fixed this.

@jonas73x
Copy link

I reverted back to the "old" way of doing it (but adding an option for version) and it seems to work fine. My coding skills are poor and I'm sure there are valid reasons to use the elegant getopt_long method, but for me it created more headache than it solved. So if this can be verified to work for others, perhaps someone can make the fix so that master works again? In more detaild what I did was:

remove:

static struct option long_options[] = {
	{"help", no_argument, 0, 'h'},
	{"version", no_argument, 0, 'V'},
};

int opt = getopt_long(argc, argv, "hV", long_options, NULL);
if (opt != -1)
{
	switch (opt) {
		case 'h':
			show_help();
			exit(0);

		case 'V':
			show_version();
			exit(0);

		default:
			puts("Not a valid option\n");
			show_help();
			exit(1);
	}
}

and then add back:

    if (argc < 2 || strncmp(argv[1], "-h", 2) == 0 || strncmp(argv[1], "--h", 3) == 0 || strcmp(argv[1], "help") == 0) {
            show_help();
            return 0;
    }
    else if (strncmp(argv[1], "-V", 2) == 0 || strncmp(argv[1], "--V", 3) == 0 || strcmp(argv[1], "version") == 0) {
            show_version();
            return 0;
    }

@Paiusco
Copy link
Contributor

Paiusco commented Oct 6, 2024

Pretty much sorry for that and for disappearing for so long. Hopefully now my smaller PR #252 cleans a bit more without making it impossible to use.

We should consider adding some unit tests under here, to make it simpler to make sure basic functionality works.

@pat-richter
Copy link

Note for peope who wanna build this for fedora silverblue. Build deps could also be in toolbox

# Install dependencies
rpm-ostree install git cmake gcc-c++ pkgconf systemd-devel boost-devel libevdev-devel scdoc
reboot

# Clone and build
git clone https://github.com/ReimuNotMoe/ydotool.git
cd ydotool
git fetch origin pull/252/head:pr-252
git checkout pr-252
mkdir build && cd build
cmake ..
make -j$(nproc)

# Install binaries
sudo cp ./ydotool /usr/local/bin/
sudo cp ./ydotoold /usr/local/bin/
sudo chmod +x /usr/local/bin/ydotool
sudo chmod +x /usr/local/bin/ydotoold

# Install man pages
sudo cp ./manpage/ydotool.1 /usr/local/share/man/man1/
sudo cp ./manpage/ydotoold.8 /usr/local/share/man/man8/

# Setup service
sudo groupadd -f input
sudo usermod -aG input $USER

sudo tee /etc/systemd/system/ydotool.service << 'EOF'
[Unit]
Description=ydotool service

[Service]
Type=simple
ExecStart=/usr/local/bin/ydotoold
User=$USER
Group=input
Environment=XDG_RUNTIME_DIR=/run/user/1000

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now ydotool


# Test
sleep 2 && ydotool mousemove -w -- 0 1

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 a pull request may close this issue.

7 participants