/usr/lib/budgie-desktop/plugins/budgie-wmover/budgie-wmover.py is in budgie-window-mover-applet 0.4.4-0ubuntu1.
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 | import gi.repository
gi.require_version('Budgie', '1.0')
from gi.repository import Budgie, GObject, Gtk
import subprocess
import os
import wmovertools as wmt
"""
Budgie WindowMover
Author: Jacob Vlijm
Copyright © 2017-2018 Ubuntu Budgie Developers
Website=https://ubuntubudgie.org
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 3 of the License, or 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, see <http://www.gnu.org/licenses/>.
"""
panelrunner = os.path.join(wmt.appletpath, "wmover_panelrunner")
backgrounder = os.path.join(wmt.appletpath, "wmover_run")
wmover_path = wmt.settings_path
wmover_ismuted = wmt.wmover_ismuted
user = wmt.user
try:
os.makedirs(wmover_path)
except FileExistsError:
pass
def check_runs(pname):
# get the pid of a proc
try:
pid = subprocess.check_output([
"pgrep", "-f", "-u", user, pname,
]).decode("utf-8")
except subprocess.CalledProcessError:
return None
else:
return pid.strip()
message = """
The following shortcuts are
automatically set:
- Ctrl + Alt + w
(call the window mover)
- Ctrl + Alt + s
(call the desktop mover)
Drag the window to the
bottom of your screen, and the
window mover appears
Applet runs without a panel
icon
"""
class WPrviewsSettings(Gtk.Grid):
def __init__(self, setting):
super().__init__()
self.setting = setting
ismuted = os.path.exists(wmt.wmover_ismuted)
# grid & layout
explanation = Gtk.Label(message)
self.attach(explanation, 0, 1, 1, 1)
self.toggle = Gtk.CheckButton.new_with_label(" Run Window Mover")
self.toggle.set_active(not ismuted)
self.toggle.connect("toggled", self.switch)
self.attach(self.toggle, 0, 0, 1, 1)
self.show_all()
def switch(self, button, *args):
# toggle ui & manage trigger file (noticed by panelrunner)
pids = check_runs(backgrounder)
if pids:
open(wmover_ismuted, "wt").write("")
else:
subprocess.Popen(panelrunner)
try:
os.remove(wmover_ismuted)
except FileNotFoundError:
pass
class WMover(GObject.GObject, Budgie.Plugin):
""" This is simply an entry point into your Budgie Applet implementation.
Note you must always override Object, and implement Plugin.
"""
# Good manners, make sure we have unique name in GObject type system
__gtype_name__ = "WMover"
def __init__(self):
""" Initialisation is important.
"""
GObject.Object.__init__(self)
def do_get_panel_widget(self, uuid):
""" This is where the real fun happens. Return a new Budgie.Applet
instance with the given UUID. The UUID is determined by the
BudgiePanelManager, and is used for lifetime tracking.
"""
return WMoverApplet(uuid)
class WMoverApplet(Budgie.Applet):
""" Budgie.Applet is in fact a Gtk.Bin """
manager = None
def __init__(self, uuid):
Budgie.Applet.__init__(self)
self.uuid = uuid
ismuted = os.path.exists(wmt.wmover_ismuted)
self.box = Gtk.EventBox()
if not ismuted:
self.initiate()
def initiate(self):
pass
pids = check_runs(backgrounder)
if not pids:
subprocess.Popen(panelrunner)
def do_get_settings_ui(self):
"""Return the applet settings with given uuid"""
return WPrviewsSettings(self.get_applet_settings(self.uuid))
def do_supports_settings(self):
"""Return True if support setting through Budgie Setting,
False otherwise.
"""
return True
|