Установить пакет «gpointing-device-settings» Установить следующие параметры:
check "Use middle button emulation"
check "Use wheel emulation"
select button "2"
check "Enable vertical scroll"
Редактировать: Rinzwind опрокинул меня на проект с пусковой площадкой под названием «wiican». По-видимому, он реализован как индикаторный апплет и позволяет настраивать ваши действия wii. Вы можете связать, например. amarok -t к wiibutton.
Вам повезло, и вы даже не знаете, сколько. Мне потребовалось некоторое время и немного исследований, но: я написал сценарий, чтобы сделать это некоторое время назад. Он работает с Amarok и Totem, хотя его можно легко модифицировать для управления другими игроками (при условии, что они имеют интерфейс командной строки). Дайте мне несколько минут, чтобы написать несколько комментариев. Затем отредактируйте этот ответ и опубликуйте его.
Особенности: Проверьте состояние батареи Wiimote. Включите светодиод на Wiimote. Начните Амарок. Пауза / продолжение воспроизведения. Перейти к следующему / последнему треку. Управление системным томом по alsamixerВам понадобятся питон и Rinzwind / sudo apt-get install python-cwiid. Вы можете сделать это, ожидая.
Ниже приведен сценарий. Просто запустите его в терминале.
#!/usr/bin/python
# indent-mode: spaces, indentsize: 4, encoding: utf-8
# © 2011 con-f-use@gmx.net.
# Use permitted under MIT license:
# http://www.opensource.org/licenses/mit-license.php (NO WARRANTY IMPLIED)
"""A Wiimote script to control totem and amarok under Ubuntu.
Provides a rudimentary interface to:
-Check battery status of the Wiimote.
-Switch an led on the Wiimote.
-Start Amarok.
-Pause/contiue playing.
-Skip to next/last track.
-Control the system volume over pulseaudio
Needs the package 'python-cwiid', 'amarok' and or 'totem' to be installed.
Globals:
wiimote -- the wiimote object
led -- the status of the led (on/off)
"""
import cwiid
import sys
import os
def main():
"""PC-side interface handles interaction between pc and user.
b -- battery status
l -- toggle led
q -- quit
h -- print help
"""
global wiimote
connect_wiimote()
#Print help text ont startup
print 'Confirm each command with ENTER.'
hlpmsg = 'Press q to quit\n'\
'b for battery status\n'\
'l to toggle the led on/off\n'\
'h or any other key to display this message.'
print hlpmsg
#Main loop for user interaction
doLoop = True
while doLoop:
c = sys.stdin.read(1)
if c == 'b': # battery status
state = wiimote.state
bat = int(100.0 * state['battery'] / cwiid.BATTERY_MAX)
print bat
elif c == 'l': # toggle led
toggle_led()
elif c == 'q': # exit program
doLoop = False
elif c == '\n': # ignore newlines
pass
else: # print help message when no valid command is issued
print hlpmsg
#Close connection and exit
wiimote.close()
def connect_wiimote():
"""Connets your computer to a Wiimote."""
print 'Put Wiimote in discoverable mode now (press 1+2)...'
global wiimote
while True:
try:
wiimote = cwiid.Wiimote(#add address of Wiimote here for speedup)
break
except:
continue
wiimote.mesg_callback = callback
#Set Wiimote options
global led
led = True
wiimote.led = cwiid.LED1_ON
wiimote.rpt_mode = cwiid.RPT_BTN
wiimote.enable(cwiid.FLAG_MESG_IFC)
def callback(mesg_list, time):
"""Handels the interaction between Wiimote and user.
A and B together -- toggle led
A -- play/pause
up / down -- fast forward / backward
right / left -- next / previous trakc
+ / - -- increase / decreas volume
"""
for mesg in mesg_list:
# Handle Buttonpresses - add hex-values for simultaneous presses
# Buttons not listed: 0x4 - B, 0x1 - 2, 0x2 - 1 | just babytown frolics
if mesg[0] == cwiid.MESG_BTN:
if mesg[1] == 0x8: # A botton
player_control('playpause')
elif mesg[1] == 0xC: # A and B together
toggle_led()
elif mesg[1] == 0x800: # Up botton
player_control('ffwd')
elif mesg[1] == 0x100: # Left botton
player_control('lasttrack')
elif mesg[1] == 0x200: # Right botton
player_control('nexttrack')
elif mesg[1] == 0x400: # Down botton
player_control('fbwd')
elif mesg[1] == 0x10: # Minus botton
change_volume(-1)
elif mesg[1] == 0x1000: # Plus botton
change_volume(1)
elif mesg[1] == 0x80: # home botton
shut_down()
# Handle errormessages
elif mesg[0] == cwiid.MESG_ERROR:
global wiimote
wiimote.close()
connect_wiimote()
def change_volume(change):
"""Changes system's master volume."""
cmd = "amixer get Master | grep 'Front Left' | grep -oP '(?<=Playback\ )\d+'"
fin,fout = os.popen4(cmd)
currVol = int( fout.read() )
newVol = currVol + change
os.system( "amixer set Master "+str(newVol) )
def toggle_led():
"""Toggles first led on Wiimote on/off."""
global led
if led == True:
led = False
wiimote.led = 0
else:
led = True
wiimote.led = cwiid.LED1_ON
def player_control(action):
"""Controls Amarok or Totem - depending on wich one is running.
Totem takes precedence over Amarok if running. If none is running, Amarok
will be started ant take the command.
"""
print action
# Check if totem is running
cmd = "ps -A | grep -oP 'totem'"
fin,fout = os.popen4(cmd)
isTotem = fout.read()
isTotem = isTotem.find('totem') != -1
# Do the actual player action
if action == 'nexttrack':
if isTotem:
cmd = "totem --next"
else:
cmd = "amarok -f"
elif action == 'lasttrack':
if isTotem:
cmd = "totem --previous"
else:
cmd = "amarok -r"
elif action == 'playpause':
if isTotem:
cmd = "totem --play-pause"
else:
cmd = "amarok -t"
elif action == 'ffwd':
if isTotem:
cmd = "totem --seek-fwd"
elif action == 'fbwd':
if isTotem:
cmd = "totem --seek-bwd"
os.system(cmd)
main()
Редактировать: Rinzwind опрокинул меня на проект с пусковой площадкой под названием «wiican». По-видимому, он реализован как индикаторный апплет и позволяет настраивать ваши действия wii. Вы можете связать, например. amarok -t к wiibutton.
Вам повезло, и вы даже не знаете, сколько. Мне потребовалось некоторое время и немного исследований, но: я написал сценарий, чтобы сделать это некоторое время назад. Он работает с Amarok и Totem, хотя его можно легко модифицировать для управления другими игроками (при условии, что они имеют интерфейс командной строки). Дайте мне несколько минут, чтобы написать несколько комментариев. Затем отредактируйте этот ответ и опубликуйте его.
Особенности: Проверьте состояние батареи Wiimote. Включите светодиод на Wiimote. Начните Амарок. Пауза / продолжение воспроизведения. Перейти к следующему / последнему треку. Управление системным томом по alsamixerВам понадобятся питон и Rinzwind / sudo apt-get install python-cwiid. Вы можете сделать это, ожидая.
Ниже приведен сценарий. Просто запустите его в терминале.
#!/usr/bin/python
# indent-mode: spaces, indentsize: 4, encoding: utf-8
# © 2011 con-f-use@gmx.net.
# Use permitted under MIT license:
# http://www.opensource.org/licenses/mit-license.php (NO WARRANTY IMPLIED)
"""A Wiimote script to control totem and amarok under Ubuntu.
Provides a rudimentary interface to:
-Check battery status of the Wiimote.
-Switch an led on the Wiimote.
-Start Amarok.
-Pause/contiue playing.
-Skip to next/last track.
-Control the system volume over pulseaudio
Needs the package 'python-cwiid', 'amarok' and or 'totem' to be installed.
Globals:
wiimote -- the wiimote object
led -- the status of the led (on/off)
"""
import cwiid
import sys
import os
def main():
"""PC-side interface handles interaction between pc and user.
b -- battery status
l -- toggle led
q -- quit
h -- print help
"""
global wiimote
connect_wiimote()
#Print help text ont startup
print 'Confirm each command with ENTER.'
hlpmsg = 'Press q to quit\n'\
'b for battery status\n'\
'l to toggle the led on/off\n'\
'h or any other key to display this message.'
print hlpmsg
#Main loop for user interaction
doLoop = True
while doLoop:
c = sys.stdin.read(1)
if c == 'b': # battery status
state = wiimote.state
bat = int(100.0 * state['battery'] / cwiid.BATTERY_MAX)
print bat
elif c == 'l': # toggle led
toggle_led()
elif c == 'q': # exit program
doLoop = False
elif c == '\n': # ignore newlines
pass
else: # print help message when no valid command is issued
print hlpmsg
#Close connection and exit
wiimote.close()
def connect_wiimote():
"""Connets your computer to a Wiimote."""
print 'Put Wiimote in discoverable mode now (press 1+2)...'
global wiimote
while True:
try:
wiimote = cwiid.Wiimote(#add address of Wiimote here for speedup)
break
except:
continue
wiimote.mesg_callback = callback
#Set Wiimote options
global led
led = True
wiimote.led = cwiid.LED1_ON
wiimote.rpt_mode = cwiid.RPT_BTN
wiimote.enable(cwiid.FLAG_MESG_IFC)
def callback(mesg_list, time):
"""Handels the interaction between Wiimote and user.
A and B together -- toggle led
A -- play/pause
up / down -- fast forward / backward
right / left -- next / previous trakc
+ / - -- increase / decreas volume
"""
for mesg in mesg_list:
# Handle Buttonpresses - add hex-values for simultaneous presses
# Buttons not listed: 0x4 - B, 0x1 - 2, 0x2 - 1 | just babytown frolics
if mesg[0] == cwiid.MESG_BTN:
if mesg[1] == 0x8: # A botton
player_control('playpause')
elif mesg[1] == 0xC: # A and B together
toggle_led()
elif mesg[1] == 0x800: # Up botton
player_control('ffwd')
elif mesg[1] == 0x100: # Left botton
player_control('lasttrack')
elif mesg[1] == 0x200: # Right botton
player_control('nexttrack')
elif mesg[1] == 0x400: # Down botton
player_control('fbwd')
elif mesg[1] == 0x10: # Minus botton
change_volume(-1)
elif mesg[1] == 0x1000: # Plus botton
change_volume(1)
elif mesg[1] == 0x80: # home botton
shut_down()
# Handle errormessages
elif mesg[0] == cwiid.MESG_ERROR:
global wiimote
wiimote.close()
connect_wiimote()
def change_volume(change):
"""Changes system's master volume."""
cmd = "amixer get Master | grep 'Front Left' | grep -oP '(?<=Playback\ )\d+'"
fin,fout = os.popen4(cmd)
currVol = int( fout.read() )
newVol = currVol + change
os.system( "amixer set Master "+str(newVol) )
def toggle_led():
"""Toggles first led on Wiimote on/off."""
global led
if led == True:
led = False
wiimote.led = 0
else:
led = True
wiimote.led = cwiid.LED1_ON
def player_control(action):
"""Controls Amarok or Totem - depending on wich one is running.
Totem takes precedence over Amarok if running. If none is running, Amarok
will be started ant take the command.
"""
print action
# Check if totem is running
cmd = "ps -A | grep -oP 'totem'"
fin,fout = os.popen4(cmd)
isTotem = fout.read()
isTotem = isTotem.find('totem') != -1
# Do the actual player action
if action == 'nexttrack':
if isTotem:
cmd = "totem --next"
else:
cmd = "amarok -f"
elif action == 'lasttrack':
if isTotem:
cmd = "totem --previous"
else:
cmd = "amarok -r"
elif action == 'playpause':
if isTotem:
cmd = "totem --play-pause"
else:
cmd = "amarok -t"
elif action == 'ffwd':
if isTotem:
cmd = "totem --seek-fwd"
elif action == 'fbwd':
if isTotem:
cmd = "totem --seek-bwd"
os.system(cmd)
main()
Редактировать: Rinzwind опрокинул меня на проект с пусковой площадкой под названием «wiican». По-видимому, он реализован как индикаторный апплет и позволяет настраивать ваши действия wii. Вы можете связать, например. amarok -t к wiibutton.
Вам повезло, и вы даже не знаете, сколько. Мне потребовалось некоторое время и немного исследований, но: я написал сценарий, чтобы сделать это некоторое время назад. Он работает с Amarok и Totem, хотя его можно легко модифицировать для управления другими игроками (при условии, что они имеют интерфейс командной строки). Дайте мне несколько минут, чтобы написать несколько комментариев. Затем отредактируйте этот ответ и опубликуйте его.
Особенности: Проверьте состояние батареи Wiimote. Включите светодиод на Wiimote. Начните Амарок. Пауза / продолжение воспроизведения. Перейти к следующему / последнему треку. Управление системным томом по alsamixerВам понадобятся питон и Rinzwind / sudo apt-get install python-cwiid. Вы можете сделать это, ожидая.
Ниже приведен сценарий. Просто запустите его в терминале.
#!/usr/bin/python
# indent-mode: spaces, indentsize: 4, encoding: utf-8
# © 2011 con-f-use@gmx.net.
# Use permitted under MIT license:
# http://www.opensource.org/licenses/mit-license.php (NO WARRANTY IMPLIED)
"""A Wiimote script to control totem and amarok under Ubuntu.
Provides a rudimentary interface to:
-Check battery status of the Wiimote.
-Switch an led on the Wiimote.
-Start Amarok.
-Pause/contiue playing.
-Skip to next/last track.
-Control the system volume over pulseaudio
Needs the package 'python-cwiid', 'amarok' and or 'totem' to be installed.
Globals:
wiimote -- the wiimote object
led -- the status of the led (on/off)
"""
import cwiid
import sys
import os
def main():
"""PC-side interface handles interaction between pc and user.
b -- battery status
l -- toggle led
q -- quit
h -- print help
"""
global wiimote
connect_wiimote()
#Print help text ont startup
print 'Confirm each command with ENTER.'
hlpmsg = 'Press q to quit\n'\
'b for battery status\n'\
'l to toggle the led on/off\n'\
'h or any other key to display this message.'
print hlpmsg
#Main loop for user interaction
doLoop = True
while doLoop:
c = sys.stdin.read(1)
if c == 'b': # battery status
state = wiimote.state
bat = int(100.0 * state['battery'] / cwiid.BATTERY_MAX)
print bat
elif c == 'l': # toggle led
toggle_led()
elif c == 'q': # exit program
doLoop = False
elif c == '\n': # ignore newlines
pass
else: # print help message when no valid command is issued
print hlpmsg
#Close connection and exit
wiimote.close()
def connect_wiimote():
"""Connets your computer to a Wiimote."""
print 'Put Wiimote in discoverable mode now (press 1+2)...'
global wiimote
while True:
try:
wiimote = cwiid.Wiimote(#add address of Wiimote here for speedup)
break
except:
continue
wiimote.mesg_callback = callback
#Set Wiimote options
global led
led = True
wiimote.led = cwiid.LED1_ON
wiimote.rpt_mode = cwiid.RPT_BTN
wiimote.enable(cwiid.FLAG_MESG_IFC)
def callback(mesg_list, time):
"""Handels the interaction between Wiimote and user.
A and B together -- toggle led
A -- play/pause
up / down -- fast forward / backward
right / left -- next / previous trakc
+ / - -- increase / decreas volume
"""
for mesg in mesg_list:
# Handle Buttonpresses - add hex-values for simultaneous presses
# Buttons not listed: 0x4 - B, 0x1 - 2, 0x2 - 1 | just babytown frolics
if mesg[0] == cwiid.MESG_BTN:
if mesg[1] == 0x8: # A botton
player_control('playpause')
elif mesg[1] == 0xC: # A and B together
toggle_led()
elif mesg[1] == 0x800: # Up botton
player_control('ffwd')
elif mesg[1] == 0x100: # Left botton
player_control('lasttrack')
elif mesg[1] == 0x200: # Right botton
player_control('nexttrack')
elif mesg[1] == 0x400: # Down botton
player_control('fbwd')
elif mesg[1] == 0x10: # Minus botton
change_volume(-1)
elif mesg[1] == 0x1000: # Plus botton
change_volume(1)
elif mesg[1] == 0x80: # home botton
shut_down()
# Handle errormessages
elif mesg[0] == cwiid.MESG_ERROR:
global wiimote
wiimote.close()
connect_wiimote()
def change_volume(change):
"""Changes system's master volume."""
cmd = "amixer get Master | grep 'Front Left' | grep -oP '(?<=Playback\ )\d+'"
fin,fout = os.popen4(cmd)
currVol = int( fout.read() )
newVol = currVol + change
os.system( "amixer set Master "+str(newVol) )
def toggle_led():
"""Toggles first led on Wiimote on/off."""
global led
if led == True:
led = False
wiimote.led = 0
else:
led = True
wiimote.led = cwiid.LED1_ON
def player_control(action):
"""Controls Amarok or Totem - depending on wich one is running.
Totem takes precedence over Amarok if running. If none is running, Amarok
will be started ant take the command.
"""
print action
# Check if totem is running
cmd = "ps -A | grep -oP 'totem'"
fin,fout = os.popen4(cmd)
isTotem = fout.read()
isTotem = isTotem.find('totem') != -1
# Do the actual player action
if action == 'nexttrack':
if isTotem:
cmd = "totem --next"
else:
cmd = "amarok -f"
elif action == 'lasttrack':
if isTotem:
cmd = "totem --previous"
else:
cmd = "amarok -r"
elif action == 'playpause':
if isTotem:
cmd = "totem --play-pause"
else:
cmd = "amarok -t"
elif action == 'ffwd':
if isTotem:
cmd = "totem --seek-fwd"
elif action == 'fbwd':
if isTotem:
cmd = "totem --seek-bwd"
os.system(cmd)
main()
Редактировать: Rinzwind опрокинул меня на проект с пусковой площадкой под названием «wiican». По-видимому, он реализован как индикаторный апплет и позволяет настраивать ваши действия wii. Вы можете связать, например. amarok -t к wiibutton.
Вам повезло, и вы даже не знаете, сколько. Мне потребовалось некоторое время и немного исследований, но: я написал сценарий, чтобы сделать это некоторое время назад. Он работает с Amarok и Totem, хотя его можно легко модифицировать для управления другими игроками (при условии, что они имеют интерфейс командной строки). Дайте мне несколько минут, чтобы написать несколько комментариев. Затем отредактируйте этот ответ и опубликуйте его.
Особенности: Проверьте состояние батареи Wiimote. Включите светодиод на Wiimote. Начните Амарок. Пауза / продолжение воспроизведения. Перейти к следующему / последнему треку. Управление системным томом по alsamixerВам понадобятся питон и Rinzwind / sudo apt-get install python-cwiid. Вы можете сделать это, ожидая.
Ниже приведен сценарий. Просто запустите его в терминале.
#!/usr/bin/python
# indent-mode: spaces, indentsize: 4, encoding: utf-8
# © 2011 con-f-use@gmx.net.
# Use permitted under MIT license:
# http://www.opensource.org/licenses/mit-license.php (NO WARRANTY IMPLIED)
"""A Wiimote script to control totem and amarok under Ubuntu.
Provides a rudimentary interface to:
-Check battery status of the Wiimote.
-Switch an led on the Wiimote.
-Start Amarok.
-Pause/contiue playing.
-Skip to next/last track.
-Control the system volume over pulseaudio
Needs the package 'python-cwiid', 'amarok' and or 'totem' to be installed.
Globals:
wiimote -- the wiimote object
led -- the status of the led (on/off)
"""
import cwiid
import sys
import os
def main():
"""PC-side interface handles interaction between pc and user.
b -- battery status
l -- toggle led
q -- quit
h -- print help
"""
global wiimote
connect_wiimote()
#Print help text ont startup
print 'Confirm each command with ENTER.'
hlpmsg = 'Press q to quit\n'\
'b for battery status\n'\
'l to toggle the led on/off\n'\
'h or any other key to display this message.'
print hlpmsg
#Main loop for user interaction
doLoop = True
while doLoop:
c = sys.stdin.read(1)
if c == 'b': # battery status
state = wiimote.state
bat = int(100.0 * state['battery'] / cwiid.BATTERY_MAX)
print bat
elif c == 'l': # toggle led
toggle_led()
elif c == 'q': # exit program
doLoop = False
elif c == '\n': # ignore newlines
pass
else: # print help message when no valid command is issued
print hlpmsg
#Close connection and exit
wiimote.close()
def connect_wiimote():
"""Connets your computer to a Wiimote."""
print 'Put Wiimote in discoverable mode now (press 1+2)...'
global wiimote
while True:
try:
wiimote = cwiid.Wiimote(#add address of Wiimote here for speedup)
break
except:
continue
wiimote.mesg_callback = callback
#Set Wiimote options
global led
led = True
wiimote.led = cwiid.LED1_ON
wiimote.rpt_mode = cwiid.RPT_BTN
wiimote.enable(cwiid.FLAG_MESG_IFC)
def callback(mesg_list, time):
"""Handels the interaction between Wiimote and user.
A and B together -- toggle led
A -- play/pause
up / down -- fast forward / backward
right / left -- next / previous trakc
+ / - -- increase / decreas volume
"""
for mesg in mesg_list:
# Handle Buttonpresses - add hex-values for simultaneous presses
# Buttons not listed: 0x4 - B, 0x1 - 2, 0x2 - 1 | just babytown frolics
if mesg[0] == cwiid.MESG_BTN:
if mesg[1] == 0x8: # A botton
player_control('playpause')
elif mesg[1] == 0xC: # A and B together
toggle_led()
elif mesg[1] == 0x800: # Up botton
player_control('ffwd')
elif mesg[1] == 0x100: # Left botton
player_control('lasttrack')
elif mesg[1] == 0x200: # Right botton
player_control('nexttrack')
elif mesg[1] == 0x400: # Down botton
player_control('fbwd')
elif mesg[1] == 0x10: # Minus botton
change_volume(-1)
elif mesg[1] == 0x1000: # Plus botton
change_volume(1)
elif mesg[1] == 0x80: # home botton
shut_down()
# Handle errormessages
elif mesg[0] == cwiid.MESG_ERROR:
global wiimote
wiimote.close()
connect_wiimote()
def change_volume(change):
"""Changes system's master volume."""
cmd = "amixer get Master | grep 'Front Left' | grep -oP '(?<=Playback\ )\d+'"
fin,fout = os.popen4(cmd)
currVol = int( fout.read() )
newVol = currVol + change
os.system( "amixer set Master "+str(newVol) )
def toggle_led():
"""Toggles first led on Wiimote on/off."""
global led
if led == True:
led = False
wiimote.led = 0
else:
led = True
wiimote.led = cwiid.LED1_ON
def player_control(action):
"""Controls Amarok or Totem - depending on wich one is running.
Totem takes precedence over Amarok if running. If none is running, Amarok
will be started ant take the command.
"""
print action
# Check if totem is running
cmd = "ps -A | grep -oP 'totem'"
fin,fout = os.popen4(cmd)
isTotem = fout.read()
isTotem = isTotem.find('totem') != -1
# Do the actual player action
if action == 'nexttrack':
if isTotem:
cmd = "totem --next"
else:
cmd = "amarok -f"
elif action == 'lasttrack':
if isTotem:
cmd = "totem --previous"
else:
cmd = "amarok -r"
elif action == 'playpause':
if isTotem:
cmd = "totem --play-pause"
else:
cmd = "amarok -t"
elif action == 'ffwd':
if isTotem:
cmd = "totem --seek-fwd"
elif action == 'fbwd':
if isTotem:
cmd = "totem --seek-bwd"
os.system(cmd)
main()
Редактировать: Rinzwind опрокинул меня на проект с пусковой площадкой под названием «wiican». По-видимому, он реализован как индикаторный апплет и позволяет настраивать ваши действия wii. Вы можете связать, например. amarok -t к wiibutton.
Вам повезло, и вы даже не знаете, сколько. Мне потребовалось некоторое время и немного исследований, но: я написал сценарий, чтобы сделать это некоторое время назад. Он работает с Amarok и Totem, хотя его можно легко модифицировать для управления другими игроками (при условии, что они имеют интерфейс командной строки). Дайте мне несколько минут, чтобы написать несколько комментариев. Затем отредактируйте этот ответ и опубликуйте его.
Особенности: Проверьте состояние батареи Wiimote. Включите светодиод на Wiimote. Начните Амарок. Пауза / продолжение воспроизведения. Перейти к следующему / последнему треку. Управление системным томом по alsamixerВам понадобятся питон и Rinzwind / sudo apt-get install python-cwiid. Вы можете сделать это, ожидая.
Ниже приведен сценарий. Просто запустите его в терминале.
#!/usr/bin/python
# indent-mode: spaces, indentsize: 4, encoding: utf-8
# © 2011 con-f-use@gmx.net.
# Use permitted under MIT license:
# http://www.opensource.org/licenses/mit-license.php (NO WARRANTY IMPLIED)
"""A Wiimote script to control totem and amarok under Ubuntu.
Provides a rudimentary interface to:
-Check battery status of the Wiimote.
-Switch an led on the Wiimote.
-Start Amarok.
-Pause/contiue playing.
-Skip to next/last track.
-Control the system volume over pulseaudio
Needs the package 'python-cwiid', 'amarok' and or 'totem' to be installed.
Globals:
wiimote -- the wiimote object
led -- the status of the led (on/off)
"""
import cwiid
import sys
import os
def main():
"""PC-side interface handles interaction between pc and user.
b -- battery status
l -- toggle led
q -- quit
h -- print help
"""
global wiimote
connect_wiimote()
#Print help text ont startup
print 'Confirm each command with ENTER.'
hlpmsg = 'Press q to quit\n'\
'b for battery status\n'\
'l to toggle the led on/off\n'\
'h or any other key to display this message.'
print hlpmsg
#Main loop for user interaction
doLoop = True
while doLoop:
c = sys.stdin.read(1)
if c == 'b': # battery status
state = wiimote.state
bat = int(100.0 * state['battery'] / cwiid.BATTERY_MAX)
print bat
elif c == 'l': # toggle led
toggle_led()
elif c == 'q': # exit program
doLoop = False
elif c == '\n': # ignore newlines
pass
else: # print help message when no valid command is issued
print hlpmsg
#Close connection and exit
wiimote.close()
def connect_wiimote():
"""Connets your computer to a Wiimote."""
print 'Put Wiimote in discoverable mode now (press 1+2)...'
global wiimote
while True:
try:
wiimote = cwiid.Wiimote(#add address of Wiimote here for speedup)
break
except:
continue
wiimote.mesg_callback = callback
#Set Wiimote options
global led
led = True
wiimote.led = cwiid.LED1_ON
wiimote.rpt_mode = cwiid.RPT_BTN
wiimote.enable(cwiid.FLAG_MESG_IFC)
def callback(mesg_list, time):
"""Handels the interaction between Wiimote and user.
A and B together -- toggle led
A -- play/pause
up / down -- fast forward / backward
right / left -- next / previous trakc
+ / - -- increase / decreas volume
"""
for mesg in mesg_list:
# Handle Buttonpresses - add hex-values for simultaneous presses
# Buttons not listed: 0x4 - B, 0x1 - 2, 0x2 - 1 | just babytown frolics
if mesg[0] == cwiid.MESG_BTN:
if mesg[1] == 0x8: # A botton
player_control('playpause')
elif mesg[1] == 0xC: # A and B together
toggle_led()
elif mesg[1] == 0x800: # Up botton
player_control('ffwd')
elif mesg[1] == 0x100: # Left botton
player_control('lasttrack')
elif mesg[1] == 0x200: # Right botton
player_control('nexttrack')
elif mesg[1] == 0x400: # Down botton
player_control('fbwd')
elif mesg[1] == 0x10: # Minus botton
change_volume(-1)
elif mesg[1] == 0x1000: # Plus botton
change_volume(1)
elif mesg[1] == 0x80: # home botton
shut_down()
# Handle errormessages
elif mesg[0] == cwiid.MESG_ERROR:
global wiimote
wiimote.close()
connect_wiimote()
def change_volume(change):
"""Changes system's master volume."""
cmd = "amixer get Master | grep 'Front Left' | grep -oP '(?<=Playback\ )\d+'"
fin,fout = os.popen4(cmd)
currVol = int( fout.read() )
newVol = currVol + change
os.system( "amixer set Master "+str(newVol) )
def toggle_led():
"""Toggles first led on Wiimote on/off."""
global led
if led == True:
led = False
wiimote.led = 0
else:
led = True
wiimote.led = cwiid.LED1_ON
def player_control(action):
"""Controls Amarok or Totem - depending on wich one is running.
Totem takes precedence over Amarok if running. If none is running, Amarok
will be started ant take the command.
"""
print action
# Check if totem is running
cmd = "ps -A | grep -oP 'totem'"
fin,fout = os.popen4(cmd)
isTotem = fout.read()
isTotem = isTotem.find('totem') != -1
# Do the actual player action
if action == 'nexttrack':
if isTotem:
cmd = "totem --next"
else:
cmd = "amarok -f"
elif action == 'lasttrack':
if isTotem:
cmd = "totem --previous"
else:
cmd = "amarok -r"
elif action == 'playpause':
if isTotem:
cmd = "totem --play-pause"
else:
cmd = "amarok -t"
elif action == 'ffwd':
if isTotem:
cmd = "totem --seek-fwd"
elif action == 'fbwd':
if isTotem:
cmd = "totem --seek-bwd"
os.system(cmd)
main()
Редактировать: Rinzwind опрокинул меня на проект с пусковой площадкой под названием «wiican». По-видимому, он реализован как индикаторный апплет и позволяет настраивать ваши действия wii. Вы можете связать, например. amarok -t к wiibutton.
Вам повезло, и вы даже не знаете, сколько. Мне потребовалось некоторое время и немного исследований, но: я написал сценарий, чтобы сделать это некоторое время назад. Он работает с Amarok и Totem, хотя его можно легко модифицировать для управления другими игроками (при условии, что они имеют интерфейс командной строки). Дайте мне несколько минут, чтобы написать несколько комментариев. Затем отредактируйте этот ответ и опубликуйте его.
Особенности: Проверьте состояние батареи Wiimote. Включите светодиод на Wiimote. Начните Амарок. Пауза / продолжение воспроизведения. Перейти к следующему / последнему треку. Управление системным томом по alsamixerВам понадобятся питон и Rinzwind / sudo apt-get install python-cwiid. Вы можете сделать это, ожидая.
Ниже приведен сценарий. Просто запустите его в терминале.
#!/usr/bin/python
# indent-mode: spaces, indentsize: 4, encoding: utf-8
# © 2011 con-f-use@gmx.net.
# Use permitted under MIT license:
# http://www.opensource.org/licenses/mit-license.php (NO WARRANTY IMPLIED)
"""A Wiimote script to control totem and amarok under Ubuntu.
Provides a rudimentary interface to:
-Check battery status of the Wiimote.
-Switch an led on the Wiimote.
-Start Amarok.
-Pause/contiue playing.
-Skip to next/last track.
-Control the system volume over pulseaudio
Needs the package 'python-cwiid', 'amarok' and or 'totem' to be installed.
Globals:
wiimote -- the wiimote object
led -- the status of the led (on/off)
"""
import cwiid
import sys
import os
def main():
"""PC-side interface handles interaction between pc and user.
b -- battery status
l -- toggle led
q -- quit
h -- print help
"""
global wiimote
connect_wiimote()
#Print help text ont startup
print 'Confirm each command with ENTER.'
hlpmsg = 'Press q to quit\n'\
'b for battery status\n'\
'l to toggle the led on/off\n'\
'h or any other key to display this message.'
print hlpmsg
#Main loop for user interaction
doLoop = True
while doLoop:
c = sys.stdin.read(1)
if c == 'b': # battery status
state = wiimote.state
bat = int(100.0 * state['battery'] / cwiid.BATTERY_MAX)
print bat
elif c == 'l': # toggle led
toggle_led()
elif c == 'q': # exit program
doLoop = False
elif c == '\n': # ignore newlines
pass
else: # print help message when no valid command is issued
print hlpmsg
#Close connection and exit
wiimote.close()
def connect_wiimote():
"""Connets your computer to a Wiimote."""
print 'Put Wiimote in discoverable mode now (press 1+2)...'
global wiimote
while True:
try:
wiimote = cwiid.Wiimote(#add address of Wiimote here for speedup)
break
except:
continue
wiimote.mesg_callback = callback
#Set Wiimote options
global led
led = True
wiimote.led = cwiid.LED1_ON
wiimote.rpt_mode = cwiid.RPT_BTN
wiimote.enable(cwiid.FLAG_MESG_IFC)
def callback(mesg_list, time):
"""Handels the interaction between Wiimote and user.
A and B together -- toggle led
A -- play/pause
up / down -- fast forward / backward
right / left -- next / previous trakc
+ / - -- increase / decreas volume
"""
for mesg in mesg_list:
# Handle Buttonpresses - add hex-values for simultaneous presses
# Buttons not listed: 0x4 - B, 0x1 - 2, 0x2 - 1 | just babytown frolics
if mesg[0] == cwiid.MESG_BTN:
if mesg[1] == 0x8: # A botton
player_control('playpause')
elif mesg[1] == 0xC: # A and B together
toggle_led()
elif mesg[1] == 0x800: # Up botton
player_control('ffwd')
elif mesg[1] == 0x100: # Left botton
player_control('lasttrack')
elif mesg[1] == 0x200: # Right botton
player_control('nexttrack')
elif mesg[1] == 0x400: # Down botton
player_control('fbwd')
elif mesg[1] == 0x10: # Minus botton
change_volume(-1)
elif mesg[1] == 0x1000: # Plus botton
change_volume(1)
elif mesg[1] == 0x80: # home botton
shut_down()
# Handle errormessages
elif mesg[0] == cwiid.MESG_ERROR:
global wiimote
wiimote.close()
connect_wiimote()
def change_volume(change):
"""Changes system's master volume."""
cmd = "amixer get Master | grep 'Front Left' | grep -oP '(?<=Playback\ )\d+'"
fin,fout = os.popen4(cmd)
currVol = int( fout.read() )
newVol = currVol + change
os.system( "amixer set Master "+str(newVol) )
def toggle_led():
"""Toggles first led on Wiimote on/off."""
global led
if led == True:
led = False
wiimote.led = 0
else:
led = True
wiimote.led = cwiid.LED1_ON
def player_control(action):
"""Controls Amarok or Totem - depending on wich one is running.
Totem takes precedence over Amarok if running. If none is running, Amarok
will be started ant take the command.
"""
print action
# Check if totem is running
cmd = "ps -A | grep -oP 'totem'"
fin,fout = os.popen4(cmd)
isTotem = fout.read()
isTotem = isTotem.find('totem') != -1
# Do the actual player action
if action == 'nexttrack':
if isTotem:
cmd = "totem --next"
else:
cmd = "amarok -f"
elif action == 'lasttrack':
if isTotem:
cmd = "totem --previous"
else:
cmd = "amarok -r"
elif action == 'playpause':
if isTotem:
cmd = "totem --play-pause"
else:
cmd = "amarok -t"
elif action == 'ffwd':
if isTotem:
cmd = "totem --seek-fwd"
elif action == 'fbwd':
if isTotem:
cmd = "totem --seek-bwd"
os.system(cmd)
main()
Редактировать: Rinzwind опрокинул меня на проект с пусковой площадкой под названием «wiican». По-видимому, он реализован как индикаторный апплет и позволяет настраивать ваши действия wii. Вы можете связать, например. amarok -t к wiibutton.
Вам повезло, и вы даже не знаете, сколько. Мне потребовалось некоторое время и немного исследований, но: я написал сценарий, чтобы сделать это некоторое время назад. Он работает с Amarok и Totem, хотя его можно легко модифицировать для управления другими игроками (при условии, что они имеют интерфейс командной строки). Дайте мне несколько минут, чтобы написать несколько комментариев. Затем отредактируйте этот ответ и опубликуйте его.
Особенности: Проверьте состояние батареи Wiimote. Включите светодиод на Wiimote. Начните Амарок. Пауза / продолжение воспроизведения. Перейти к следующему / последнему треку. Управление системным томом по alsamixerВам понадобятся питон и Rinzwind / sudo apt-get install python-cwiid. Вы можете сделать это, ожидая.
Ниже приведен сценарий. Просто запустите его в терминале.
#!/usr/bin/python
# indent-mode: spaces, indentsize: 4, encoding: utf-8
# © 2011 con-f-use@gmx.net.
# Use permitted under MIT license:
# http://www.opensource.org/licenses/mit-license.php (NO WARRANTY IMPLIED)
"""A Wiimote script to control totem and amarok under Ubuntu.
Provides a rudimentary interface to:
-Check battery status of the Wiimote.
-Switch an led on the Wiimote.
-Start Amarok.
-Pause/contiue playing.
-Skip to next/last track.
-Control the system volume over pulseaudio
Needs the package 'python-cwiid', 'amarok' and or 'totem' to be installed.
Globals:
wiimote -- the wiimote object
led -- the status of the led (on/off)
"""
import cwiid
import sys
import os
def main():
"""PC-side interface handles interaction between pc and user.
b -- battery status
l -- toggle led
q -- quit
h -- print help
"""
global wiimote
connect_wiimote()
#Print help text ont startup
print 'Confirm each command with ENTER.'
hlpmsg = 'Press q to quit\n'\
'b for battery status\n'\
'l to toggle the led on/off\n'\
'h or any other key to display this message.'
print hlpmsg
#Main loop for user interaction
doLoop = True
while doLoop:
c = sys.stdin.read(1)
if c == 'b': # battery status
state = wiimote.state
bat = int(100.0 * state['battery'] / cwiid.BATTERY_MAX)
print bat
elif c == 'l': # toggle led
toggle_led()
elif c == 'q': # exit program
doLoop = False
elif c == '\n': # ignore newlines
pass
else: # print help message when no valid command is issued
print hlpmsg
#Close connection and exit
wiimote.close()
def connect_wiimote():
"""Connets your computer to a Wiimote."""
print 'Put Wiimote in discoverable mode now (press 1+2)...'
global wiimote
while True:
try:
wiimote = cwiid.Wiimote(#add address of Wiimote here for speedup)
break
except:
continue
wiimote.mesg_callback = callback
#Set Wiimote options
global led
led = True
wiimote.led = cwiid.LED1_ON
wiimote.rpt_mode = cwiid.RPT_BTN
wiimote.enable(cwiid.FLAG_MESG_IFC)
def callback(mesg_list, time):
"""Handels the interaction between Wiimote and user.
A and B together -- toggle led
A -- play/pause
up / down -- fast forward / backward
right / left -- next / previous trakc
+ / - -- increase / decreas volume
"""
for mesg in mesg_list:
# Handle Buttonpresses - add hex-values for simultaneous presses
# Buttons not listed: 0x4 - B, 0x1 - 2, 0x2 - 1 | just babytown frolics
if mesg[0] == cwiid.MESG_BTN:
if mesg[1] == 0x8: # A botton
player_control('playpause')
elif mesg[1] == 0xC: # A and B together
toggle_led()
elif mesg[1] == 0x800: # Up botton
player_control('ffwd')
elif mesg[1] == 0x100: # Left botton
player_control('lasttrack')
elif mesg[1] == 0x200: # Right botton
player_control('nexttrack')
elif mesg[1] == 0x400: # Down botton
player_control('fbwd')
elif mesg[1] == 0x10: # Minus botton
change_volume(-1)
elif mesg[1] == 0x1000: # Plus botton
change_volume(1)
elif mesg[1] == 0x80: # home botton
shut_down()
# Handle errormessages
elif mesg[0] == cwiid.MESG_ERROR:
global wiimote
wiimote.close()
connect_wiimote()
def change_volume(change):
"""Changes system's master volume."""
cmd = "amixer get Master | grep 'Front Left' | grep -oP '(?<=Playback\ )\d+'"
fin,fout = os.popen4(cmd)
currVol = int( fout.read() )
newVol = currVol + change
os.system( "amixer set Master "+str(newVol) )
def toggle_led():
"""Toggles first led on Wiimote on/off."""
global led
if led == True:
led = False
wiimote.led = 0
else:
led = True
wiimote.led = cwiid.LED1_ON
def player_control(action):
"""Controls Amarok or Totem - depending on wich one is running.
Totem takes precedence over Amarok if running. If none is running, Amarok
will be started ant take the command.
"""
print action
# Check if totem is running
cmd = "ps -A | grep -oP 'totem'"
fin,fout = os.popen4(cmd)
isTotem = fout.read()
isTotem = isTotem.find('totem') != -1
# Do the actual player action
if action == 'nexttrack':
if isTotem:
cmd = "totem --next"
else:
cmd = "amarok -f"
elif action == 'lasttrack':
if isTotem:
cmd = "totem --previous"
else:
cmd = "amarok -r"
elif action == 'playpause':
if isTotem:
cmd = "totem --play-pause"
else:
cmd = "amarok -t"
elif action == 'ffwd':
if isTotem:
cmd = "totem --seek-fwd"
elif action == 'fbwd':
if isTotem:
cmd = "totem --seek-bwd"
os.system(cmd)
main()
Редактировать: Rinzwind опрокинул меня на проект с пусковой площадкой под названием «wiican». По-видимому, он реализован как индикаторный апплет и позволяет настраивать ваши действия wii. Вы можете связать, например. amarok -t к wiibutton.
Вам повезло, и вы даже не знаете, сколько. Мне потребовалось некоторое время и немного исследований, но: я написал сценарий, чтобы сделать это некоторое время назад. Он работает с Amarok и Totem, хотя его можно легко модифицировать для управления другими игроками (при условии, что они имеют интерфейс командной строки). Дайте мне несколько минут, чтобы написать несколько комментариев. Затем отредактируйте этот ответ и опубликуйте его.
Особенности: Проверьте состояние батареи Wiimote. Включите светодиод на Wiimote. Начните Амарок. Пауза / продолжение воспроизведения. Перейти к следующему / последнему треку. Управление системным томом по alsamixerВам понадобятся питон и Rinzwind / sudo apt-get install python-cwiid. Вы можете сделать это, ожидая.
Ниже приведен сценарий. Просто запустите его в терминале.
#!/usr/bin/python
# indent-mode: spaces, indentsize: 4, encoding: utf-8
# © 2011 con-f-use@gmx.net.
# Use permitted under MIT license:
# http://www.opensource.org/licenses/mit-license.php (NO WARRANTY IMPLIED)
"""A Wiimote script to control totem and amarok under Ubuntu.
Provides a rudimentary interface to:
-Check battery status of the Wiimote.
-Switch an led on the Wiimote.
-Start Amarok.
-Pause/contiue playing.
-Skip to next/last track.
-Control the system volume over pulseaudio
Needs the package 'python-cwiid', 'amarok' and or 'totem' to be installed.
Globals:
wiimote -- the wiimote object
led -- the status of the led (on/off)
"""
import cwiid
import sys
import os
def main():
"""PC-side interface handles interaction between pc and user.
b -- battery status
l -- toggle led
q -- quit
h -- print help
"""
global wiimote
connect_wiimote()
#Print help text ont startup
print 'Confirm each command with ENTER.'
hlpmsg = 'Press q to quit\n'\
'b for battery status\n'\
'l to toggle the led on/off\n'\
'h or any other key to display this message.'
print hlpmsg
#Main loop for user interaction
doLoop = True
while doLoop:
c = sys.stdin.read(1)
if c == 'b': # battery status
state = wiimote.state
bat = int(100.0 * state['battery'] / cwiid.BATTERY_MAX)
print bat
elif c == 'l': # toggle led
toggle_led()
elif c == 'q': # exit program
doLoop = False
elif c == '\n': # ignore newlines
pass
else: # print help message when no valid command is issued
print hlpmsg
#Close connection and exit
wiimote.close()
def connect_wiimote():
"""Connets your computer to a Wiimote."""
print 'Put Wiimote in discoverable mode now (press 1+2)...'
global wiimote
while True:
try:
wiimote = cwiid.Wiimote(#add address of Wiimote here for speedup)
break
except:
continue
wiimote.mesg_callback = callback
#Set Wiimote options
global led
led = True
wiimote.led = cwiid.LED1_ON
wiimote.rpt_mode = cwiid.RPT_BTN
wiimote.enable(cwiid.FLAG_MESG_IFC)
def callback(mesg_list, time):
"""Handels the interaction between Wiimote and user.
A and B together -- toggle led
A -- play/pause
up / down -- fast forward / backward
right / left -- next / previous trakc
+ / - -- increase / decreas volume
"""
for mesg in mesg_list:
# Handle Buttonpresses - add hex-values for simultaneous presses
# Buttons not listed: 0x4 - B, 0x1 - 2, 0x2 - 1 | just babytown frolics
if mesg[0] == cwiid.MESG_BTN:
if mesg[1] == 0x8: # A botton
player_control('playpause')
elif mesg[1] == 0xC: # A and B together
toggle_led()
elif mesg[1] == 0x800: # Up botton
player_control('ffwd')
elif mesg[1] == 0x100: # Left botton
player_control('lasttrack')
elif mesg[1] == 0x200: # Right botton
player_control('nexttrack')
elif mesg[1] == 0x400: # Down botton
player_control('fbwd')
elif mesg[1] == 0x10: # Minus botton
change_volume(-1)
elif mesg[1] == 0x1000: # Plus botton
change_volume(1)
elif mesg[1] == 0x80: # home botton
shut_down()
# Handle errormessages
elif mesg[0] == cwiid.MESG_ERROR:
global wiimote
wiimote.close()
connect_wiimote()
def change_volume(change):
"""Changes system's master volume."""
cmd = "amixer get Master | grep 'Front Left' | grep -oP '(?<=Playback\ )\d+'"
fin,fout = os.popen4(cmd)
currVol = int( fout.read() )
newVol = currVol + change
os.system( "amixer set Master "+str(newVol) )
def toggle_led():
"""Toggles first led on Wiimote on/off."""
global led
if led == True:
led = False
wiimote.led = 0
else:
led = True
wiimote.led = cwiid.LED1_ON
def player_control(action):
"""Controls Amarok or Totem - depending on wich one is running.
Totem takes precedence over Amarok if running. If none is running, Amarok
will be started ant take the command.
"""
print action
# Check if totem is running
cmd = "ps -A | grep -oP 'totem'"
fin,fout = os.popen4(cmd)
isTotem = fout.read()
isTotem = isTotem.find('totem') != -1
# Do the actual player action
if action == 'nexttrack':
if isTotem:
cmd = "totem --next"
else:
cmd = "amarok -f"
elif action == 'lasttrack':
if isTotem:
cmd = "totem --previous"
else:
cmd = "amarok -r"
elif action == 'playpause':
if isTotem:
cmd = "totem --play-pause"
else:
cmd = "amarok -t"
elif action == 'ffwd':
if isTotem:
cmd = "totem --seek-fwd"
elif action == 'fbwd':
if isTotem:
cmd = "totem --seek-bwd"
os.system(cmd)
main()
Редактировать : Rinzwind опрокинул меня в проекте с пусковой панелью под названием « wiican ». По-видимому, он реализован как индикаторный апплет и позволяет настраивать ваши действия wii. Вы можете связать, например. amarok -t
в wiibutton.
Вам повезло, и вы даже не знаете, сколько. Мне потребовалось некоторое время и немного исследований, но: я написал сценарий, чтобы сделать это некоторое время назад. Он работает с Amarok и Totem, хотя его можно легко модифицировать для управления другими игроками (при условии, что они имеют интерфейс командной строки). Дайте мне несколько минут, чтобы написать несколько комментариев. Затем отредактируйте этот ответ и опубликуйте его.
Вам понадобятся питон и python-cwiid / sudo apt-get install python-cwiid
. Вы можете сделать это, ожидая.
Ниже приведен скрипт. Просто запустите его в терминале.
#!/usr/bin/python
# indent-mode: spaces, indentsize: 4, encoding: utf-8
# © 2011 con-f-use@gmx.net.
# Use permitted under MIT license:
# http://www.opensource.org/licenses/mit-license.php (NO WARRANTY IMPLIED)
"""A Wiimote script to control totem and amarok under Ubuntu.
Provides a rudimentary interface to:
-Check battery status of the Wiimote.
-Switch an led on the Wiimote.
-Start Amarok.
-Pause/contiue playing.
-Skip to next/last track.
-Control the system volume over pulseaudio
Needs the package 'python-cwiid', 'amarok' and or 'totem' to be installed.
Globals:
wiimote -- the wiimote object
led -- the status of the led (on/off)
"""
import cwiid
import sys
import os
def main():
"""PC-side interface handles interaction between pc and user.
b -- battery status
l -- toggle led
q -- quit
h -- print help
"""
global wiimote
connect_wiimote()
#Print help text ont startup
print 'Confirm each command with ENTER.'
hlpmsg = 'Press q to quit\n'\
'b for battery status\n'\
'l to toggle the led on/off\n'\
'h or any other key to display this message.'
print hlpmsg
#Main loop for user interaction
doLoop = True
while doLoop:
c = sys.stdin.read(1)
if c == 'b': # battery status
state = wiimote.state
bat = int(100.0 * state['battery'] / cwiid.BATTERY_MAX)
print bat
elif c == 'l': # toggle led
toggle_led()
elif c == 'q': # exit program
doLoop = False
elif c == '\n': # ignore newlines
pass
else: # print help message when no valid command is issued
print hlpmsg
#Close connection and exit
wiimote.close()
def connect_wiimote():
"""Connets your computer to a Wiimote."""
print 'Put Wiimote in discoverable mode now (press 1+2)...'
global wiimote
while True:
try:
wiimote = cwiid.Wiimote(#add address of Wiimote here for speedup)
break
except:
continue
wiimote.mesg_callback = callback
#Set Wiimote options
global led
led = True
wiimote.led = cwiid.LED1_ON
wiimote.rpt_mode = cwiid.RPT_BTN
wiimote.enable(cwiid.FLAG_MESG_IFC)
def callback(mesg_list, time):
"""Handels the interaction between Wiimote and user.
A and B together -- toggle led
A -- play/pause
up / down -- fast forward / backward
right / left -- next / previous trakc
+ / - -- increase / decreas volume
"""
for mesg in mesg_list:
# Handle Buttonpresses - add hex-values for simultaneous presses
# Buttons not listed: 0x4 - B, 0x1 - 2, 0x2 - 1 | just babytown frolics
if mesg[0] == cwiid.MESG_BTN:
if mesg[1] == 0x8: # A botton
player_control('playpause')
elif mesg[1] == 0xC: # A and B together
toggle_led()
elif mesg[1] == 0x800: # Up botton
player_control('ffwd')
elif mesg[1] == 0x100: # Left botton
player_control('lasttrack')
elif mesg[1] == 0x200: # Right botton
player_control('nexttrack')
elif mesg[1] == 0x400: # Down botton
player_control('fbwd')
elif mesg[1] == 0x10: # Minus botton
change_volume(-1)
elif mesg[1] == 0x1000: # Plus botton
change_volume(1)
elif mesg[1] == 0x80: # home botton
shut_down()
# Handle errormessages
elif mesg[0] == cwiid.MESG_ERROR:
global wiimote
wiimote.close()
connect_wiimote()
def change_volume(change):
"""Changes system's master volume."""
cmd = "amixer get Master | grep 'Front Left' | grep -oP '(?<=Playback\ )\d+'"
fin,fout = os.popen4(cmd)
currVol = int( fout.read() )
newVol = currVol + change
os.system( "amixer set Master "+str(newVol) )
def toggle_led():
"""Toggles first led on Wiimote on/off."""
global led
if led == True:
led = False
wiimote.led = 0
else:
led = True
wiimote.led = cwiid.LED1_ON
def player_control(action):
"""Controls Amarok or Totem - depending on wich one is running.
Totem takes precedence over Amarok if running. If none is running, Amarok
will be started ant take the command.
"""
print action
# Check if totem is running
cmd = "ps -A | grep -oP 'totem'"
fin,fout = os.popen4(cmd)
isTotem = fout.read()
isTotem = isTotem.find('totem') != -1
# Do the actual player action
if action == 'nexttrack':
if isTotem:
cmd = "totem --next"
else:
cmd = "amarok -f"
elif action == 'lasttrack':
if isTotem:
cmd = "totem --previous"
else:
cmd = "amarok -r"
elif action == 'playpause':
if isTotem:
cmd = "totem --play-pause"
else:
cmd = "amarok -t"
elif action == 'ffwd':
if isTotem:
cmd = "totem --seek-fwd"
elif action == 'fbwd':
if isTotem:
cmd = "totem --seek-bwd"
os.system(cmd)
main()
Редактировать : Rinzwind опрокинул меня в проекте с пусковой панелью под названием « wiican ». По-видимому, он реализован как индикаторный апплет и позволяет настраивать ваши действия wii. Вы можете связать, например. amarok -t
в wiibutton.
Вам повезло, и вы даже не знаете, сколько. Мне потребовалось некоторое время и немного исследований, но: я написал сценарий, чтобы сделать это некоторое время назад. Он работает с Amarok и Totem, хотя его можно легко модифицировать для управления другими игроками (при условии, что они имеют интерфейс командной строки). Дайте мне несколько минут, чтобы написать несколько комментариев. Затем отредактируйте этот ответ и опубликуйте его.
Вам понадобятся питон и python-cwiid / sudo apt-get install python-cwiid
. Вы можете сделать это, ожидая.
Ниже приведен скрипт. Просто запустите его в терминале.
#!/usr/bin/python
# indent-mode: spaces, indentsize: 4, encoding: utf-8
# © 2011 con-f-use@gmx.net.
# Use permitted under MIT license:
# http://www.opensource.org/licenses/mit-license.php (NO WARRANTY IMPLIED)
"""A Wiimote script to control totem and amarok under Ubuntu.
Provides a rudimentary interface to:
-Check battery status of the Wiimote.
-Switch an led on the Wiimote.
-Start Amarok.
-Pause/contiue playing.
-Skip to next/last track.
-Control the system volume over pulseaudio
Needs the package 'python-cwiid', 'amarok' and or 'totem' to be installed.
Globals:
wiimote -- the wiimote object
led -- the status of the led (on/off)
"""
import cwiid
import sys
import os
def main():
"""PC-side interface handles interaction between pc and user.
b -- battery status
l -- toggle led
q -- quit
h -- print help
"""
global wiimote
connect_wiimote()
#Print help text ont startup
print 'Confirm each command with ENTER.'
hlpmsg = 'Press q to quit\n'\
'b for battery status\n'\
'l to toggle the led on/off\n'\
'h or any other key to display this message.'
print hlpmsg
#Main loop for user interaction
doLoop = True
while doLoop:
c = sys.stdin.read(1)
if c == 'b': # battery status
state = wiimote.state
bat = int(100.0 * state['battery'] / cwiid.BATTERY_MAX)
print bat
elif c == 'l': # toggle led
toggle_led()
elif c == 'q': # exit program
doLoop = False
elif c == '\n': # ignore newlines
pass
else: # print help message when no valid command is issued
print hlpmsg
#Close connection and exit
wiimote.close()
def connect_wiimote():
"""Connets your computer to a Wiimote."""
print 'Put Wiimote in discoverable mode now (press 1+2)...'
global wiimote
while True:
try:
wiimote = cwiid.Wiimote(#add address of Wiimote here for speedup)
break
except:
continue
wiimote.mesg_callback = callback
#Set Wiimote options
global led
led = True
wiimote.led = cwiid.LED1_ON
wiimote.rpt_mode = cwiid.RPT_BTN
wiimote.enable(cwiid.FLAG_MESG_IFC)
def callback(mesg_list, time):
"""Handels the interaction between Wiimote and user.
A and B together -- toggle led
A -- play/pause
up / down -- fast forward / backward
right / left -- next / previous trakc
+ / - -- increase / decreas volume
"""
for mesg in mesg_list:
# Handle Buttonpresses - add hex-values for simultaneous presses
# Buttons not listed: 0x4 - B, 0x1 - 2, 0x2 - 1 | just babytown frolics
if mesg[0] == cwiid.MESG_BTN:
if mesg[1] == 0x8: # A botton
player_control('playpause')
elif mesg[1] == 0xC: # A and B together
toggle_led()
elif mesg[1] == 0x800: # Up botton
player_control('ffwd')
elif mesg[1] == 0x100: # Left botton
player_control('lasttrack')
elif mesg[1] == 0x200: # Right botton
player_control('nexttrack')
elif mesg[1] == 0x400: # Down botton
player_control('fbwd')
elif mesg[1] == 0x10: # Minus botton
change_volume(-1)
elif mesg[1] == 0x1000: # Plus botton
change_volume(1)
elif mesg[1] == 0x80: # home botton
shut_down()
# Handle errormessages
elif mesg[0] == cwiid.MESG_ERROR:
global wiimote
wiimote.close()
connect_wiimote()
def change_volume(change):
"""Changes system's master volume."""
cmd = "amixer get Master | grep 'Front Left' | grep -oP '(?<=Playback\ )\d+'"
fin,fout = os.popen4(cmd)
currVol = int( fout.read() )
newVol = currVol + change
os.system( "amixer set Master "+str(newVol) )
def toggle_led():
"""Toggles first led on Wiimote on/off."""
global led
if led == True:
led = False
wiimote.led = 0
else:
led = True
wiimote.led = cwiid.LED1_ON
def player_control(action):
"""Controls Amarok or Totem - depending on wich one is running.
Totem takes precedence over Amarok if running. If none is running, Amarok
will be started ant take the command.
"""
print action
# Check if totem is running
cmd = "ps -A | grep -oP 'totem'"
fin,fout = os.popen4(cmd)
isTotem = fout.read()
isTotem = isTotem.find('totem') != -1
# Do the actual player action
if action == 'nexttrack':
if isTotem:
cmd = "totem --next"
else:
cmd = "amarok -f"
elif action == 'lasttrack':
if isTotem:
cmd = "totem --previous"
else:
cmd = "amarok -r"
elif action == 'playpause':
if isTotem:
cmd = "totem --play-pause"
else:
cmd = "amarok -t"
elif action == 'ffwd':
if isTotem:
cmd = "totem --seek-fwd"
elif action == 'fbwd':
if isTotem:
cmd = "totem --seek-bwd"
os.system(cmd)
main()
Существует также программа GUI, которая находится на системном трее под названием «Wiican». Раньше я использовал Ubuntu до 11.04 (Natty), но теперь я не могу понять, как установить его с PPA, найденным на https://launchpad.net/wiican
Это просто подключается и настраивает кнопки по своему желанию, но не идеально, но я бы назвал это отличным
будет обновлять сообщение после того, как узнаю, как установить.
Изменить: мне удалось найти пакет на этом https://launchpad.net/wiican
Существует также программа GUI, которая находится на системном трее под названием «Wiican». Раньше я использовал Ubuntu до 11.04 (Natty), но теперь я не могу понять, как установить его с PPA, найденным на https://launchpad.net/wiican
Это просто подключается и настраивает кнопки по своему желанию, но не идеально, но я бы назвал это отличным
будет обновлять сообщение после того, как узнаю, как установить.
Изменить: мне удалось найти пакет на этом https://launchpad.net/wiican
Существует также программа GUI, которая находится на системном трее под названием «Wiican». Раньше я использовал Ubuntu до 11.04 (Natty), но теперь я не могу понять, как установить его с PPA, найденным на https://launchpad.net/wiican
Это просто подключается и настраивает кнопки по своему желанию, но не идеально, но я бы назвал это отличным
будет обновлять сообщение после того, как узнаю, как установить.
Изменить: мне удалось найти пакет на этом https://launchpad.net/wiican
Существует также программа GUI, которая находится на системном трее под названием «Wiican». Раньше я использовал Ubuntu до 11.04 (Natty), но теперь я не могу понять, как установить его с PPA, найденным на https://launchpad.net/wiican
Это просто подключается и настраивает кнопки по своему желанию, но не идеально, но я бы назвал это отличным
будет обновлять сообщение после того, как узнаю, как установить.
Изменить: мне удалось найти пакет на этом https://launchpad.net/wiican
Существует также программа GUI, которая находится на системном трее под названием «Wiican». Раньше я использовал Ubuntu до 11.04 (Natty), но теперь я не могу понять, как установить его с PPA, найденным на https://launchpad.net/wiican
Это просто подключается и настраивает кнопки по своему желанию, но не идеально, но я бы назвал это отличным
будет обновлять сообщение после того, как узнаю, как установить.
Изменить: мне удалось найти пакет на этом https://launchpad.net/wiican
Существует также программа GUI, которая находится на системном трее под названием «Wiican». Раньше я использовал Ubuntu до 11.04 (Natty), но теперь я не могу понять, как установить его с PPA, найденным на https://launchpad.net/wiican
Это просто подключается и настраивает кнопки по своему желанию, но не идеально, но я бы назвал это отличным
будет обновлять сообщение после того, как узнаю, как установить.
Изменить: мне удалось найти пакет на этом https://launchpad.net/wiican
Существует также программа GUI, которая находится на системном трее под названием «Wiican». Раньше я использовал Ubuntu до 11.04 (Natty), но теперь я не могу понять, как установить его с PPA, найденным на https://launchpad.net/wiican
Это просто подключается и настраивает кнопки по своему желанию, но не идеально, но я бы назвал это отличным
будет обновлять сообщение после того, как узнаю, как установить.
Изменить: мне удалось найти пакет на этом https://launchpad.net/wiican
Существует также программа GUI, которая находится на системном трее под названием «Wiican». Раньше я использовал Ubuntu до 11.04 (Natty), но теперь я не могу понять, как установить его с PPA, найденным на https://launchpad.net/wiican
Это просто подключается и настраивает кнопки по своему желанию, но не идеально, но я бы назвал это отличным
будет обновлять сообщение после того, как узнаю, как установить.
Изменить: мне удалось найти пакет на этом https://launchpad.net/wiican
Существует также программа GUI, которая находится на системном трее под названием «Wiican». Раньше я использовал Ubuntu до 11.04 (Natty), но теперь я не могу понять, как установить его с PPA, найденным в https://launchpad.net/wiican
Он просто подключает и настраивает кнопки по своему желанию, но не идеально, но я бы назвал это отличным
будет обновлять сообщение после того, как узнаю, как установить.
Изменить: мне удалось найти пакет на этой ссылке
Существует также программа GUI, которая находится на системном трее под названием «Wiican». Раньше я использовал Ubuntu до 11.04 (Natty), но теперь я не могу понять, как установить его с PPA, найденным в https://launchpad.net/wiican
Он просто подключает и настраивает кнопки по своему желанию, но не идеально, но я бы назвал это отличным
будет обновлять сообщение после того, как узнаю, как установить.
Изменить: мне удалось найти пакет на этой ссылке