유니티 런처 자동 숨기기를 전환하는 키보드 단축키

유니티 런처 자동 숨기기를 전환하는 키보드 단축키

유닛 런처의 자동 숨기기 옵션을 전환하는 키보드 단축키를 만들고 싶습니다. 에 대한 답변을 바탕으로런처의 숨기기 동작을 프로그래밍 방식으로 변경하는 방법나는 작업을 수행하기 위해 Python 스크립트를 만들려고했습니다. 그런 다음 키보드 단축키를 사용하여 실행하는 방법을 알아내야 합니다.

내 스크립트는 다음과 같습니다

#!/bin/python
AUTOHIDE=$(dconf read /org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode)
if (AUTOHIDE==1):
   dconf write /org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode 0
else:
    dconf write /org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode 1

그러나 터미널에서 스크립트를 실행하는 것('python scriptname.py' 수행)은 작동하지 않습니다. $ 기호에서 "잘못된 구문" 오류가 발생합니다.

나는 Python에 대한 지식(또는 일반적인 스크립트 작성)이 거의 없다는 것을 알아야 합니다. (저는 도움말과 예제를 찾기 위해 웹을 검색하는 데 몇 시간을 보냈습니다.)

실제 질문은 다음과 같습니다.

  • 내가 뭘 잘못했나요?
  • 이에 대해 복잡한 접근 방법을 선택했습니까? 이 경우 어떻게 하면 더 쉽게 할 수 있습니까?

답변1

Python 방식으로 하고 싶다면.

#!/bin/python
import subprocess
AUTOHIDE = subprocess.check_output (["/usr/bin/dconf", "read", "/org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode"])
if (AUTOHIDE==1):
   subprocess.call (["/usr/bin/dconf", "write", "/org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode", "0"])
else:
   subprocess.call (["/usr/bin/dconf", "write", "/org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode", "1"])

하위 프로세스를 생성하여 프로그램을 실행해야 합니다.

그리고 이것은 bash 스크립트 버전입니다

#!/bin/bash
AUTOHIDE=$(dconf read /org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode)
if [[ $AUTOHIDE -eq 1 ]]
then
   dconf write /org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode 0
else
   dconf write /org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode 1
fi

바로가기는 다음과 같이 할당할 수 있습니다.이것.

답변2

이를 수행하는 한 가지 방법은 사용자 정의 바로가기를 만드는 것입니다.

시스템 설정 > 키보드 > 단축키 > 사용자 정의 단축키에 액세스한 다음 '+'를 클릭하여 새 단축키를 추가하고 명령 상자에 다음을 붙여넣습니다.

dconf write /org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode 0

그러면 런처를 표시하기 위한 바로가기가 생성됩니다. 이제 런처를 숨기려면 다음 명령을 추가하여 또 다른 바로가기를 만들어야 합니다.

dconf write /org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode 1

물론 이제 각 기능에 대해 하나의 명령을 가지게 되지만, 나란히 배치해 보니 매우 직관적입니다.

답변3

Unity 2D의 경우 dconf 라인은 다음과 같아야 합니다.

/com/canonical/unity-2d/launcher/hide-mode

값이 2인 세 번째 모드인 "Intellihide"도 있습니다.

관련 정보