gkarsay / parlatype

GNOME audio player for transcription
https://www.parlatype.xyz
GNU General Public License v3.0
168 stars 20 forks source link

Add global keyboard shortcuts #18

Open forteller opened 7 years ago

forteller commented 7 years ago

I transcribe a lot for my project the Cory Doctorow wiki, so I was very excited to find an application specifically made for this purpose! Thank you for making this!

Unfortunately I soon had to go back to VLC, which I don't particularly like for this purpose (but it's the least worst I've found so far), because of a few issues. The most important of which is the lack of support for global keyboard shortcuts.

On my laptop there is no media buttons. So there is no way for me to work in a text document and easily play/pause or go back/forth in Parlatype. This, unfortunately, makes Parlatype impossible to use.

In VLC I've set Shift + space to Play/pause and Shift + Alt + Left Arrow/Right Arrow to go a short while back/forth. This is perfect for me, and would be fine if you set that as the default global shortcuts. But I'm thinking a way to set your own global keyboard shortcuts in Parlatype would be ideal.

I'm sure all the technical info is not needed for a future request, but in case I'm using Parlatype 1.5.2 from the PPA on Ubuntu Gnome 17.04 :)

Thank you so much again for your work!

gkarsay commented 7 years ago

If you are using GNOME, you can actually achieve what you want. In GNOME Settings (gnome-control-center) select "Keyboard", then "Shortcuts". On the left select "Sound and Media", there you can assign to "Play (or play/pause)" any keyboard shortcut, e.g. Shift + space. For "Previous track" and "Next track" you can assign Shift + Alt + Left Arrow/Right Arrow. Parlatype will be controlled by those shortcuts. This should actually work, doesn't it? This will also control other media players.

If you are using LibreOffice and have the libreoffice-helpers installed, you can assign shortcuts in LibreOffice to those actions, there are a few more than with Media Keys only.

I hope this works for you, but I won't close this bug report. It is still a problem if you are not using GNOME nor LibreOffice.

You say there are "a few issues". Thank you for this report, feel free to report any other issue separately.

fcastilloec commented 6 years ago

I'm not sure if I should open a new issue, but my problem is related to this issue. I'm using latest Ubuntu 16.04 with Unity and your app doesn't work with global media shortcuts. All my other audio apps work flawlessly when I press any of the global shortcuts I assigned to Pause/Play. (i.e. VLC, Clementine, Spotify, Headset, etc)

Running it from the terminal doesn't show any errors. I know there are FLAGS for debugging (--gdk-debug=FLAGS), so do let me know if I need to send any additional info to solve this problem. Since you mention that the software works with Gnome, maybe the bug is something to do with Unity?

I've installed your app from your PPA, currently running v1.5.3

gkarsay commented 6 years ago

I think I have messed it up while fixing issue #20 , argh. Seems like it's working on newer systems now but not on older ones anymore. I'll fix it asap, meanwhile you could downgrade to 1.5.2, it should work there.

forteller commented 6 years ago

If you are using GNOME, you can actually achieve what you want. In GNOME Settings (gnome-control-center) select "Keyboard", then "Shortcuts".

Thanks for the tip. But that would make my media keys on my external keyboard not work any more it seems (I use that when on my projector, not when transcribing)

If you are using LibreOffice and have the libreoffice-helpers installed, you can assign shortcuts in LibreOffice to those actions, there are a few more than with Media Keys only.

Maybe I'm just a bit slow, but I haven't figured out how to use LO-helpers yet. A link to a step-by-step would be much appreciated. Thanks!

fcastilloec commented 6 years ago

@gkarsay I just received an update to v.1.5.4 which has fixed the media shortcuts. Maybe @forteller can try installing this version and test if it works for you too

forteller commented 6 years ago

I just updated to 1.5.4. Can't see any preferences to seg global shortcuts?

fcastilloec commented 6 years ago

@forteller try using the default ones on your keyboard, the ones associated with all apps. It's usually F8, or FN+F8. Look for the PLAY/PAUSE logo on your keyboard. There's no need to set specific keys for just this app. You can also check which keys are associated by going to Settings/Keyboard from Ubuntu (NOT this app) and scrolling down to Sound and Media, you can always change them to whatever you want, but this will affect all audio applications, not just Parlatype gnome-settings

forteller commented 6 years ago

Yes. I've already explained why none of those options don't work for me :)

gkarsay commented 6 years ago

The help pages in Parlatype explain how to assign shortcuts to the LibreOffice macros. The help pages are also online: https://gkarsay.github.io/parlatype/help-online/libreoffice-helpers.html

There are no global shortcuts yet. First, I don't know yet how to do that. Then I would consider it for version 1.6 which won't land this year.

fcastilloec commented 6 years ago

@forteller also, even though your laptop doesn't have dedicated media keys. Following my previous instructions, you can assign any key combination you want, for example, the same keys you were using for VLC. You just have to click on the Play (or play/pause) and it will ask you to assign any shortcut, same goes for previous and next track

vijaymarupudi commented 6 years ago

I think a command like parlatype toggle-play would help a lot. You can bind that to whatever DE's shortcuts configuration tool. I'm thinking of something like cmus-remote.

gkarsay commented 6 years ago

I'm not sure whether this helps the issue reporter. But yes, you can control Parlatype via D-Bus commands that you could launch from a script or some shortcuts tools. That's how the LibreOffice macros work.

For example you can do the following from command line while Parlatype is running (that is a single line): qdbus com.github.gkarsay.parlatype /com/github/gkarsay/parlatype com.github.gkarsay.parlatype.PlayPause

Supported actions are:

com.github.gkarsay.parlatype.DecreaseSpeed
com.github.gkarsay.parlatype.GetTimestamp
com.github.gkarsay.parlatype.GotoTimestamp "#1:00.0#"
com.github.gkarsay.parlatype.IncreaseSpeed
com.github.gkarsay.parlatype.JumpBack
com.github.gkarsay.parlatype.JumpForward
com.github.gkarsay.parlatype.PlayPause
gkarsay commented 6 years ago

I investigated how to implement global keyboard shortcuts. It seems like it would work only with X11 but it is impossible with Wayland, at least at the moment. It would be too much work for me to implement this natively in Parlatype but I suggest a workaround using xbindkeys:

Install xbindkeys from your distro. First you have to assign a config file:

$ xbindkeys --defaults > ~/.xbindkeysrc

Then edit that file and add something like:

#Play/Pause
"qdbus com.github.gkarsay.parlatype /com/github/gkarsay/parlatype com.github.gkarsay.parlatype.PlayPause"
   Shift + space

#Jump back
"qdbus com.github.gkarsay.parlatype /com/github/gkarsay/parlatype com.github.gkarsay.parlatype.JumpBack"
   Shift+Alt + Left

#Jump forward
"qdbus com.github.gkarsay.parlatype /com/github/gkarsay/parlatype com.github.gkarsay.parlatype.JumpForward"
   Shift+Alt + Right

Now run xbindkeys in background and it will listen to those shortcuts. You may want to start it automatically when you start your desktop environment, there are different solutions for this. Or you launch parlatype with a script, starting xbindkeys first.

You can use all the dbus commands listed in my posting above.

This works only in X11, I'm not aware of a solution in Wayland.

I hope this helps! The status of this bug is "on hold". I will not implement this in Parlatype itself in the near future.

cristoper commented 6 years ago

Thanks @gkarsay. The dbus interface sounds very useful for people (like me) who don't use gnome or have gnome-settings-daemon installed. (It would be nice if it were documented somewhere outside of github.)

As an aside, for parlatype installed via Debian this service name/path works:

qdbus org.gnome.parlatype /org/gnome/parlatype org.gnome.parlatype.PlayPause

a-pav commented 11 months ago

For example you can do the following from command line while Parlatype is running (that is a single line): qdbus com.github.gkarsay.parlatype /com/github/gkarsay/parlatype com.github.gkarsay.parlatype.PlayPause

Running this said: qdbus: could not find a Qt installation of ''

I installed qdbus-qt5 and tried again, but now it says: Service 'com.github.gkarsay.parlatype' does not exist. or Service 'org.gnome.parlatype' does not exist.

Did the service name change or parlatype stopped supporting this method of controlling? I'm using parlatype 3.0 installed from ubuntu repository, i3 and linux mint.

a-pav commented 11 months ago

I found the (current) service name, and also found the equivalent calls to dbus-send instead of qdbus. Given that dbus-send looks more familiar to me, I list it along the qdbus calls.

To get parlatype service name:

dbus-send --print-reply --dest=org.freedesktop.DBus  /org/freedesktop/DBus org.freedesktop.DBus.ListNames | grep -i parlatype
# Or, alternatively:
qdbus | grep -i parlatype

Call the above mentioned methods like:

dbus-send --type=method_call --dest=org.parlatype.Parlatype /org/parlatype/parlatype org.parlatype.Parlatype.PlayPause
# Or, alternatively:
qdbus org.parlatype.Parlatype /org/parlatype/parlatype org.parlatype.Parlatype.PlayPause