Skip to content

Global shortcut to bring up npPY. #164

Open

Description

@grandfso

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

Activity

  1. grandfso commented on Jan 21, 2019

    @grandfso
    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 ?

  2. grandfso commented on Jul 15, 2019

    @grandfso
    Author

    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.

  3. self-assigned this
    on Jul 16, 2019
  4. x3cca commented on Nov 6, 2019

    @x3cca

    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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions