We're writing a python script to have i3 play sounds when a mode is switched anb back to default. This is part of a project to make i3 accessible to the blind. This script requires you have sox installed.
I am getting this error when running the script, and the mode event triggers.
List indices must be integers or slices, not str.
Script code:
!/usr/bin/env python3
import i3ipc
from os import system
This script allows for sounds in i3
def on_new_window(self,i3):
system('play -n synth .25 sin 440:880 sin 480:920 remix - norm -3 pitch -500')
Trace stack:
list indices must be integers or slices, not str
Traceback (most recent call last):
File "/home/jticket/src/I38/scripts/sound.py", line 25, in
i3.main()
File "/usr/lib/python3.10/site-packages/i3ipc/connection.py", line 514, in main
raise loop_exception
File "/usr/lib/python3.10/site-packages/i3ipc/connection.py", line 497, in main
while not self._event_socket_poll():
File "/usr/lib/python3.10/site-packages/i3ipc/connection.py", line 477, in _event_socket_poll
raise e
File "/usr/lib/python3.10/site-packages/i3ipc/connection.py", line 474, in _event_socket_poll
self._pubsub.emit(event_name, event)
File "/usr/lib/python3.10/site-packages/i3ipc/_private/pubsub.py", line 28, in emit
s['handler'](self.conn, data)
File "/home/jticket/src/I38/scripts/sound.py", line 12, in on_mode
mode = i3ipc.ModeEvent(['change'])
File "/usr/lib/python3.10/site-packages/i3ipc/events.py", line 112, in init
self.change = data['change']
TypeError: list indices must be integers or slices, not str
We're writing a python script to have i3 play sounds when a mode is switched anb back to default. This is part of a project to make i3 accessible to the blind. This script requires you have sox installed. I am getting this error when running the script, and the mode event triggers. List indices must be integers or slices, not str.
Script code:
!/usr/bin/env python3
import i3ipc from os import system
This script allows for sounds in i3
def on_new_window(self,i3): system('play -n synth .25 sin 440:880 sin 480:920 remix - norm -3 pitch -500')
def on_mode(self,i3): mode = i3ipc.ModeEvent(['change']) if mode == 'resize': system('play -qV0 "|sox -np synth .07 sq 400" "|sox -np synth .5 sq 800" fade h 0 .5 .5 norm -20') elif mode == 'default': system('play -qV0 "|sox -np synth .07 sq 400" "|sox -np synth .5 sq 800" fade h 0 .5 .5 norm -20 reverse')
i3 = i3ipc.Connection()
i3.on('window::new', on_new_window) i3.on('mode', on_mode)
i3.main()
Trace stack: list indices must be integers or slices, not str Traceback (most recent call last): File "/home/jticket/src/I38/scripts/sound.py", line 25, in
i3.main()
File "/usr/lib/python3.10/site-packages/i3ipc/connection.py", line 514, in main
raise loop_exception
File "/usr/lib/python3.10/site-packages/i3ipc/connection.py", line 497, in main
while not self._event_socket_poll():
File "/usr/lib/python3.10/site-packages/i3ipc/connection.py", line 477, in _event_socket_poll
raise e
File "/usr/lib/python3.10/site-packages/i3ipc/connection.py", line 474, in _event_socket_poll
self._pubsub.emit(event_name, event)
File "/usr/lib/python3.10/site-packages/i3ipc/_private/pubsub.py", line 28, in emit
s['handler'](self.conn, data)
File "/home/jticket/src/I38/scripts/sound.py", line 12, in on_mode
mode = i3ipc.ModeEvent(['change'])
File "/usr/lib/python3.10/site-packages/i3ipc/events.py", line 112, in init
self.change = data['change']
TypeError: list indices must be integers or slices, not str