전체 화면 앱 중에 SUPER 키 끄기


8

게임 세션 또는 전체 화면 앱에서 SUPER 키를 끄는 방법이 있습니까?


네 가능합니다. 나는 이것에 대한 스크립트를 작성하기 시작하고 일단 작동하면 게시 할 것이다
— Sergiy Kolodyazhnyy

대단 할 것입니다!
— Kay T

1
답변 게시 됨,
— 의견

2
향후 방문자를 위해 참고 이전에 특정 창마다 슈퍼 키를 비활성화하기 위해 관련 스크립트를 작성했습니다. 관심이 있으시면 확인하십시오 : askubuntu.com/q/754884/295286
— Sergiy Kolodyazhnyy

답변:


11

소개

다음 스크립트 Super는 X11 창이 전체 화면 모드 인 경우 키를 비활성화 합니다. 시작 응용 프로그램으로 추가되지만 독립 실행 형 모드로 실행될 수도 있습니다.

용법

스크립트를 수동으로 실행하려면 다음을 수행하면됩니다.

python disable_super_key.py

로그인시 스크립이 자동으로 시작되도록하려면 로그인 시 응용 프로그램을 자동으로 시작하려면 어떻게합니까?를 참조하십시오 .

스크립트 소스 코드 얻기

이 답변에서 스크립트 소스를 복사하거나 GitHub 리포지토리 를 복제하여 얻을 수 있습니다 .

다음을 가진 사람들을위한 지침 git:

  1. cd /opt
  2. sudo git clone https://github.com/SergKolo/sergrep.git
  3. chmod -R +x sergrep

스크립트는 /opt/sergrep/disable_super_key.py

스크립트 소스 코드

#!/usr/bin/env python
#
###########################################################
# Author: Serg Kolo , contact: 1047481448@qq.com 
# Date: August 1st , 2016
# Purpose: Disable Super key that calls Unity Dash, when any 
#          X11 window is in fullscreen state
# 
# Written for: https://askubuntu.com/q/805807/295286
# Tested on: Ubuntu 16.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.
from __future__ import print_function
import gi
gi.require_version('Gdk', '3.0')
from gi.repository import  Gdk,Gio
import subprocess
import signal
import time
import sys

debug = False

def gsettings_get(schema,path,key):
    """ fetches value of gsettings schema"""
    if path is None:
        gsettings = Gio.Settings.new(schema)
    else:
        gsettings = Gio.Settings.new_with_path(schema,path)
    return gsettings.get_value(key)

def gsettings_set(schema,path,key,value):
    """ sets value of gsettings schema """
    if path is None:
        gsettings = Gio.Settings.new(schema)
    else:
        gsettings = Gio.Settings.new_with_path(schema,path)
    return gsettings.set_string(key,value)


def gsettings_reset(schema,path,key):
    """ resets schema:key value to default"""
    if path is None:
        gsettings = Gio.Settings.new(schema)
    else:
        gsettings = Gio.Settings.new_with_path(schema,path)
    return gsettings.reset(key)

def run_cmd(cmdlist):
    """ reusable function for running shell commands"""
    try:
        stdout = subprocess.check_output(cmdlist)
    except subprocess.CalledProcessError:
        pass
    else:
        if stdout:
            return stdout


def main():
    """ defines entry point of the program """
    screen = Gdk.Screen.get_default()
    while True:

        key_state = str(gsettings_get('org.compiz.unityshell', 
                                  '/org/compiz/profiles/unity/plugins/unityshell/', 
                                  'show-launcher'))
        active_xid = str(screen.get_active_window().get_xid())
        wm_state =  run_cmd( ['xprop', '-root', '-notype','-id',active_xid, '_NET_WM_STATE'])  

        if debug : print(key_state,wm_state)

        if 'FULLSCREEN' in wm_state:
            if "Super" in  key_state:    
                gsettings_set('org.compiz.unityshell', 
                              '/org/compiz/profiles/unity/plugins/unityshell/',
                              'show-launcher', 
                              'Disabled')

        else:
            if "Disabled" in key_state :
               gsettings_reset( 'org.compiz.unityshell', 
                                '/org/compiz/profiles/unity/plugins/unityshell/',
                                'show-launcher')


        time.sleep(0.25)


def sigterm_handler(*args):
    """ ensures that Super key has been reset upon exit"""
    gsettings_reset( 'org.compiz.unityshell', 
                     '/org/compiz/profiles/unity/plugins/unityshell/',
                     'show-launcher')

    if debug: print('CAUGHT SIGTERM')
    sys.exit(0)


if __name__ == "__main__":
    signal.signal(signal.SIGTERM,sigterm_handler)
    main()

디버깅

디버깅이 필요한 경우 32 행을에서 debug = False로 변경 debug = True하고 명령 행에서 스크립트를 실행하십시오.


이 스크립트를 특정 작업 공간마다 작동하도록 요청 받았습니다. 관심이 있으신 분은 askubuntu.com/a/816512/295286 에서 해결책을 찾으실 수 있습니다. 또한이 스크립트는 스크립트 종료시 SUPER 키를 다시 활성화하기 위해 스크립트 종료를 처리하도록 업데이트되었습니다.
— Sergiy Kolodyazhnyy
당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.