Git Product home page Git Product logo

keebie's People

Contributors

craftycodie avatar daisyuniverse avatar johannescmayer avatar michael-e-b avatar parasbhanot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

keebie's Issues

Mapping Keyboard Shortcuts

Hi there!!!

After struggling a little bit, it run!!! Its awesome.

Now I have doubt. Is it possible to assign to a key a keyboard shortcut?. Example: In my second keyboard, I press a key, let's say letter A, can it be changed as pressing "Ctrl + C" on my main keyboard or even sending non standard keycaps like "F25"?

Switch bounce?

I added an entry into the default.json using the --add flag to load Sublime Text and assigned it to the SPACE key. When running and if I hit SPACE it will launch the program either three to five times as if there is a switch bounce. I tried a different keyboard and got the same issue. I also tried looking at the default.json and tried editing a few things and no change.

CLI OUTPUT
Welcome to Keebie
Loading settings from settings.json
: /opt/sublime_text/sublime_text&
KEY_SPACE:
: /opt/sublime_text/sublime_text&
: /opt/sublime_text/sublime_text&
: /opt/sublime_text/sublime_text&
: /opt/sublime_text/sublime_text&

DEFAULT.JSON
{
"leds": [],
"vars": {
"sublimetext": "/opt/sublime_text/sublime_text"
},
"KEY_SPACE": "%sublimetext",
"": "/opt/sublime_text/sublime_text"
}

second keyboard only activating after a first keypress

The second keyboard I've set up works, but if it has been a while since I used it, the first keypress presses something else alltogether. From the log e.g. i get this:

KEY_KPMINUS: xdotool key 'Control_L+Shift_L+Meta_L+t'
^[^TKEY_KPMINUS: xdotool key 'Control_L+Shift_L+Meta_L+t'
KEY_KP9: xdotool key 'Super_L+9'

the second line reflects what happens when I haven't pressed it in a while.
Am I doing something wrong? or is this a bug?
Thanks for the excellent software, i'm enjoying it a lot !!!!

Feature request -- run bash scripts as non-root

Hello everyone ,

i am running the following script to toggle between audio output :

#!/usr/bin/sh

TOGGLE=$HOME/.toggle

if [ ! -e $TOGGLE ]; then

  touch $TOGGLE  
  pacmd set-card-profile 0 output:analog-stereo

else

  rm $TOGGLE
  pacmd set-card-profile 0 output:hdmi-stereo

fi

The problem is that keebie is running this script as root user so 'pacmd' commad in the script is not working but this script is working fine with other hotkeys daemons like dxhd because they run the scripts/binaries as non-root user.

i have already tried the following as suggested in this forum :

"TOGGLE_AUDIO_SOURCE": "sudo -u parasbhanot bash -c '/home/parasbhanot/toogleAudio.sh"

&&

"TOGGLE_AUDIO_SOURCE": "sudo -u parasbhanot '/home/parasbhanot/toogleAudio.sh"

is it possible to do this in keebie ?

Key adding dialog sometimes returns empty keypresses

I've noticed that if you use the hotkey adding dialog, if you do not hit the desired key quickly enough (within 1 second of the prompt appearing it feels like) it will try to bind to an empty key value. Not a huge issue but initially confusing

Also, I just wanna say that besides that, that menu works incredibly smoothly. Really nicely done @Michael-E-B

F string error, permission error, and a discussion of key passthrough

When following the instructions, I get hung up on running the script.
This is the output I get when running "python keepbie.py" in y terminal.

File "keebie.py", line 73
print(f"Untracked key {keycode} released.") # If you see this that means we missed a key press, bad news. (But not fatal.)

Unsure of how to go about to resolve this issue.

some comments trying to make keebie run

is issue: no

Issue description

Im trying to use a NEC point-of-sale keyboard
OS: Linux Mint 20.1 x86_64
Kernel: 5.11.0-27-generic

Tried just installing python3-evdev didnt work, had to use
pip install evdev

Then right after installing the permission for the /dev/input was not set properly, i read elsewhere it could fix with log-out or reboot, so i tried rebooting and it read proper

Next the NEC keyboard has no leds in hardware, and keebie uses a hardcoded index 17 in line L#311

            leds = self.device.capabilities()[17] # Get a list of LEDs the device has

added a line and increased tab space on the rest of this scope

            if(17 in self.device.capabilities().keys()):
                leds = self.device.capabilities()[17] # Get a list of LEDs the device has
                ...

next running
keebie --install
breaks with error because it attempts to copy files that already exists, added on L#1011

def firstUses(): # Setup to be run when a user first runs keebie
    if os.path.exists(dataDir):
        print("files already installed in ", dataDir)
        return
    shutil.copytree(installDataDir + "data/", dataDir) # Copy template configuration files to user
    print(f"configuration files copied from {installDataDir}/data/ to {dataDir}") # And inform the user

next, because of the reboot the evdev input id number changed from what it autodetected (input30) and running
keebie --detect
returns /dev/input//event2

Then edited the files by hand in /home/zaida/.config/keebie/
Suggestion that i have no idea how to make: use /dev/input/by-id/* instead of input/event*

then running as root
sudo chown zaida /dev/input/event2

then running keebie works properly. This last part is probably fixed with editing the udev rules but i havent rebooted and idek lel

Run command without root privilege.

Good evening,
I was wondering if it was possible to access to the second keyboard without root privilege ? I mean, if I do not launch keebie.py as root, it just do not work because it does not have access to the keyboard. Is there something to do I did not ?
Thank you.
2021-07-11_18-06

Not Detecting - Missing inotifywatch

In Ubuntu, I encountered a problem where Keebie was unable to detect my keyboards. The underlying issue was that the inotifywatch utility was not installed.

The inotifywatch utility is used for monitoring device files within the code. To resolve this problem, you can use the following commands to install it:

sudo apt-get update
sudo apt-get install inotify-tools

Executing these commands will update the package lists and install the necessary inotify-tools package. Once installed, you should be able to use inotifywatch without any issues.

Layers error

i am getting the following error when i use layers options :

Keebie  🌡 master ✈️  Γ—2 via 🐍 v3.9.1 ❯  ./keebie.py --layers                                                      12:09:00
Welcome to Keebie
Available Layers: 

default.json{
   "KEY_SPACE": "echo 'Hello World!'",
   "KEY_A": "brave"
}

Exception ignored in: <function InputDevice.__del__ at 0x7f3cd1dd5940>
Traceback (most recent call last):
  File "/home/parasbhanot/.local/lib/python3.9/site-packages/evdev/device.py", line 159, in __del__
  File "/home/parasbhanot/.local/lib/python3.9/site-packages/evdev/device.py", line 304, in close
  File "/home/parasbhanot/.local/lib/python3.9/site-packages/evdev/eventio_async.py", line 54, in close
  File "/usr/lib/python3.9/asyncio/events.py", line 725, in get_event_loop_policy
  File "/usr/lib/python3.9/asyncio/events.py", line 718, in _init_event_loop_policy
ImportError: sys.meta_path is None, Python is likely shutting down

i am testing this on arch machine with python 3.9.1.

Any ideas what is causing this import error ?

Switching layers

i can neither create nor switch to a layer.

i tried the following to create the layer :

Keebie  🌡 master ✈️  Γ—1 πŸ† Γ—1 via 🐍 v3.9.1 took 16s ❯  
./keebie.py --add layer:parasbhanot
usage: keebie.py [-h] [--layers] [--device DEVICE] [--add] [--settings]
keebie.py: error: unrecognized arguments: layer:parasbhanot
Keebie  🌡 master ✈️  Γ—1 πŸ† Γ—1 via 🐍 v3.9.1 βœ–   
./keebie.py --add layer parasbhanot
usage: keebie.py [-h] [--layers] [--device DEVICE] [--add] [--settings]
keebie.py: error: unrecognized arguments: layer parasbhanot

Am i missing something here ?

I have also tried to create a layer manually, but I have no idea how to switch to that layer as the documentation is very confusing.

Create a standard systemd service file

Keebie is most usefully run as a daemon, so this seems like a no brainer, having it install as part of a package managers installation script would also be handy

New format of device file

Hello everyone ,

i updated the local keebie repository on my machine but then i realized that old config file does not work anymore . Also no sample device file exist in repository and i do not want to use "keebie --new" syntax as it will create the udev rule again .

What is the format of new device file ?

How to map comma, point or semicolon to KEY_X?

Hello,
so far i can --add new Keys_* to the layer-file.json and it works great.

Assign k to [KEY_K]? [Y/n]

But how can i add points or comma?

Assign . to []? [Y/n] y
Addition cancelled.
<...>
Assign , to []? [Y/n] y
Addition cancelled.

Is there a special Format?
I tried to add KEY_[.]": "py3:my_script.py" in the layer file but that does not work.

Modifier key combinations

Is it possible to add modifier + regular keys combo for macros in default.json can do something like :
"KEY_CTRL KEY_Y":"brave-browser-stable" or
"KEY_CTRL + KEY_Y":"brave-browser-stable"

GUI Layer Configuration Tool

I have a concept for layer file configuration that I would like to implement, this would require a few changes to the main script, but it could probably be kept separate and optional

image

Not working as systemd service

Hi,

I am trying to run keebie.py using as systemd service so that i can turn the script on and off using systemctl command but for some reasons keebie.py refuse to work with systemd but if i run the keebie.py from the terminal emulator everthing works as expected

The keeebie service seems to be working but it is not executing any command that i have defined in default.json.

~ ❯ sudo systemctl status keebie                                              11:17:33
● keebie.service - Keebie service
     Loaded: loaded (/etc/systemd/system/keebie.service; disabled; vendor preset: dis>
     Active: active (running) since Sat 2021-01-30 11:17:33 IST; 1s ago
   Main PID: 62904 (python3)
      Tasks: 1 (limit: 9366)
     Memory: 12.6M
     CGroup: /system.slice/keebie.service
             └─62904 /usr/bin/python3 /home/parasbhanot/Keebie/keebie.py

i have created the keebie service with the following content :

[Unit]
Description=Keebie service 

[Service]
Type=simple
ExecStart=/usr/bin/python3 /home/parasbhanot/Keebie/keebie.py

[Install]
WantedBy=multi-user.target

Please note that i have also created the udev rule for my second keyboard so it cannot not be a permission issue.

if i disconnect my second keyboard and then check the status of the keebie service i get the following :


/etc/systemd/systemπŸ”’ ❯ sudo systemctl status keebie                          11:31:33
[sudo] password for parasbhanot: 
● keebie.service - Keebie service
     Loaded: loaded (/etc/systemd/system/keebie.service; disabled; vendor preset: dis>
     Active: failed (Result: exit-code) since Sat 2021-01-30 11:34:31 IST; 7s ago
    Process: 62904 ExecStart=/usr/bin/python3 /home/parasbhanot/Keebie/keebie.py (cod>
   Main PID: 62904 (code=exited, status=1/FAILURE)

Jan 30 11:34:31 garuda python3[62904]: Exception ignored in: <function InputDevice.__>
Jan 30 11:34:31 garuda python3[62904]: Traceback (most recent call last):
Jan 30 11:34:31 garuda python3[62904]:   File "/usr/lib/python3.9/site-packages/evdev>
Jan 30 11:34:31 garuda python3[62904]:   File "/usr/lib/python3.9/site-packages/evdev>
Jan 30 11:34:31 garuda python3[62904]:   File "/usr/lib/python3.9/site-packages/evdev>
Jan 30 11:34:31 garuda python3[62904]:   File "/usr/lib/python3.9/asyncio/events.py",>
Jan 30 11:34:31 garuda python3[62904]:   File "/usr/lib/python3.9/asyncio/events.py",>
Jan 30 11:34:31 garuda python3[62904]: ImportError: sys.meta_path is None, Python is >
Jan 30 11:34:31 garuda systemd[1]: keebie.service: Main process exited, code=exited, >
Jan 30 11:34:31 garuda systemd[1]: keebie.service: Failed with result 'exit-code'.

i have also cheked the jorunal logs . it seems script is working but it is not executing xdotool when it is run as service which is strange but simple echo commands are working fine as given below.

16:11 garuda python3[28139]: error: Your personal settings will not be saved.
Jan 31 13:16:11 garuda python3[28139]: error: Unable to locate the config directory.
Jan 31 13:16:11 garuda python3[28139]: error: Please set the XDG_CONFIG_HOME or HOME environment variable before starting fish.
Jan 31 13:16:11 garuda python3[28141]: Error: Can't open display: (null)
Jan 31 13:16:11 garuda python3[28141]: Failed creating new xdo instance

Jan 31 13:18:14 garuda python3[28189]: hello from default

My default.json file :

{
   "KEY_F10": "layer:parasbhanot",
   "KEY_SPACE": "echo 'hello from default' ",
   "KEY_F1": "/home/parasbhanot/Automation/scripts/ping.sh",
   "KEY_SCROLLLOCK": "xdotool key ctrl+n"
}

i am running out of ideas .

has anyone tested keebie.py with systemd ?

NameError: name 'dev' is not defined

Hello, i'm trying to get Keebie working.
here the error i got :

[mirsella@predator ~/Documents/Keebie]$ python keebie.py --add
Welcome to Keebie
Enter the command you would like to attribute to a key on your second keyboard 
echo ergkljh
Please press the key you would like to assign the command to...
Traceback (most recent call last):
  File "keebie.py", line 132, in <module>
    addKey()
  File "keebie.py", line 59, in addKey
    for event in dev.read_loop():
NameError: name 'dev' is not defined

seems like dev is not set in the addKey() func.
after some documentation and reading your code (i'm a newbie, so i'm happy for what a just done) and i just added dev = InputDevice(config()[0]) at the start of the function addKey(). God i love open source, being able to do that. now it's working great, this script is awesome !
tell me if you add a better solution to solve this issue thanks

Video Tutorial / Showcase

Alright, so here's where I'll post updates on the progress of the video.

  1. install it from scratch, preferably on several systems to get a feel for the process
  2. begin writing the script ( and possibly update the readme while I'm at it )
  3. record the process of installation, and record some VO
  4. mix it all together in kdenlive

Some useful things to do might also be to reread the entire codebase in order to familiarize myself with any features we've added in but haven't documented well

more details about layer<mylayer>

could you pls add more details to the layer syntax? at the moment all macros go to default.json but the keyboard is bound to his own config fle

Escaping `%`s in a layer causes `json` to raise an error. Workaround and possible solutions.

I found a small issue with parseVars(), it seems the json module doesn't like it if you escape a character it doesn't think needs to be escaped and will raise an error like json.decoder.JSONDecodeError: Invalid \escape: line 48 column 32 (char 1722) and it doesn't think %s should be escaped; as such if you have something like "KEY_T": "echo \"\%testvar\%\"" in a layer file keebie.py crashes as soon as the layer is loaded.

I missed this bug when I was writing the function because I wrote tests to see if the function would work properly with escaped characters, I forgot to test if json parses and escapes anything, it does.

There is an easy workaround, simply type \\% when you want an escaped %, json will send \% to parseVars() which will in turn send a % (instead of capturing a variable name). This works and is simple, but is also counterintuitive.

A simple fix would be to change line 346 escapeChar = "\\" in parseVars() to a different character such as ^, this would break existing escaped characters and would have Keebie using a non standard escape character. Another solution would be to make escapeChar a tuple of possible escape character. Either of these is obviously an easy change.

#Dependency inotify-tools

While looking for solution to use hotkeys form my new custom keyboard, i stumpled upon this package.

Unfortunately it didn't work out of the box for me (Linux 5.11.0-25-generic #27~20.04.1-Ubuntu )

After looking through the code and trying different options i noticed that when trying to detect any input

( keebie -d ) the script entered an infinite loop because i was missing a dependency.

dev = subprocess.check_output("sudo inotifywatch " + path +"/* -t 1 2>&1 | grep " + path + " | awk 'NF{ print $NF }'", shell=True ).decode('utf-8').strip()

when trying manually i noticed that i'm missing the package:

Command 'inotifywatch' not found, but can be installed with:

sudo apt install inotify-tools

Maybe the dependency should be installed using the makefile, or documented in the readme.

--add layer:<name> does not work for me

name the correct layer for macro does not work for me

pi@raspberrypi:~ $ keebie --add layer:a52
usage: keebie [-h] [--layers] [--detect] [--print-keys] [--add [layer]] [--settings] [--edit [layer]] [--new] [--remove [device]] [--pause] [--resume] [--stop] [--install] [--verbose] [--quiet]
keebie: error: argument --add/-a: invalid choice: 'layer:a52' (choose from 'default.json')

pi@raspberrypi:~ $ ls ./.config/keebie/layers/*
./.config/keebie/layers/a52 ./.config/keebie/layers/default.json

Adding a license

Firstly it should be noted that I am not a fancy law talk'n guy (a lawyer).

Assuming choosealicense.com is to be believed in Keebie's current unlicensed state "[...], nobody else can copy, distribute, or modify your work without being at risk of take-downs, shake-downs, or litigation." which I expect everyone can agree is rubbish. Adding a license would solve this.

This would require consensus among contributors on what license to choose. At present the three contributors are myself, @craftycodie, and @robinuniverse. I would suggest the MIT Expat License or The Unlicense (though I understand reservations about public domain, plus it has jurisdiction issues).

Thoughts?

Edit: @parasbhanot is now also a contributor.

Video Tutorial needed, or any type of tutorial.

First of all I must say this piece of software is exactly what I and many others need to enhance our productivity and speed. I saw your (now outdated) video tutorial an it looks great but I can't get the current version to do anything. I can only imagine how many people go through the same steps as me and then give up. That's why I'm leaving this comment here: please do a video tutorial that includes installation, configuration and a few examples of layers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.