This file is indexed.

/usr/share/pyshared/plwm/mixer.py is in python-plwm 2.6a+20080530-1.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#
# mw_mixer.py -- control and view volume
#
#    Copyright (C) 2002  Peter Liljenberg <petli@ctrl-c.liu.se>
#
#    This program 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 2 of the License, or
#    (at your option) any later version.
#
#    This program 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 this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

import types
import re

from plwm import event, wmanager

MixerIOEventType = event.new_event_type()
MixerTimeoutEventType = event.new_event_type()

class ReximaInterface:
    dev_re = re.compile('^([a-z0-9]+)\s+(\d+)(, (\d+))?', re.MULTILINE)

    def get_cmd(self):
        return 'rexima -v'

    def set_cmd(self, dev, val1, val2):
        if val2 is None:
            return 'rexima %s %d' % (dev, val1)
        else:
            return 'rexima %s %d,%d' % (dev, val1, val2)

    def parse_output(self, data):
        groups = self.dev_re.findall(data)
        devs = []

        for dev, ls1, skip, ls2 in groups:
            if not ls1:
                continue
            left = int(ls1)
            if not ls2:
                devs.append((dev, left))
            else:
                right = int(ls2)
                devs.append((dev, (left, right)))

        return devs

# wm mixin
class Mixer:
    mixer_interface = ReximaInterface()

    def __wm_init__(self):
        self.dispatch.add_handler(MixerIOEventType, self.mixer_io_event)
        self.dispatch.add_handler(MixerTimeoutEventType,
                                  self.mixer_timout)

        self.mixer_devs = {}

        self.mixer_mute_devs = {}

        self.mixer_status_msg = None
        self.mixer_timer_event = None

        self.mixer_cmd_out = None
        self.mixer_update_settings()

    def mixer_update_settings(self):
        if self.mixer_cmd_out is not None:
            wmanager.debug('mixer',
                           'previous update command has not finished yet')
            return

        pipes = self.system(self.mixer_interface.get_cmd(), redirect = 1)

        self.mixer_cmd_out = pipes[1]
        self.mixer_cmd_data = ''
        self.mixer_cmd_event = event.FileEvent(MixerIOEventType,
                                               self.mixer_cmd_out,
                                               event.FileEvent.READ)
        self.events.add_file(self.mixer_cmd_event)


    def mixer_io_event(self, evt):
        d = self.mixer_cmd_out.read()
        if d:
            self.mixer_cmd_data = self.mixer_cmd_data + d
            return

        # command finished, update values
        self.mixer_cmd_event.cancel()
        self.mixer_cmd_event = None
        self.mixer_cmd_out.close()
        self.mixer_cmd_out = None

        devs = self.mixer_interface.parse_output(self.mixer_cmd_data)

        for dev, val in devs:
            self.mixer_devs[dev] = val


    def mixer_timout(self, evt):
        if self.mixer_status_msg is not None:
            self.mixer_status_msg.pop()
            self.mixer_status_msg = None
            self.mixer_timer_event = None


    def mixer_status_view(self, devs = None, stereo = 0, timeout = 5):
        if devs is None:
            devs = self.mixer_devs.keys()

        msg = ''
        for dev in devs:
            try:
                val = self.mixer_mute_devs[dev]
                valstr = 'MUTE:%s' % val
            except KeyError:
                try:
                    values = self.mixer_devs[dev]

                    if type(values) is types.TupleType:
                        if stereo:
                            valstr = '%s:%s' % values
                        else:
                            valstr = str(values[0])
                    else:
                        valstr = str(values)
                except KeyError:
                    valstr = 'N/A'

            msg = '%s  [%s %s]' % (msg, dev, valstr)

        if self.mixer_status_msg is None:
            self.mixer_status_msg = self.current_screen.modestatus_new(msg)
        else:
            self.mixer_status_msg.set(msg)

        if self.mixer_timer_event is not None:
            self.mixer_timer_event.cancel()

        self.mixer_timer_event = event.TimerEvent(MixerTimeoutEventType,
                                                  after = timeout)
        self.events.add_timer(self.mixer_timer_event)


    def mixer_get(self, dev, stereo = 0):
        try:
            values = self.mixer_devs[dev]

            if type(values) is types.TupleType:
                return values[0]
            else:
                return values
        except KeyError:
            return None


    def mixer_set(self, dev, val1, val2 = None):
        try:
            values = self.mixer_devs[dev]
        except KeyError:
            return

        assert val1 >= 0 and val1 <= 100
        assert val2 is None or (val2 >= 0 and val2 <= 100)

        if type(values) is types.TupleType:
            if val2 is None:
                val2 = val1

            self.mixer_devs[dev] = (val1, val2)
            cmd = self.mixer_interface.set_cmd(dev, val1, val2)
        else:
            self.mixer_devs[dev] = val1
            cmd = self.mixer_interface.set_cmd(dev, val1, None)

        self.system(cmd, fg = 1)

        try: del self.mixer_mute_devs[dev]
        except KeyError: pass


    def mixer_mute(self, dev):
        """Toggle muteness of DEV."""

        if self.mixer_mute_devs.has_key(dev):
            old = self.mixer_mute_devs[dev]
            self.mixer_set(dev, old)
        else:
            old = self.mixer_get(dev)
            self.mixer_set(dev, 0)
            self.mixer_mute_devs[dev] = old