You are not logged in.

#1 2012-04-15 08:38:03

bbq
Member
Registered: 2011-05-07
Posts: 14

[Solved]Shortcut key to toggle terminal display in KDE?

I want to minimize/unminimize my Konsole with a shortcut key for example "F1".
Just like tilda do, but all I want is the shortcut key function.
I found a way to add a global shortcut key in KDE control center and I can bind a key with a script or a dbus command.
However, I don't know how to toggle minimize/unminimize a program with a script or a dbus command.
Does someone have a idea? Thx!

Last edited by bbq (2012-04-17 11:54:45)


Documents speak over the programs.

Offline

#2 2012-04-15 12:12:58

Yggdrasil
Member
Registered: 2009-07-21
Posts: 37

Re: [Solved]Shortcut key to toggle terminal display in KDE?

Maybe just use yakuake.

What you describe is often called "run or raise". I found this thread after a quick search:
http://ubuntuforums.org/showthread.php?t=1381892

Looks like you can use wmctrl to interact with the window manager. Never used it myself through.

Btw, kwin allows window shortcuts to raise a specific window, but not the same key to minimize:
http://forum.kde.org/brainstorm.php?mode=idea&i=55522
If you follow the links you might land there (alternative to wmctrl):
http://kde-apps.org/content/show.php/WM … tent=40425

Offline

#3 2012-04-16 09:54:35

bbq
Member
Registered: 2011-05-07
Posts: 14

Re: [Solved]Shortcut key to toggle terminal display in KDE?

Yggdrasil wrote:

Maybe just use yakuake.

What you describe is often called "run or raise". I found this thread after a quick search:
http://ubuntuforums.org/showthread.php?t=1381892

Looks like you can use wmctrl to interact with the window manager. Never used it myself through.

Btw, kwin allows window shortcuts to raise a specific window, but not the same key to minimize:
http://forum.kde.org/brainstorm.php?mode=idea&i=55522
If you follow the links you might land there (alternative to wmctrl):
http://kde-apps.org/content/show.php/WM … tent=40425

Thank you, Yggdrasil! I also find the  shortcuts to raise a specific window before.
Now I found the way to "run or raise" my Konsole now via xdotool.

I wrote a Script to do these work. Simply using toggleWindow WINDOWCLASS to toggle a window with specified class.
Here is my script:

#!/bin/bash
#filename:toggleWindow
#Written by bbq 
#Mon Apr 16 20:04:12 CST 2012
#Usage: toggleWindow WINDOWCLASS

#check if has an given window
if [[ -z "$1" ]]
then
	echo -e "USAGE: toggleWindow WINDOWCLASS\nAborting...\n"
	exit
fi

#check if the xdotool is installed
hash xdotool 2>/dev/null || { echo -e >&2 "I require xdotool but it's not installed. Please install it first!\n Aborting.\n"; exit 1; }

activeWin=`xdotool getactivewindow`
searchList=`xdotool search --class $1`

if [[ -z "$searchList" ]]
then
	echo "No windows found. Exit"
	exit
fi

echo `echo $searchList | grep $activeWin`
if [[ `echo $searchList | grep $activeWin` ]] 
then
	for i in $searchList
	do
		xdotool windowminimize $i
	done
	echo minimized $1
else
	for i in $searchList
	do
		xdotool windowactivate $i
	done
	echo raised $1
fi

Last edited by bbq (2012-04-17 11:43:23)


Documents speak over the programs.

Offline

Board footer

Powered by FluxBB