This file is indexed.

/usr/share/cinnamon-screensaver/volumeControl.py is in cinnamon-screensaver 3.6.1-2.

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
#!/usr/bin/python3

import gi
gi.require_version('Cvc', '1.0')

from gi.repository import Gtk, Cvc, Gdk

from widgets.volumeSlider import VolumeSlider
from util import trackers, utils

class VolumeControl(Gtk.Box):
    """
    A direct child of the AudioPanel, it provides the volume slider.  This shows
    any time we are Awake, regardless of any media player connections.  We use libcvc
    to interact with the audio subsystem.
    """
    def __init__(self):
        super(VolumeControl, self).__init__(orientation=Gtk.Orientation.HORIZONTAL)

        self.output = None
        self.controller = None

        self.volume_slider = VolumeSlider()
        self.volume_slider.show_all()

        self.set_no_show_all(True)

        self.pack_start(self.volume_slider, False, False, 6)

        self.initialize_sound_controller()

    def initialize_sound_controller(self):
        self.controller = Cvc.MixerControl(name="cinnamon-screensaver")
        trackers.con_tracker_get().connect(self.controller,
                                           "state-changed",
                                           self.on_state_changed)

        trackers.con_tracker_get().connect(self.controller,
                                           "default-sink-changed",
                                           self.on_state_changed)

        self.controller.open()
        self.on_state_changed()

    def on_state_changed(self, controller=None, state=0):
        if controller and controller != self.controller:
            old = self.controller
            self.controller = controller
            del old
        if self.controller.get_state() == Cvc.MixerControlState.READY:
            new = self.controller.get_default_sink()
            if new is not None:
                if self.output and self.output != new:
                    old = self.output
                    self.output = new
                    del old
                else:
                    self.output = new
                trackers.con_tracker_get().connect(self.output,
                                                   "notify::is-muted",
                                                   self.on_volume_changed)
                trackers.con_tracker_get().connect(self.output,
                                                   "notify::volume",
                                                   self.on_volume_changed)
                trackers.con_tracker_get().connect(self.volume_slider,
                                                   "value-changed",
                                                   self.on_volume_slider_changed)
                trackers.con_tracker_get().connect(self.volume_slider,
                                                   "button-press-event",
                                                   self.on_button_press_event)
                if not utils.have_gtk_version("3.18.0"):
                    trackers.con_tracker_get().connect(self.volume_slider,
                                                       "scroll-event",
                                                       self.on_scroll_event)

                self.on_volume_changed(None, None)
                self.show()
                return

        self.hide()

    def on_volume_changed(self, output, pspec):
        vol = self.output.props.volume
        muted = self.output.get_is_muted()
        max_vol = self.controller.get_vol_max_norm()

        normalized_volume = int(min((vol / max_vol * 100), 100))

        self.update_slider(normalized_volume, muted)

    def update_slider(self, volume, muted):

        trackers.con_tracker_get().handler_block(self.volume_slider,
                                                 "value-changed",
                                                 self.on_volume_slider_changed)

        self.volume_slider.set_muted(muted)
        self.volume_slider.set_value(volume)

        trackers.con_tracker_get().handler_unblock(self.volume_slider,
                                                   "value-changed",
                                                   self.on_volume_slider_changed)

    def on_volume_slider_changed(self, range, data=None):
        value = self.volume_slider.get_value()
        max_norm = self.controller.get_vol_max_norm()

        denormalized_volume = utils.CLAMP((value / 100) * max_norm, 0, max_norm)

        trackers.con_tracker_get().handler_block(self.output,
                                                 "notify::volume",
                                                 self.on_volume_changed)
        trackers.con_tracker_get().handler_block(self.output,
                                                 "notify::is-muted",
                                                 self.on_volume_changed)
        self.output.set_volume(denormalized_volume)
        self.output.push_volume()
        self.output.change_is_muted(False)
        trackers.con_tracker_get().handler_unblock(self.output,
                                                   "notify::volume",
                                                   self.on_volume_changed)
        trackers.con_tracker_get().handler_unblock(self.output,
                                                   "notify::is-muted",
                                                   self.on_volume_changed)

    def on_button_press_event(self, widget, event):
        if event.button == 2:
            self.output.set_is_muted(not self.volume_slider.muted)

        return Gdk.EVENT_PROPAGATE

    def on_scroll_event(self, widget, event):
        success, dx, dy = event.get_scroll_deltas()
        step = self.volume_slider.get_adjustment().get_step_increment()

        if dy < 0:
            self.volume_slider.set_value(self.volume_slider.get_value() + step)
        elif dy > 0:
            self.volume_slider.set_value(self.volume_slider.get_value() - step)

        return Gdk.EVENT_STOP