tdesktop icon indicating copy to clipboard operation
tdesktop copied to clipboard

[Feature request] Hotkey for quick access

Open xander13th opened this issue 11 years ago • 4 comments

Hello! I suggest to add option to set custom GLOBAL hotkey for quick access for telegram.

[✓] show/hide application with global hotkey [ press key ]     [✓] switch to oldest unread message

Hotkey actions: -if app is inactive then activate it on last chat with text field focused -if there are new messages then activate app (if inactive) and open chat with oldest unread msg -if app is active and there is no any message then minimize application

xander13th avatar May 23 '15 07:05 xander13th

+1!

arghfrank avatar Aug 09 '15 16:08 arghfrank

merged into #1060

auchri avatar Sep 04 '15 16:09 auchri

Honestly, I think that global shortcuts to open / close software should be implemented not in the application itself but the operating system / window manager around it in order to avoid duplication and conflicts. I know that there are applications that do not follow this principle for ease of use, but that won't scale well if each an every app does it.

Workaround for Windows

Get Autohotkey, if you like shortcuts and automation you'll love it anyway ;)

I ended up using Win+J for Telegram because T was already assigned to Thunderbird - customizing that should be straightforward. I don't have a ready solution for "hide on second press" but mainly using Linux / Gnome the Win+H shortcut to hide any active window is sufficient for me. (Shouldn't be too hard to build "hide on second press" with Autohotkey though.)

; Win+J Telegram
#J::
Run "C:\Users\<!! your username here !!>\AppData\Roaming\Telegram Desktop\Telegram.exe"
return

; Win+H hide window [Hides Windows default keybinding: dictation]
#H::
WinMinimize, A
return

Put this in something.ahk either directly in the autostart folder or add a link to the file there. (%appdata%\Microsoft\Windows\Start Menu\Programs\Startup)

Workaround for Gnome (popular Linux Desktop, default on Fedora, Ubuntu, ...)

You can create shortcuts with the built in "Keyboard Shortcuts" settings page.

I'm not sure if this is needed for Telegram but for many programs I use this little activate_or_run script in order to check for an existing window and pulling it to front instead of running a new instance of the same program.

#!/bin/bash

# Inspiration for possible shortcuts

# Win+Del: activate_or_run gnome-system-monitor.Gnome-system-monitor gnome-system-monitor
# Win+f:   activate_or_run Navigator.Firefox firefox
# Win+t:   activate_or_run Mail.Thunderbird thunderbird
# Win+y:   activate_or_run spotify.Spotify spotify
# Win+k:   activate_or_run keepass2.KeePass2 keepass
# Win+g:   activate_or_run org.gnome.gedit.Org.gnome.gedit gedit
# Win+z:   activate_or_run zim.Zim zim

# Win+j:   activate_or_run telegram-desktop.TelegramDesktop telegram-desktop

# Win+e:   activate_or_run org.gnome.Nautilus.Org.gnome.Nautilus nautilus
# Win+b:   activate_or_run gnome-terminal-server.Gnome-terminal gnome-terminal
# Win+Shift+e: New nautilus
# Win+shift+b: new bash

# To get the class: wmctrl -l -x

WINCLASS=$1
PROGNAME=$2

echo "WINCLASS: $WINCLASS"
echo "Progname: $PROGNAME"

wmctrl -x -a "$WINCLASS"
RCODE=$?
if [ $RCODE != 0 ]
then
    echo "Error bringing to front ($RCODE) -> launching programm"
    $PROGNAME & # window not found, launch given program
else
    echo "No error bringing to front, everything should be okay :)"
fi

exit 0

I have this in ~/.local/bin which is in my $PATH so using Gnome's keyboard shortcuts setting, I just enter the command activate_or_run telegram-desktop.TelegramDesktop telegram-desktop. (First argument is the window class to match, second is the program to run if no such window is present.)

dreua avatar Jun 16 '20 17:06 dreua

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Mar 05 '21 02:03 github-actions[bot]