I can't exit from this if construct
#!/usr/bin/python2.7
import os
import re
import time
global state
#print status_on.group()
def main():
get_current_jack_status = """amixer -c1 contents | grep -A 2 'Headphone Jack'"""
output = os.popen(get_current_jack_status).read()
status_on = re.search('values=on', output)
if status_on:
state = status_on
os.system("notify-send 'Audio Manager' 'An audio jack was plugged in' -i audacity.png")
if status_on == state:
print "True"
state = 1 #here i can't exit
if status_on != state:
print state
os.system("notify-send 'Audio Manager' 'An audio jack was unplugged' -i audacity.png")
while True:
main()
I've tried pass but when I execute the script it says as output:
True
1
True
1
ecc. If I use "break" it crashes.