add asoundconf
This commit is contained in:
parent
a3474b0588
commit
829bfd8a7a
|
@ -0,0 +1,193 @@
|
||||||
|
# HG changeset patch
|
||||||
|
# User Alad Wenter <alad@archlinux.org>
|
||||||
|
# Date 1565311059 -7200
|
||||||
|
# Fri Aug 09 02:37:39 2019 +0200
|
||||||
|
# Node ID e92452338b542c3626f81db079610753f723c9b9
|
||||||
|
# Parent bf25f416f615a43267abecab4c599e86f363438b
|
||||||
|
python3: syntax changes
|
||||||
|
|
||||||
|
diff -r bf25f416f615 -r e92452338b54 asoundconf
|
||||||
|
--- a/asoundconf Sun May 31 20:26:03 2015 +0200
|
||||||
|
+++ b/asoundconf Fri Aug 09 02:37:39 2019 +0200
|
||||||
|
@@ -1,4 +1,4 @@
|
||||||
|
-#!/usr/bin/python2
|
||||||
|
+#!/usr/bin/python3
|
||||||
|
|
||||||
|
# (C) 2005 Canonical Ltd.
|
||||||
|
# Author: Martin Pitt <martin.pitt@ubuntu.com>
|
||||||
|
@@ -98,7 +98,7 @@
|
||||||
|
open(our_conf_file, 'w').write(our_conf_header)
|
||||||
|
return True
|
||||||
|
except IOError:
|
||||||
|
- print >> sys.stderr, 'Error: could not create', our_conf_file
|
||||||
|
+ print('Error: could not create', our_conf_file, file=sys.stderr)
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@@ -116,7 +116,7 @@
|
||||||
|
open(asoundrc_file, 'w').write('%s\n%s\n<%s>\n\n' % (asoundrc_header, inclusion_comment, our_conf_file))
|
||||||
|
return True
|
||||||
|
except IOError:
|
||||||
|
- print >> sys.stderr, 'Error: could not create', asoundrc_file
|
||||||
|
+ print('Error: could not create', asoundrc_file, file=sys.stderr)
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@@ -229,7 +229,7 @@
|
||||||
|
for line in open(our_conf_file):
|
||||||
|
m = setting_re.match(line)
|
||||||
|
if m:
|
||||||
|
- print m.group(1).strip()
|
||||||
|
+ print(m.group(1).strip())
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
except IOError:
|
||||||
|
@@ -245,9 +245,9 @@
|
||||||
|
except IOError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
- print "Names of available sound cards:"
|
||||||
|
+ print("Names of available sound cards:")
|
||||||
|
for cardname in card_lines:
|
||||||
|
- print cardname.id_
|
||||||
|
+ print(cardname.id_)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@@ -262,13 +262,13 @@
|
||||||
|
except IOError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
- print "Available devices for all sound cards:"
|
||||||
|
+ print("Available devices for all sound cards:")
|
||||||
|
for dev in dev_lines:
|
||||||
|
card = next(c for c in card_lines if c.card_num == dev.card_num) # find card by number
|
||||||
|
- print "hw:%d,%d: %s : %s : %s : %s" % (
|
||||||
|
+ print('hw:{},{}: {} : {} : {} : {}'.format(
|
||||||
|
dev.card_num, dev.dev_num,
|
||||||
|
card.id_, card.name,
|
||||||
|
- dev.id_, dev.name)
|
||||||
|
+ dev.id_, dev.name))
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
@@ -294,7 +294,7 @@
|
||||||
|
return False
|
||||||
|
|
||||||
|
found = 0
|
||||||
|
- for i in xrange(len(lines)):
|
||||||
|
+ for i in range(len(lines)):
|
||||||
|
if setting_re.match(lines[i]):
|
||||||
|
del lines[i]
|
||||||
|
found = 1
|
||||||
|
@@ -340,7 +340,7 @@
|
||||||
|
|
||||||
|
# if setting is already present, change it
|
||||||
|
found = 0
|
||||||
|
- for i in xrange(len(lines)):
|
||||||
|
+ for i in range(len(lines)):
|
||||||
|
if setting_re.match(lines[i]):
|
||||||
|
lines[i] = newsetting
|
||||||
|
found = 1
|
||||||
|
@@ -426,10 +426,10 @@
|
||||||
|
##
|
||||||
|
|
||||||
|
if os.geteuid() == 0:
|
||||||
|
- print superuser_warn
|
||||||
|
+ print(superuser_warn)
|
||||||
|
|
||||||
|
if len(sys.argv) < 2 or sys.argv[1] == '--help' or sys.argv[1] == '-h':
|
||||||
|
- print usage
|
||||||
|
+ print(usage)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
if sys.argv[1] == 'is-active':
|
||||||
|
@@ -437,19 +437,19 @@
|
||||||
|
|
||||||
|
if sys.argv[1] == 'get':
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
- print usage
|
||||||
|
+ print(usage)
|
||||||
|
sys.exit(1)
|
||||||
|
exit_code(get(sys.argv[2]))
|
||||||
|
|
||||||
|
if sys.argv[1] == 'delete':
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
- print usage
|
||||||
|
+ print(usage)
|
||||||
|
sys.exit(1)
|
||||||
|
exit_code(delete(sys.argv[2]))
|
||||||
|
|
||||||
|
if sys.argv[1] == 'set':
|
||||||
|
if len(sys.argv) != 4:
|
||||||
|
- print usage
|
||||||
|
+ print(usage)
|
||||||
|
sys.exit(1)
|
||||||
|
exit_code(set(sys.argv[2], sys.argv[3]))
|
||||||
|
|
||||||
|
@@ -461,7 +461,7 @@
|
||||||
|
|
||||||
|
if sys.argv[1] == 'set-default-card':
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
- print needs_default_card
|
||||||
|
+ print(needs_default_card)
|
||||||
|
sys.exit(1)
|
||||||
|
exit_code(set_default_card(sys.argv[2]))
|
||||||
|
|
||||||
|
@@ -476,13 +476,13 @@
|
||||||
|
|
||||||
|
if sys.argv[1] == 'set-oss':
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
- print needs_oss_dev
|
||||||
|
+ print(needs_oss_dev)
|
||||||
|
sys.exit(1)
|
||||||
|
exit_code(set_oss(sys.argv[2]))
|
||||||
|
|
||||||
|
if sys.argv[1] == 'unset-oss':
|
||||||
|
exit_code(unset_oss())
|
||||||
|
|
||||||
|
-print usage
|
||||||
|
+print(usage)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
diff -r bf25f416f615 -r e92452338b54 asoundconf_common.py
|
||||||
|
--- a/asoundconf_common.py Sun May 31 20:26:03 2015 +0200
|
||||||
|
+++ b/asoundconf_common.py Fri Aug 09 02:37:39 2019 +0200
|
||||||
|
@@ -1,4 +1,4 @@
|
||||||
|
-#!/usr/bin/python2
|
||||||
|
+#!/usr/bin/python3
|
||||||
|
|
||||||
|
# License: GNU General Public License, version 2 or any later version
|
||||||
|
#
|
||||||
|
@@ -38,6 +38,7 @@
|
||||||
|
|
||||||
|
lines = procfile.readlines()
|
||||||
|
for l in lines:
|
||||||
|
+ l = l.decode()
|
||||||
|
if cardline.match(l):
|
||||||
|
groups = cardline.match(l).groups()
|
||||||
|
c = SndCardInfo()
|
||||||
|
@@ -62,6 +63,7 @@
|
||||||
|
|
||||||
|
lines = procfile.readlines()
|
||||||
|
for l in lines:
|
||||||
|
+ l = l.decode()
|
||||||
|
fields = l.split(':')
|
||||||
|
if len(fields) >= 3:
|
||||||
|
if devnum.match(fields[0]):
|
||||||
|
@@ -73,4 +75,4 @@
|
||||||
|
d.name = fields[2].strip()
|
||||||
|
dev_lines.append(d)
|
||||||
|
|
||||||
|
- return dev_lines
|
||||||
|
\ No newline at end of file
|
||||||
|
+ return dev_lines
|
||||||
|
diff -r bf25f416f615 -r e92452338b54 setup.py
|
||||||
|
--- a/setup.py Sun May 31 20:26:03 2015 +0200
|
||||||
|
+++ b/setup.py Fri Aug 09 02:37:39 2019 +0200
|
||||||
|
@@ -1,4 +1,4 @@
|
||||||
|
-#!/usr/bin/env python2
|
||||||
|
+#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os, sys
|
||||||
|
|
|
@ -0,0 +1,372 @@
|
||||||
|
# HG changeset patch
|
||||||
|
# User Alad Wenter <alad@archlinux.org>
|
||||||
|
# Date 1565311107 -7200
|
||||||
|
# Fri Aug 09 02:38:27 2019 +0200
|
||||||
|
# Node ID 6244f8fd266243931caa0f03da46380ddc9a3aeb
|
||||||
|
# Parent e92452338b542c3626f81db079610753f723c9b9
|
||||||
|
python3: convert tabs to spaces
|
||||||
|
|
||||||
|
diff -r e92452338b54 -r 6244f8fd2662 asoundconf
|
||||||
|
--- a/asoundconf Fri Aug 09 02:37:39 2019 +0200
|
||||||
|
+++ b/asoundconf Fri Aug 09 02:38:27 2019 +0200
|
||||||
|
@@ -62,26 +62,26 @@
|
||||||
|
|
||||||
|
def get_default_predefs():
|
||||||
|
try:
|
||||||
|
- if not os.path.exists(predefs_file):
|
||||||
|
- return
|
||||||
|
- predefs_file_entire = open(predefs_file).readlines()
|
||||||
|
- r = re.compile('^defaults')
|
||||||
|
- ## Between these hashes, add additional unique regexps that
|
||||||
|
- ## must exist at the end of the user's custom asoundrc.
|
||||||
|
- s = re.compile('^defaults.namehint')
|
||||||
|
- ##
|
||||||
|
- predefs_list = []
|
||||||
|
- must_append_predefs_list = []
|
||||||
|
- for i in predefs_file_entire:
|
||||||
|
- if r.match(i) and not s.match(i):
|
||||||
|
- predefs_list.append(str(i).strip())
|
||||||
|
- elif s.match(i):
|
||||||
|
- must_append_predefs_list.append(str(i).strip())
|
||||||
|
- for i in must_append_predefs_list:
|
||||||
|
- predefs_list.append(str(i).strip())
|
||||||
|
- return predefs_list
|
||||||
|
+ if not os.path.exists(predefs_file):
|
||||||
|
+ return
|
||||||
|
+ predefs_file_entire = open(predefs_file).readlines()
|
||||||
|
+ r = re.compile('^defaults')
|
||||||
|
+ ## Between these hashes, add additional unique regexps that
|
||||||
|
+ ## must exist at the end of the user's custom asoundrc.
|
||||||
|
+ s = re.compile('^defaults.namehint')
|
||||||
|
+ ##
|
||||||
|
+ predefs_list = []
|
||||||
|
+ must_append_predefs_list = []
|
||||||
|
+ for i in predefs_file_entire:
|
||||||
|
+ if r.match(i) and not s.match(i):
|
||||||
|
+ predefs_list.append(str(i).strip())
|
||||||
|
+ elif s.match(i):
|
||||||
|
+ must_append_predefs_list.append(str(i).strip())
|
||||||
|
+ for i in must_append_predefs_list:
|
||||||
|
+ predefs_list.append(str(i).strip())
|
||||||
|
+ return predefs_list
|
||||||
|
except IOError:
|
||||||
|
- pass
|
||||||
|
+ pass
|
||||||
|
|
||||||
|
|
||||||
|
def ensure_our_conf_exists():
|
||||||
|
@@ -237,40 +237,40 @@
|
||||||
|
|
||||||
|
|
||||||
|
def list():
|
||||||
|
- '''Print list of card IDs'''
|
||||||
|
-
|
||||||
|
- card_lines = []
|
||||||
|
- try:
|
||||||
|
- card_lines = asoundconf_common.parse_cards()
|
||||||
|
- except IOError:
|
||||||
|
- return False
|
||||||
|
-
|
||||||
|
+ '''Print list of card IDs'''
|
||||||
|
+
|
||||||
|
+ card_lines = []
|
||||||
|
+ try:
|
||||||
|
+ card_lines = asoundconf_common.parse_cards()
|
||||||
|
+ except IOError:
|
||||||
|
+ return False
|
||||||
|
+
|
||||||
|
print("Names of available sound cards:")
|
||||||
|
- for cardname in card_lines:
|
||||||
|
+ for cardname in card_lines:
|
||||||
|
print(cardname.id_)
|
||||||
|
- return True
|
||||||
|
+ return True
|
||||||
|
|
||||||
|
|
||||||
|
def list_all():
|
||||||
|
- '''Print list of devices for all cards (including number, id and name)'''
|
||||||
|
+ '''Print list of devices for all cards (including number, id and name)'''
|
||||||
|
|
||||||
|
- card_lines = []
|
||||||
|
- dev_lines = []
|
||||||
|
- try:
|
||||||
|
- card_lines = asoundconf_common.parse_cards()
|
||||||
|
- dev_lines = asoundconf_common.parse_devices()
|
||||||
|
- except IOError:
|
||||||
|
- return False
|
||||||
|
+ card_lines = []
|
||||||
|
+ dev_lines = []
|
||||||
|
+ try:
|
||||||
|
+ card_lines = asoundconf_common.parse_cards()
|
||||||
|
+ dev_lines = asoundconf_common.parse_devices()
|
||||||
|
+ except IOError:
|
||||||
|
+ return False
|
||||||
|
|
||||||
|
- print("Available devices for all sound cards:")
|
||||||
|
- for dev in dev_lines:
|
||||||
|
- card = next(c for c in card_lines if c.card_num == dev.card_num) # find card by number
|
||||||
|
- print('hw:{},{}: {} : {} : {} : {}'.format(
|
||||||
|
- dev.card_num, dev.dev_num,
|
||||||
|
- card.id_, card.name,
|
||||||
|
- dev.id_, dev.name))
|
||||||
|
+ print("Available devices for all sound cards:")
|
||||||
|
+ for dev in dev_lines:
|
||||||
|
+ card = next(c for c in card_lines if c.card_num == dev.card_num) # find card by number
|
||||||
|
+ print('hw:{},{}: {} : {} : {} : {}'.format(
|
||||||
|
+ dev.card_num, dev.dev_num,
|
||||||
|
+ card.id_, card.name,
|
||||||
|
+ dev.id_, dev.name))
|
||||||
|
|
||||||
|
- return True
|
||||||
|
+ return True
|
||||||
|
|
||||||
|
|
||||||
|
def delete(prmtr):
|
||||||
|
@@ -358,50 +358,50 @@
|
||||||
|
return True
|
||||||
|
|
||||||
|
def set_default_card(card):
|
||||||
|
- clist = get_default_predefs()
|
||||||
|
- sep = re.compile(r'[ \t]')
|
||||||
|
- com = re.compile('[ \t]*#.*')
|
||||||
|
- r = re.compile('^defaults.pcm.card')
|
||||||
|
- s = re.compile('^defaults.ctl.card')
|
||||||
|
- ## !defaults.pcm.card and defaults.ctl.card should lead
|
||||||
|
- ## the user's custom asoundrc.
|
||||||
|
- if set('!defaults.pcm.card', card) and \
|
||||||
|
- set('defaults.ctl.card', card):
|
||||||
|
- for i in clist:
|
||||||
|
- # remove any comments
|
||||||
|
- i = com.sub("",i)
|
||||||
|
- (j, k) = sep.split(i)
|
||||||
|
- if not r.match(j) and not s.match(j):
|
||||||
|
- if not set(j, k):
|
||||||
|
- return False
|
||||||
|
- return True
|
||||||
|
- else:
|
||||||
|
- return False
|
||||||
|
+ clist = get_default_predefs()
|
||||||
|
+ sep = re.compile(r'[ \t]')
|
||||||
|
+ com = re.compile('[ \t]*#.*')
|
||||||
|
+ r = re.compile('^defaults.pcm.card')
|
||||||
|
+ s = re.compile('^defaults.ctl.card')
|
||||||
|
+ ## !defaults.pcm.card and defaults.ctl.card should lead
|
||||||
|
+ ## the user's custom asoundrc.
|
||||||
|
+ if set('!defaults.pcm.card', card) and \
|
||||||
|
+ set('defaults.ctl.card', card):
|
||||||
|
+ for i in clist:
|
||||||
|
+ # remove any comments
|
||||||
|
+ i = com.sub("",i)
|
||||||
|
+ (j, k) = sep.split(i)
|
||||||
|
+ if not r.match(j) and not s.match(j):
|
||||||
|
+ if not set(j, k):
|
||||||
|
+ return False
|
||||||
|
+ return True
|
||||||
|
+ else:
|
||||||
|
+ return False
|
||||||
|
|
||||||
|
def reset_default_card():
|
||||||
|
- clist = get_default_predefs()
|
||||||
|
- sep = re.compile(r'[ \t]')
|
||||||
|
- com = re.compile('[ \t]*#.*')
|
||||||
|
- for i in clist:
|
||||||
|
- i = com.sub("",i)
|
||||||
|
- (j, k) = sep.split(i)
|
||||||
|
- if not delete(j):
|
||||||
|
- return False
|
||||||
|
- return True
|
||||||
|
+ clist = get_default_predefs()
|
||||||
|
+ sep = re.compile(r'[ \t]')
|
||||||
|
+ com = re.compile('[ \t]*#.*')
|
||||||
|
+ for i in clist:
|
||||||
|
+ i = com.sub("",i)
|
||||||
|
+ (j, k) = sep.split(i)
|
||||||
|
+ if not delete(j):
|
||||||
|
+ return False
|
||||||
|
+ return True
|
||||||
|
|
||||||
|
def delete_pcm_default():
|
||||||
|
- return delete('pcm.!default')
|
||||||
|
+ return delete('pcm.!default')
|
||||||
|
|
||||||
|
def delete_ctl_default():
|
||||||
|
- return delete('ctl.!default')
|
||||||
|
+ return delete('ctl.!default')
|
||||||
|
|
||||||
|
def set_pulseaudio():
|
||||||
|
return set('pcm.!default', '{ type pulse }') and \
|
||||||
|
- set('ctl.!default', '{ type pulse }')
|
||||||
|
+ set('ctl.!default', '{ type pulse }')
|
||||||
|
|
||||||
|
def unset_pulseaudio():
|
||||||
|
return delete_pcm_default() and \
|
||||||
|
- delete_ctl_default()
|
||||||
|
+ delete_ctl_default()
|
||||||
|
|
||||||
|
def set_oss(device):
|
||||||
|
endbrace = ' }'
|
||||||
|
@@ -454,34 +454,34 @@
|
||||||
|
exit_code(set(sys.argv[2], sys.argv[3]))
|
||||||
|
|
||||||
|
if sys.argv[1] == 'list':
|
||||||
|
- exit_code(list())
|
||||||
|
+ exit_code(list())
|
||||||
|
|
||||||
|
if sys.argv[1] == 'list-all':
|
||||||
|
- exit_code(list_all())
|
||||||
|
+ exit_code(list_all())
|
||||||
|
|
||||||
|
if sys.argv[1] == 'set-default-card':
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
- print(needs_default_card)
|
||||||
|
- sys.exit(1)
|
||||||
|
+ print(needs_default_card)
|
||||||
|
+ sys.exit(1)
|
||||||
|
exit_code(set_default_card(sys.argv[2]))
|
||||||
|
|
||||||
|
if sys.argv[1] == 'reset-default-card':
|
||||||
|
- exit_code(reset_default_card())
|
||||||
|
+ exit_code(reset_default_card())
|
||||||
|
|
||||||
|
if sys.argv[1] == 'set-pulseaudio':
|
||||||
|
- exit_code(set_pulseaudio())
|
||||||
|
+ exit_code(set_pulseaudio())
|
||||||
|
|
||||||
|
if sys.argv[1] == 'unset-pulseaudio':
|
||||||
|
- exit_code(unset_pulseaudio())
|
||||||
|
+ exit_code(unset_pulseaudio())
|
||||||
|
|
||||||
|
if sys.argv[1] == 'set-oss':
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
- print(needs_oss_dev)
|
||||||
|
- sys.exit(1)
|
||||||
|
+ print(needs_oss_dev)
|
||||||
|
+ sys.exit(1)
|
||||||
|
exit_code(set_oss(sys.argv[2]))
|
||||||
|
|
||||||
|
if sys.argv[1] == 'unset-oss':
|
||||||
|
- exit_code(unset_oss())
|
||||||
|
+ exit_code(unset_oss())
|
||||||
|
|
||||||
|
print(usage)
|
||||||
|
sys.exit(1)
|
||||||
|
diff -r e92452338b54 -r 6244f8fd2662 asoundconf_common.py
|
||||||
|
--- a/asoundconf_common.py Fri Aug 09 02:37:39 2019 +0200
|
||||||
|
+++ b/asoundconf_common.py Fri Aug 09 02:38:27 2019 +0200
|
||||||
|
@@ -11,68 +11,68 @@
|
||||||
|
|
||||||
|
|
||||||
|
class SndCardInfo(object):
|
||||||
|
- def __init__(self):
|
||||||
|
- self.card_num = -1
|
||||||
|
- self.id_ = ''
|
||||||
|
- self.name = ''
|
||||||
|
+ def __init__(self):
|
||||||
|
+ self.card_num = -1
|
||||||
|
+ self.id_ = ''
|
||||||
|
+ self.name = ''
|
||||||
|
|
||||||
|
|
||||||
|
class SndPcmInfo(object):
|
||||||
|
- def __init__(self):
|
||||||
|
- self.card_num = -1
|
||||||
|
- self.dev_num = -1
|
||||||
|
- self.id_ = ''
|
||||||
|
- self.name = ''
|
||||||
|
+ def __init__(self):
|
||||||
|
+ self.card_num = -1
|
||||||
|
+ self.dev_num = -1
|
||||||
|
+ self.id_ = ''
|
||||||
|
+ self.name = ''
|
||||||
|
|
||||||
|
|
||||||
|
def parse_cards():
|
||||||
|
- '''Get card info from /proc/asound/cards'''
|
||||||
|
+ '''Get card info from /proc/asound/cards'''
|
||||||
|
|
||||||
|
- cardspath = '/proc/asound/cards'
|
||||||
|
- if not os.path.exists(cardspath):
|
||||||
|
- raise IOError(cardspath + ' does not exist')
|
||||||
|
- procfile = open(cardspath, 'rb')
|
||||||
|
+ cardspath = '/proc/asound/cards'
|
||||||
|
+ if not os.path.exists(cardspath):
|
||||||
|
+ raise IOError(cardspath + ' does not exist')
|
||||||
|
+ procfile = open(cardspath, 'rb')
|
||||||
|
|
||||||
|
- cardline = re.compile('^\s*(\d+)\s*\[(\w+)\s*\].*-\s(.*)$') # capture card number, id and name
|
||||||
|
- card_lines = []
|
||||||
|
+ cardline = re.compile('^\s*(\d+)\s*\[(\w+)\s*\].*-\s(.*)$') # capture card number, id and name
|
||||||
|
+ card_lines = []
|
||||||
|
|
||||||
|
- lines = procfile.readlines()
|
||||||
|
- for l in lines:
|
||||||
|
- l = l.decode()
|
||||||
|
- if cardline.match(l):
|
||||||
|
- groups = cardline.match(l).groups()
|
||||||
|
- c = SndCardInfo()
|
||||||
|
- c.card_num = int(groups[0])
|
||||||
|
- c.id_ = groups[1].strip()
|
||||||
|
- c.name = groups[2].strip()
|
||||||
|
- card_lines.append(c)
|
||||||
|
+ lines = procfile.readlines()
|
||||||
|
+ for l in lines:
|
||||||
|
+ l = l.decode()
|
||||||
|
+ if cardline.match(l):
|
||||||
|
+ groups = cardline.match(l).groups()
|
||||||
|
+ c = SndCardInfo()
|
||||||
|
+ c.card_num = int(groups[0])
|
||||||
|
+ c.id_ = groups[1].strip()
|
||||||
|
+ c.name = groups[2].strip()
|
||||||
|
+ card_lines.append(c)
|
||||||
|
|
||||||
|
- return card_lines
|
||||||
|
+ return card_lines
|
||||||
|
|
||||||
|
|
||||||
|
def parse_devices():
|
||||||
|
- '''Get device numbers and names from /proc/asound/pcm'''
|
||||||
|
+ '''Get device numbers and names from /proc/asound/pcm'''
|
||||||
|
|
||||||
|
- devspath = '/proc/asound/pcm'
|
||||||
|
- if not os.path.exists(devspath):
|
||||||
|
- raise IOError(devspath + ' does not exist')
|
||||||
|
- procfile = open(devspath, 'rb')
|
||||||
|
+ devspath = '/proc/asound/pcm'
|
||||||
|
+ if not os.path.exists(devspath):
|
||||||
|
+ raise IOError(devspath + ' does not exist')
|
||||||
|
+ procfile = open(devspath, 'rb')
|
||||||
|
|
||||||
|
- devnum = re.compile('(\d+)-(\d+)')
|
||||||
|
- dev_lines = []
|
||||||
|
+ devnum = re.compile('(\d+)-(\d+)')
|
||||||
|
+ dev_lines = []
|
||||||
|
|
||||||
|
- lines = procfile.readlines()
|
||||||
|
- for l in lines:
|
||||||
|
- l = l.decode()
|
||||||
|
- fields = l.split(':')
|
||||||
|
- if len(fields) >= 3:
|
||||||
|
- if devnum.match(fields[0]):
|
||||||
|
- groups = devnum.match(fields[0]).groups()
|
||||||
|
- d = SndPcmInfo()
|
||||||
|
- d.card_num = int(groups[0])
|
||||||
|
- d.dev_num = int(groups[1])
|
||||||
|
- d.id_ = fields[1].strip()
|
||||||
|
- d.name = fields[2].strip()
|
||||||
|
- dev_lines.append(d)
|
||||||
|
+ lines = procfile.readlines()
|
||||||
|
+ for l in lines:
|
||||||
|
+ l = l.decode()
|
||||||
|
+ fields = l.split(':')
|
||||||
|
+ if len(fields) >= 3:
|
||||||
|
+ if devnum.match(fields[0]):
|
||||||
|
+ groups = devnum.match(fields[0]).groups()
|
||||||
|
+ d = SndPcmInfo()
|
||||||
|
+ d.card_num = int(groups[0])
|
||||||
|
+ d.dev_num = int(groups[1])
|
||||||
|
+ d.id_ = fields[1].strip()
|
||||||
|
+ d.name = fields[2].strip()
|
||||||
|
+ dev_lines.append(d)
|
||||||
|
|
||||||
|
- return dev_lines
|
||||||
|
+ return dev_lines
|
|
@ -0,0 +1,125 @@
|
||||||
|
# HG changeset patch
|
||||||
|
# User Alad Wenter <alad@archlinux.org>
|
||||||
|
# Date 1565313540 -7200
|
||||||
|
# Fri Aug 09 03:19:00 2019 +0200
|
||||||
|
# Node ID f382f5fa628e5a3e0e5924c954ea88e264264270
|
||||||
|
# Parent 6244f8fd266243931caa0f03da46380ddc9a3aeb
|
||||||
|
python3: migrate to PyGObject
|
||||||
|
|
||||||
|
diff -r 6244f8fd2662 -r f382f5fa628e asoundconf-gtk/asoundconf-gtk
|
||||||
|
--- a/asoundconf-gtk/asoundconf-gtk Fri Aug 09 02:38:27 2019 +0200
|
||||||
|
+++ b/asoundconf-gtk/asoundconf-gtk Fri Aug 09 03:19:00 2019 +0200
|
||||||
|
@@ -1,4 +1,4 @@
|
||||||
|
-#!/usr/bin/env python2
|
||||||
|
+#!/usr/bin/env python3
|
||||||
|
# asoundconf-gtk - GTK GUI to select the default sound card
|
||||||
|
#
|
||||||
|
# (C) 2006 Toby Smithe
|
||||||
|
@@ -21,7 +21,9 @@
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
-import sys, re, os, pygtk, gtk, string
|
||||||
|
+import sys, re, os, gi
|
||||||
|
+gi.require_version('Gtk', '3.0')
|
||||||
|
+from gi.repository import Gtk
|
||||||
|
import asoundconf_common
|
||||||
|
|
||||||
|
###################################
|
||||||
|
@@ -50,12 +52,12 @@
|
||||||
|
def die_on_error():
|
||||||
|
'''Kill the application if it cannot run'''
|
||||||
|
if not os.path.exists("/proc/asound/cards"):
|
||||||
|
- print "You need at least one ALSA sound card for this to work!"
|
||||||
|
+ print("You need at least one ALSA sound card for this to work!")
|
||||||
|
sys.exit(-1)
|
||||||
|
if os.system(asoundconf + " is-active"):
|
||||||
|
- print "You need to make sure asoundconf is active!"
|
||||||
|
- print "By default, asoundconf's configuration file is ~/.asoundrc.asoundconf"
|
||||||
|
- print "and must be included in ~/.asoundrc. Open this file to make sure it is!"
|
||||||
|
+ print("You need to make sure asoundconf is active!")
|
||||||
|
+ print("By default, asoundconf's configuration file is ~/.asoundrc.asoundconf")
|
||||||
|
+ print("and must be included in ~/.asoundrc. Open this file to make sure it is!")
|
||||||
|
sys.exit(-2)
|
||||||
|
|
||||||
|
def get(setting):
|
||||||
|
@@ -71,7 +73,7 @@
|
||||||
|
value_raw = get("defaults.pcm.card")
|
||||||
|
if not value_raw:
|
||||||
|
return 0
|
||||||
|
- value = string.strip(value_raw[0])
|
||||||
|
+ value = str.strip(value_raw[0])
|
||||||
|
return value
|
||||||
|
|
||||||
|
def set_default_card(card):
|
||||||
|
@@ -95,7 +97,7 @@
|
||||||
|
class asoundconf_gtk:
|
||||||
|
def destroy(self, widget, data=None):
|
||||||
|
'''This is a stub function to allow for stuff to be done on close'''
|
||||||
|
- gtk.main_quit()
|
||||||
|
+ Gtk.main_quit()
|
||||||
|
|
||||||
|
def delete_event(self, widget, event, data=None):
|
||||||
|
'''Again, a stub to allow stuff to happen when widgets are deleted'''
|
||||||
|
@@ -133,17 +135,17 @@
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
# Initiate the window
|
||||||
|
- self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||||
|
+ self.window = Gtk.Window.new(Gtk.WindowType.TOPLEVEL)
|
||||||
|
self.window.set_title("Default Sound Card")
|
||||||
|
- self.window.set_position(gtk.WIN_POS_CENTER)
|
||||||
|
+ self.window.set_position(Gtk.WindowPosition.CENTER)
|
||||||
|
# Create an HBox box
|
||||||
|
- self.selectionbox = gtk.HBox(False, 0)
|
||||||
|
+ self.selectionbox = Gtk.HBox.new(False, 0)
|
||||||
|
# Create a button
|
||||||
|
- self.button = gtk.Button("Quit")
|
||||||
|
+ self.button = Gtk.Button.new_with_label("Quit")
|
||||||
|
#self.button.connect("clicked", self.reset, None)
|
||||||
|
- self.button.connect_object("clicked", gtk.Widget.destroy, self.window)
|
||||||
|
+ self.button.connect_object("clicked", Gtk.Widget.destroy, self.window)
|
||||||
|
# Create combobox
|
||||||
|
- self.combo = gtk.combo_box_new_text()
|
||||||
|
+ self.combo = Gtk.ComboBoxText()
|
||||||
|
self.liststore = self.combo.get_model()
|
||||||
|
|
||||||
|
# Add cards and devices to combobox liststore
|
||||||
|
@@ -158,10 +160,10 @@
|
||||||
|
self.combo.append_text("%s (%s)" % (card.id_, device.name))
|
||||||
|
self.combo.connect("changed", self.choose, None)
|
||||||
|
# Create a label
|
||||||
|
- self.label = gtk.Label("Select default card: ")
|
||||||
|
+ self.label = Gtk.Label.new("Select default card: ")
|
||||||
|
|
||||||
|
# Spacing between controls
|
||||||
|
- label_height = self.label.size_request()[1]
|
||||||
|
+ label_height = self.label.get_size_request()[1]
|
||||||
|
CTL_SPACING = label_height / 3
|
||||||
|
self.selectionbox.set_spacing(CTL_SPACING)
|
||||||
|
self.window.set_border_width(CTL_SPACING)
|
||||||
|
@@ -170,13 +172,13 @@
|
||||||
|
self.selectionbox.pack_start(self.combo, True, True, 0)
|
||||||
|
self.selectionbox.pack_start(self.button, True, True, 0)
|
||||||
|
# Create a VBox
|
||||||
|
- self.vbox = gtk.VBox(False, CTL_SPACING)
|
||||||
|
+ self.vbox = Gtk.VBox.new(False, CTL_SPACING)
|
||||||
|
self.window.add(self.vbox)
|
||||||
|
self.vbox.pack_start(self.label, True, True, 0)
|
||||||
|
self.vbox.pack_start(self.selectionbox, True, True, 0)
|
||||||
|
# Create PulseAudio checkbox if ALSA PulseAudio plugin installed
|
||||||
|
if os.path.exists("/usr/lib/alsa-lib/libasound_module_pcm_pulse.so") and os.path.exists("/usr/lib/alsa-lib/libasound_module_ctl_pulse.so"):
|
||||||
|
- #self.pulsecheck = gtk.CheckButton("Use _PulseAudio?")
|
||||||
|
+ #self.pulsecheck = Gtk.CheckButton("Use _PulseAudio?")
|
||||||
|
self.combo.append_text("PulseAudio")
|
||||||
|
try: pcmDefault = get("pcm.!default")[0]
|
||||||
|
except: pcmDefault = ""
|
||||||
|
@@ -196,7 +198,7 @@
|
||||||
|
|
||||||
|
def main(self):
|
||||||
|
'''Do the stuffs'''
|
||||||
|
- gtk.main()
|
||||||
|
+ Gtk.main()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
die_on_error()
|
|
@ -0,0 +1,57 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
# JOBoRun : Jwm OpenBox Obarun RUNit
|
||||||
|
# Maintainer : Joe Bo Run <joborun@disroot.org>
|
||||||
|
# PkgSource : url="https://gittea.disroot.org/joborun-pkg/jobcomm/$pkgname"
|
||||||
|
# Website : https://pozol.eu
|
||||||
|
#-----------------------------------------| DESCRIPTION |---------------------------------------
|
||||||
|
|
||||||
|
pkgname=asoundconf
|
||||||
|
#epoch=1
|
||||||
|
pkgver=1.2
|
||||||
|
pkgrel=08
|
||||||
|
pkgdesc="utility to read, change, and keep the user's ALSA library configuration"
|
||||||
|
url="https://bitbucket.org/stativ/asoundconf"
|
||||||
|
depends=('python')
|
||||||
|
makedepends=('git')
|
||||||
|
optdepends=('python-gobject: asoundconf-gtk GUI')
|
||||||
|
_commit=55cdf2e78b7f28ee1808346e5d4e32f7e95618dc # 1.2
|
||||||
|
source=("git+https://bitbucket.org/stativ/asoundconf.git#commit=$_commit"
|
||||||
|
'0001-python3-syntax.patch'
|
||||||
|
'0002-python3-spaces.patch'
|
||||||
|
'0003-python3-gobject.patch')
|
||||||
|
|
||||||
|
#pkgver() {
|
||||||
|
# cd "$srcdir/$pkgname"
|
||||||
|
# git describe --tags --always
|
||||||
|
#}
|
||||||
|
|
||||||
|
prepare() {
|
||||||
|
cd "$pkgname"
|
||||||
|
patch -p1 < "$srcdir"/0001-python3-syntax.patch
|
||||||
|
patch -p1 < "$srcdir"/0002-python3-spaces.patch
|
||||||
|
patch -p1 < "$srcdir"/0003-python3-gobject.patch
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
cd "$pkgname"
|
||||||
|
python setup.py build
|
||||||
|
}
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd "$pkgname"
|
||||||
|
python setup.py install --root="$pkgdir/" --optimize=1 --skip-build
|
||||||
|
}
|
||||||
|
|
||||||
|
#---- arch license gpg-key & sha256sums ----
|
||||||
|
|
||||||
|
arch=(x86_64)
|
||||||
|
|
||||||
|
license=('GPL')
|
||||||
|
|
||||||
|
sha256sums=(SKIP # asoundconf
|
||||||
|
7a93b1b05615ea73172e8d7a017d2557dbdaa3d34c51d91d46961c5e85f0d2af # 0001-python3-syntax.patch
|
||||||
|
dfde8ccc2d57fee3132a3f7b58858300765e56c5a165e605fc52e8c7550bbcbf # 0002-python3-spaces.patch
|
||||||
|
ae7bf3c388e1e6a45f6e0fcd44350d9e5bffb2453e2f397470dab9175ccc1072) # 0003-python3-gobject.patch
|
||||||
|
|
||||||
|
## 462040a8046bdf708ea2ac2f746492703a8705b00bf92340fc3f3767f661ce1b asoundconf-1.2-08-x86_64.pkg.tar.lz
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
# Maintainer: Alad Wenter <alad@archlinux.org>
|
||||||
|
# Contributor: Lukas Jirkovsky <l.jirkovsky@gmail.com>
|
||||||
|
pkgname=asoundconf
|
||||||
|
epoch=1
|
||||||
|
pkgver=1.2
|
||||||
|
_commit=55cdf2e78b7f28ee1808346e5d4e32f7e95618dc # 1.2
|
||||||
|
pkgrel=7
|
||||||
|
pkgdesc="utility to read and change the user's ALSA library configuration"
|
||||||
|
arch=('any')
|
||||||
|
url="https://bitbucket.org/stativ/asoundconf"
|
||||||
|
license=('GPL')
|
||||||
|
depends=('python')
|
||||||
|
makedepends=('git')
|
||||||
|
optdepends=('python-gobject: asoundconf-gtk GUI')
|
||||||
|
source=("git+https://bitbucket.org/stativ/asoundconf.git#commit=$_commit"
|
||||||
|
'0001-python3-syntax.patch'
|
||||||
|
'0002-python3-spaces.patch'
|
||||||
|
'0003-python3-gobject.patch')
|
||||||
|
sha256sums=('SKIP'
|
||||||
|
'7a93b1b05615ea73172e8d7a017d2557dbdaa3d34c51d91d46961c5e85f0d2af'
|
||||||
|
'dfde8ccc2d57fee3132a3f7b58858300765e56c5a165e605fc52e8c7550bbcbf'
|
||||||
|
'ae7bf3c388e1e6a45f6e0fcd44350d9e5bffb2453e2f397470dab9175ccc1072')
|
||||||
|
|
||||||
|
prepare() {
|
||||||
|
cd "$pkgname"
|
||||||
|
patch -p1 < "$srcdir"/0001-python3-syntax.patch
|
||||||
|
patch -p1 < "$srcdir"/0002-python3-spaces.patch
|
||||||
|
patch -p1 < "$srcdir"/0003-python3-gobject.patch
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
cd "$pkgname"
|
||||||
|
python setup.py build
|
||||||
|
}
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd "$pkgname"
|
||||||
|
python setup.py install --root="$pkgdir/" --optimize=1 --skip-build
|
||||||
|
}
|
||||||
|
|
||||||
|
# vim:set ts=2 sw=2 et:
|
|
@ -0,0 +1 @@
|
||||||
|
rm -rf {src,pkg,asoundconf}
|
|
@ -0,0 +1,4 @@
|
||||||
|
python
|
||||||
|
git
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
real 2m10.841s
|
||||||
|
user 0m1.477s
|
||||||
|
sys 0m0.386s
|
||||||
|
|
Loading…
Reference in New Issue