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

Global shortcut to bring up npPY. #164

Open
grandfso opened this issue Nov 2, 2018 · 3 comments
Open

Global shortcut to bring up npPY. #164

grandfso opened this issue Nov 2, 2018 · 3 comments
Assignees

Comments

@grandfso
Copy link

grandfso commented Nov 2, 2018

I would like to request the addition of the possibility to bring up nvpy from taskbar or tray(or background in general) to front.

Example use case: You're working in some application, let's say browser. You want to take a note of something you've seen or something you found. Assuming the application is already running (e.g. autostarts with system), I would press a key combination to bring up nvpy e.g. Alt+R, then Ctrl+N to start new note, then Ctrl+V to paste url or type something, then press escape to exit the note, and escape again to minimise nvPY.

I tried to find some easy solution, but as I am no coder, it wasn't easy enough. Maybe you'd find this useful: http://web.archive.org/web/20081123040533/http://www.cixar.com/~segphault/blog/2007/1/10 and https://github.com/kupferlauncher/keybinder/tree/keybinder-3.0

@grandfso
Copy link
Author

Hi there @yuuki0xff
I was thinking about workaround for this, because lack of the global shortcut makes my life miserable. The workaround I was thinking is - I can configure custom global shortcut on my system, to launch specific command. I was thinking that I can use this feature, but it seems that nvpy command by default doesn't check if there is an instance already running. So the current behavior for me, seems to be that whenever I run the nvpy command, a new instance is launched. Is there some switch available to suppress launching of the second instance and bring up the existing one ?

@grandfso
Copy link
Author

grandfso commented Jul 15, 2019

Hacked my way around it. Posting here maybe someone will find it useful.

This works on linux, and assumes you have the wmctrl and pgrep package installed. I tested arch linux with gnome.

create a bash script:

#!/bin/bash

pidNo="$(pgrep -f 'python2 -m nvpy')"
echo $pidNo
if [ -z "$pidNo" ]
then
    echo "Execution of a script"
    python2 -m nvpy &
    exit 1
else
    echo "Activate the PID"
    wmctrl -a nvPy
fi

Then assign shortcut to this script. When NVPY is not running, it will launch it. If it is running, it will unminimize/bring the window to foreground :)

edit: there's a small bug, if there are more windows with nvpy in the window title (e.g. browser with this git repo open in an active tab), the script will not know which window to unminimize. In my case, it unminimizes the browser.

@yuuki0xff yuuki0xff self-assigned this Jul 16, 2019
@CoolDotty
Copy link
Contributor

I use alt+n as shortcut for nvpy. I have a separate autohotkey script that manages this. Place it in the same folder as the nvpy repo after compiling.

!n::
SetWorkingDir %A_ScriptDir%
if WinExist("nvPY") {
	WinActivate
}
if !WinExist("nvPY") {
	Run %A_ScriptDir%/dist/nvpy/nvpy.exe
}
return

Direct support would be nice but here's another work-around for Windows in the meantime.

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

No branches or pull requests

3 participants