![Deshabilitar la tecla cuando el programa se está ejecutando](https://rvso.com/image/1087123/Deshabilitar%20la%20tecla%20cuando%20el%20programa%20se%20est%C3%A1%20ejecutando.png)
Duplicar pregunta a¿Cómo desactivar la clave mientras se ejecuta un programa específico?, que nunca fue respondida. (¿Qué opción es peor, volver a publicar la misma pregunta o hacer necro en la publicación anterior?)
De todos modos, ¿hay alguna manera de desactivar claves específicas cuando se ejecutan programas específicos? ¿O, alternativamente, desactivar Dash cuando se esté ejecutando un programa específico?
Respuesta1
Solución simple
Cree dos atajos, uno para deshabilitar la Superclave y otro para restaurarla a voluntad.
Vaya a Configuración del sistema -> Teclado -> Atajos -> Personalizado y haga clic en +el botón. Nombra el nuevo acceso directo como "Desactivar Dash". El comando es
gsettings set org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ show-launcher 'Disabled'
Para crear un acceso directo para volver a habilitar el script, repita los pasos anteriores, pero el comando debe ser
gsettings set org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ show-launcher '<Super>'
Una solución de secuencias de comandos
El siguiente script deshabilitará la Superclave cuando el programa que el usuario haya especificado tenga el foco. Tenga en cuenta que el usuario aún puede hacer clic en el icono del guión con el mouse para invocar el guión. El nombre del programa debe estar entre comillas simples y ser exactamente igual al que aparece en Unity Launcher. Se pueden especificar varias ventanas en el mismo formato separadas por espacios.
Por ejemplo, para deshabilitar la Super clave cada vez que la ventana de Firefox tiene el foco, el script debe llamarse como
disable_super_key.sh 'Firefox Web Browser'
Para desactivar ambos firefox
y gnome-terminal
hacer
disable_super_key.sh 'Firefox Web Browser' 'Terminal'
Cómo conseguir el guión
Los usuarios pueden copiar el código fuente aquí o, alternativamente, obtenerlo de github siguiendo las instrucciones a continuación:
sudo apt-get install git
cd /opt ; sudo git clone https://github.com/SergKolo/sergrep.git
sudo chmod -R +x sergrep
El guión estará ubicado en/opt/sergrep/disable_super_key.sh
Para hacer que el script se inicie automáticamente en cada inicio de sesión, consulte¿Cómo inicio aplicaciones automáticamente al iniciar sesión?. Proporcionar /opt/sergrep/disable_super_key.sh
(ruta completa) como comando
Fuente del guión
#!/usr/bin/env bash
#
###########################################################
# Author: Serg Kolo , contact: [email protected]
# Date: April 12 , 2016
# Purpose: Disable super key that brings up Unity Dash
# per specific application
#
# Written for: https://askubuntu.com/q/754884/295286
# Tested on: Ubuntu 14.04 LTS
###########################################################
# Copyright: Serg Kolo , 2016
#
# Permission to use, copy, modify, and distribute this software is hereby granted
# without fee, provided that the copyright notice above and this permission statement
# appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
ARGV0="$0"
ARGC=$#
enable_dash_key()
{
gsettings set org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ show-launcher '<Super>'
}
disable_dash_key()
{
gsettings set org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ show-launcher 'Disabled'
}
get_active_app()
{
qdbus org.ayatana.bamf \
/org/ayatana/bamf/matcher \
org.ayatana.bamf.matcher.ActiveApplication
}
get_active_app_name()
{
qdbus org.ayatana.bamf \
$(get_active_app) \
org.ayatana.bamf.view.Name
}
check_active_app()
{
active_name=$(get_active_app_name)
local is_found
for win in "${windows_list[@]}"
do
if [ "$active_name" = "$win" ] ; then
is_found=true
break
else
is_found=false
fi
done
if $is_found ; then
disable_dash_key
else
enable_dash_key
fi
}
print_usage()
{
cat << EOF
Copyright Serg Kolo , 2016
Usage: disable_super_key.sh 'App Name 1' [ 'App Name 2' 'App Name 3' ... ]
The script disables the Super key for the specified set of applications
under Ubuntu's Unity environment. The list of windows must be space
separated, each app name single quoted and exactly as it appears on the
launcher (or as it appears in the .desktop file of that app), so spelling
and spacing matter.
Note that the script only disables the Super key as shortcut for Dash.
The user still will be able to invoke Dash by manually clicking on the
Ubuntu icon in the launcher
EOF
}
main()
{
if [ $ARGC -eq 0 ]; then
print_usage
exit
fi
local windows_list
windows_list=( "$@" )
dbus-monitor --profile "type='signal',member='FocusedWindowChanged'" |\
while read line
do
case "$line" in
*FocusedWindowChanged*) check_active_app ;;
esac
done
}
main "$@"