Compare commits

...

3 Commits

Author SHA1 Message Date
9a7246442c Set screen width and height as default variables 2022-06-10 20:12:02 +02:00
234069ba85 Migrate project to flakes 2022-06-10 20:10:48 +02:00
ad319e19af Update mouse library 2022-06-10 20:05:20 +02:00
15 changed files with 61 additions and 17 deletions

41
flake.lock generated Normal file
View File

@@ -0,0 +1,41 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1654845941,
"narHash": "sha256-uXulXu4BQ9ch1ItV0FlL2Ns8X83m6unT5h/0X//VRLQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7b3e907a6fef935794b5049c2c57c519853deb90",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

14
flake.nix Normal file
View File

@@ -0,0 +1,14 @@
{
description = "";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let pkgs = nixpkgs.legacyPackages.${system}; in
{
devShell = import ./shell.nix { inherit pkgs; };
}
);
}

View File

@@ -166,10 +166,6 @@ def on_button(callback, args=(), buttons=(LEFT, MIDDLE, RIGHT, X, X2), types=(UP
callback(*args)
_listener.add_handler(handler)
return handler
def on_pressed(callback, args=()):
""" Invokes `callback` with `args` when the left button is pressed. """
return on_button(callback, args, [LEFT], [DOWN])
def on_click(callback, args=()):
""" Invokes `callback` with `args` when the left button is clicked. """

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -20,8 +20,6 @@ EV_REL = 0x02
EV_ABS = 0x03
EV_MSC = 0x04
INVALID_ARGUMENT_ERRNO = 22
def make_uinput():
import fcntl, struct
@@ -31,12 +29,8 @@ def make_uinput():
fcntl.ioctl(uinput, UI_SET_EVBIT, EV_KEY)
UI_SET_KEYBIT = 0x40045565
try:
for i in range(0x300):
fcntl.ioctl(uinput, UI_SET_KEYBIT, i)
except OSError as e:
if e.errno != INVALID_ARGUMENT_ERRNO:
raise e
for i in range(256):
fcntl.ioctl(uinput, UI_SET_KEYBIT, i)
BUS_USB = 0x03
uinput_user_dev = "80sHHHHi64i64i64i64i"

Binary file not shown.

Binary file not shown.

View File

@@ -3,12 +3,13 @@ from secrets import randbelow
from time import sleep
def erratic_movement(screen_width, screen_height):
def erratic_movement(screen_width=800, screen_height=600):
"""
Moves the cursor to a random position with the screen's width and height as an upper bound
"""
move(
randbelow(screen_width), randbelow(screen_height),
randbelow(screen_width),
randbelow(screen_height),
)
@@ -16,10 +17,8 @@ def main():
"""
Calls the movement function in an infinite loop, with a random delay between each call
"""
screen_width = 800
screen_height = 600
while True:
erratic_movement(screen_width, screen_height)
erratic_movement()
sleep(randbelow(90))