2022-11-22 17:53:53 -05:00
#!/usr/bin/env python3
2024-06-14 21:53:21 -04:00
# This file is part of I38.
# I38 is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
# I38 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with I38. If not, see <https://www.gnu.org/licenses/>.
2022-11-23 20:25:29 -05:00
2022-11-22 17:53:53 -05:00
import i3ipc
2022-11-23 20:06:56 -05:00
from i3ipc import Event
2022-11-22 20:37:27 -05:00
from os import system
#This script allows for sounds in i3
2022-11-23 20:06:56 -05:00
i3 = i3ipc . Connection ( )
2022-11-22 17:53:53 -05:00
2022-11-22 18:25:06 -05:00
2022-11-22 20:37:27 -05:00
def on_new_window ( self , i3 ) :
2024-05-14 23:35:55 -04:00
if i3 . container . name == ' xfce4-notifyd ' :
2024-07-13 18:55:32 -04:00
system ( ' play -nqV0 synth .05 sq 1800 tri 2400 delay 0 .03 remix - repeat 2 echo .55 0.7 20 1 norm -12 & ' )
2024-05-14 23:35:55 -04:00
else :
2024-07-13 18:55:32 -04:00
system ( ' play -nqV0 synth .25 sin 440:880 sin 480:920 remix - norm -3 pitch -500 & ' )
2022-11-22 18:25:06 -05:00
2023-09-26 08:38:02 -04:00
def on_close_window ( self , i3 ) :
2024-05-14 23:35:55 -04:00
if i3 . container . name != ' xfce4-notifyd ' :
2024-07-13 18:55:32 -04:00
system ( ' play -nqV0 synth .25 sin 880:440 sin 920:480 remix - norm -3 pitch -500 & ' )
2023-09-26 08:38:02 -04:00
2022-11-23 20:06:56 -05:00
def on_mode ( self , event ) :
mode = event . change
2023-04-25 19:09:20 -04:00
if mode == ' ratpoison ' :
2022-11-23 22:55:42 -05:00
system ( ' play -qV0 " |sox -np synth .07 sq 400 " " |sox -np synth .5 sq 800 " fade h 0 .5 .5 norm -20 & ' )
2023-04-25 19:09:20 -04:00
elif mode == ' bypass ' :
system ( ' play -nqV0 synth .1 saw 700 saw 1200 delay 0 .04 remix - norm -6 ' )
2023-06-01 15:47:10 -04:00
elif mode == ' default ' :
2023-04-25 19:09:20 -04:00
system ( ' play -qV0 " |sox -np synth .07 sq 400 " " |sox -np synth .5 sq 800 " fade h 0 .5 .5 norm -20 reverse & ' )
2023-06-01 15:47:10 -04:00
else :
2024-07-13 18:55:32 -04:00
system ( ' play -nqV0 synth 0.05 pluck F3 norm -8 : synth 0.05 pluck C4 norm -8 : synth 0.05 pluck F4 norm -8 : synth 0.05 pluck C5 norm -8 ' )
2022-11-22 18:25:06 -05:00
2022-11-23 17:13:28 -05:00
def on_workspace_focus ( self , i3 ) :
2022-11-30 02:25:23 -05:00
#system('play -qnV0 synth pi fade 0 .25 .15 pad 0 1 reverb overdrive riaa norm -8 speed 1 &')
pass
2022-11-23 17:13:28 -05:00
2022-11-23 17:32:32 -05:00
def on_workspace_move ( self , i3 ) :
2022-11-23 22:55:42 -05:00
system ( ' play -qnV0 synth pi fade 0 .25 .15 pad 0 1 reverb overdrive riaa norm -8 speed 1 reverse & ' )
2022-11-23 17:32:32 -05:00
2022-11-23 20:33:23 -05:00
def on_restart ( self , i3 ) :
2024-07-13 18:55:32 -04:00
system ( ' play -qnV0 synth .25 saw 500:1200 fade .1 .25 .1 norm -8 & ' )
2022-11-23 20:33:23 -05:00
2022-11-26 23:30:15 -05:00
def on_exit ( self , i3 ) :
2024-07-13 18:55:32 -04:00
system ( ' play -qnV0 synth .3 sin 700:200 fade 0 .3 0 & ' )
2022-11-26 23:30:15 -05:00
def on_fullscreen ( self , i3 ) :
2024-07-13 18:55:32 -04:00
system ( ' play -qnV0 synth br flanger fade h .3 .3 0 & ' )
2022-11-26 23:30:15 -05:00
2022-11-22 17:53:53 -05:00
i3 = i3ipc . Connection ( )
2022-11-22 20:37:27 -05:00
i3 . on ( ' window::new ' , on_new_window )
2023-09-26 08:38:02 -04:00
i3 . on ( ' window::close ' , on_close_window )
2022-11-23 20:06:56 -05:00
i3 . on ( Event . MODE , on_mode )
2022-11-23 17:13:28 -05:00
i3 . on ( ' workspace::focus ' , on_workspace_focus )
2022-11-23 17:32:32 -05:00
i3 . on ( ' window::move ' , on_workspace_move )
2022-11-26 23:30:15 -05:00
i3 . on ( ' window::fullscreen_mode ' , on_fullscreen )
2022-11-23 20:33:23 -05:00
i3 . on ( ' shutdown::restart ' , on_restart )
2022-11-26 23:30:15 -05:00
i3 . on ( ' shutdown::exit ' , on_exit )
2022-11-22 17:53:53 -05:00
i3 . main ( )