github.com/kubiko/snapd@v0.0.0-20201013125620-d4f3094d9ddf/interfaces/builtin/screen_inhibit_control.go (about)

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  
     3  /*
     4   * Copyright (C) 2016 Canonical Ltd
     5   *
     6   * This program is free software: you can redistribute it and/or modify
     7   * it under the terms of the GNU General Public License version 3 as
     8   * published by the Free Software Foundation.
     9   *
    10   * This program is distributed in the hope that it will be useful,
    11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13   * GNU General Public License for more details.
    14   *
    15   * You should have received a copy of the GNU General Public License
    16   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    17   *
    18   */
    19  
    20  package builtin
    21  
    22  const screenInhibitControlSummary = `allows inhibiting the screen saver`
    23  
    24  const screenInhibitBaseDeclarationSlots = `
    25    screen-inhibit-control:
    26      allow-installation:
    27        slot-snap-type:
    28          - core
    29  `
    30  
    31  const screenInhibitControlConnectedPlugAppArmor = `
    32  # Description: Can inhibit and uninhibit screen savers in desktop sessions.
    33  #include <abstractions/dbus-session-strict>
    34  #include <abstractions/dbus-strict>
    35  
    36  # gnome-session
    37  dbus (send)
    38      bus=session
    39      path=/org/gnome/SessionManager
    40      interface=org.gnome.SessionManager
    41      member={Inhibit,Uninhibit}
    42      peer=(label=unconfined),
    43  
    44  # unity screen API
    45  dbus (send)
    46      bus=system
    47      interface="org.freedesktop.DBus.Introspectable"
    48      path="/com/canonical/Unity/Screen"
    49      member="Introspect"
    50      peer=(label=unconfined),
    51  dbus (send)
    52      bus=system
    53      interface="com.canonical.Unity.Screen"
    54      path="/com/canonical/Unity/Screen"
    55      member={keepDisplayOn,removeDisplayOnRequest}
    56      peer=(label=unconfined),
    57  
    58  # freedesktop.org ScreenSaver
    59  # compatibility rule
    60  dbus (send)
    61      bus=session
    62      path=/Screensaver
    63      interface=org.freedesktop.ScreenSaver
    64      member={Inhibit,UnInhibit,SimulateUserActivity}
    65      peer=(label=unconfined),
    66  
    67  # API rule
    68  dbus (send)
    69      bus=session
    70      path=/{,org/freedesktop/,org/gnome/}ScreenSaver
    71      interface=org.{freedesktop,gnome}.ScreenSaver
    72      member={Inhibit,UnInhibit,SimulateUserActivity}
    73      peer=(label=unconfined),
    74  
    75  # gnome, kde and cinnamon screensaver
    76  dbus (send)
    77      bus=session
    78      path=/{,ScreenSaver}
    79      interface=org.{gnome.ScreenSaver,kde.screensaver,cinnamon.ScreenSaver}
    80      member=SimulateUserActivity
    81      peer=(label=unconfined),
    82  `
    83  
    84  func init() {
    85  	registerIface(&commonInterface{
    86  		name:                  "screen-inhibit-control",
    87  		summary:               screenInhibitControlSummary,
    88  		implicitOnClassic:     true,
    89  		baseDeclarationSlots:  screenInhibitBaseDeclarationSlots,
    90  		connectedPlugAppArmor: screenInhibitControlConnectedPlugAppArmor,
    91  	})
    92  }