Zim

[Feature request] Assign hotkey to Tray Icon

Asked by jess

The Tray Icon plugin is very useful - particularly the ability to toggle the visibility of the main window by clicking the tray icon. As far as I can tell, there is no way to assign a hotkey (keyboard accelerator/shortcut) to simulate clicking the tray icon in the current version (Zim 0.65 on Linux Mint 17.2). Would it be possible to implement such a feature? Or is there already a way to do it which I haven't found?

Question information

Language:
English Edit question
Status:
Solved
For:
Zim Edit question
Assignee:
No assignee Edit question
Solved by:
jess
Solved:
Last query:
Last reply:
Revision history for this message
jess (jess-harpur) said :
#1

I found a way to do what I want using xdotool (http://www.semicomplete.com/projects/xdotool/xdotool.xhtml) via a shell script activated by a system keyboard shortcut. The script starts Zim if it's not running, or toggles its visibility state if it is. It works on my setup (Zim 0.65 on Linux Mint 17.2). Note that it's not compatible with the Tray Icon plugin. Here's the script for anyone who's interested:

#!/bin/bash
# =========================================
# Toggle Zim Visibility
#
# Assign this script to a keyboard shortcut
#
# Starts Zim if it isn't running, otherwise
# toggles it's visibility state
#
# Dependency: xdotool, xrandr, grep
#
# Jess Harpur 2015
# =========================================

###########################
# Edit name of Zim Notebook
notebook='MyNotebook'
###########################

# Get Zim status
PID=`xdotool search --name $notebook" - Zim"`
VIS=`xdotool search --onlyvisible --name $notebook" - Zim"`

# Calculate x co-ord for Zim window
xw=`xrandr | grep '*' | cut -dx -f1`
xx=`echo "$(($xw-600))"`

# Run, hide, or show Zim
if [ "$PID" = "" ]
then
 xdotool exec zim $notebook
elif [ "$PID" = "$VIS" ]
then
 xdotool windowunmap $PID
else
 xdotool windowmap --sync $PID windowmove --sync $PID $xx 0 windowactivate --sync $PID
fi