Я написал фрагмент кода python, чтобы вы могли использовать технику xinput, не выполняя всю ручную работу. Copyleft, AS-IS, без гарантии, используйте на свой страх и риск. Отлично работает для меня: и если вы используете gnome, просто сопоставьте его с ключевым ярлыком, например CtrlShiftT.
#!/usr/bin/python2
# -*- coding: utf-8 -*-
'''Program to toggle Touchpad Enable to Disable or vice-versa.'''
import commands
import re
def current_id():
""" Search through the output of xinput and find the line that has the
word TouchPad. At that point, I believe we can find the ID of that device."""
props = commands.getoutput("xinput").split("\n")
match = [line for line in props if "TouchPad" in line]
assert len(match) == 1, "Problem finding Touchpad string! %s" % match
pat = re.match(r"(.*)id=(\d+)", match[0])
assert pat, "No matching ID found!"
return int(pat.group(2))
def current_status(tpad_id):
"""Find the current Device ID, it has to have the word TouchPad in the line."""
props = commands.getoutput("""xinput list-props %d""" % tpad_id).split('\n')
match = [line for line in props if "Device Enabled" in line]
assert len(match) == 1, "Can't find the status of device #%d" % tpad_id
pat = re.match(r"(.*):\s*(\d+)", match[0])
assert pat, "No matching status found!"
return int(pat.group(2))
def flop(tpad_id, status):
"""Change the value of status, and call xinput to reverse that status."""
if status == 0:
status = 1
else:
status = 0
print "Changing Device #%d Device Enabled %d" % (tpad_id, status)
commands.getoutput("""xinput set-prop %d "Device Enabled" %d""" % (tpad_id, status))
def main():
"""Get curent device id and status, and flop status value."""
tpad = current_id()
stat = current_status(tpad)
flop(tpad, stat)
main()
Цвета перестали работать, скорее всего после обновления до Lion из Snow Leopard .
В Lion по какой-то причине по умолчанию терминал объявляется как «xterm-256color» вместо «xterm-color», что понимает Ubuntu.
Один из вариантов для вас, как упоминалось предыдущими респондентами, uncomment force_color_prompt = yes
в ~ / .bashrc
Другой вариант заключается в том, чтобы обновить в Terminal.app терминал как xterm-color. Вот как это сделать:
Настройки
и найдите тему, установленную по умолчанию Advanced
Объявить терминал как:
и установить его в xterm-color UPDATE: Кажется, что Mountain Lion полностью удалил параметр xterm-color из выпадающего меню. Если вы выполняете обновление, вы, скорее всего, сохраните свою прежнюю конфигурацию, но если вы делаете новую установку, вам придется вручную изменить конфигурационный файл терминала, и для этого вам понадобится редактор plist (входит в XCode , которые необходимо установить через App Store). Расположение файла терминала находится в ~ / Library / Preferences / com.apple.Terminal.plist, чтобы добавить параметр xterm-color, выполните следующие действия:
$ open ~ / Library / Preferences / com.apple.Terminal.plist
Root & gt; Настройки окна
TerminalType
. TerminalType
на xterm-color вручную У вас есть одна альтернатива: создать файл .bash_login
, если он еще не существует в вашем домашнем каталоге, и поместить внутри него .bashrc
.
Закройте терминал и снова его откройте - ваша проблема должна быть решена!