forked from graysky2/xscreensaver-aerial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vid
executable file
·124 lines (109 loc) · 4.5 KB
/
vid
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
#!/usr/bin/python2
# -*- coding: utf-8 -*-
# PRIME Indicator - indicator applet for NVIDIA Optimus laptops
# Copyright (C) 2013 Alfred Neumayer
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from time import sleep
import subprocess
import sys
import commands
import os
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GLib
# try which gir is available prioritising Gtk3
gi.require_version('AyatanaAppIndicator3', '0.1')
try:
from gi.repository import AyatanaAppIndicator3 as appindicator
except ImportError:
try:
from gi.repository import AppIndicator3 as appindicator
except ImportError:
from gi.repository import appindicator
class VidWall:
def __init__(self):
self.ind = appindicator.Indicator.new('Video Wallpaper',
'indicator-messages',
appindicator.IndicatorCategory.OTHER)
self.ind.set_status(appindicator.IndicatorStatus.ACTIVE)
self.ind.set_attention_icon('indicator-messages-new')
self.ind.set_icon_theme_path('/usr/lib/atvvid/')
self.isIntegrated = self.checkIntegrated()
self.ind.set_icon('wallvid')
self.menu_setup()
self.ind.set_menu(self.menu)
def menu_setup(self):
self.menu = Gtk.Menu()
self.info_item = Gtk.MenuItem(self.rendererString())
self.info_item.set_sensitive(False)
self.info_item.show()
self.seperator_item = Gtk.SeparatorMenuItem()
self.seperator_item.show()
self.switch_item = Gtk.MenuItem('Next Video')
self.switch_item.connect('activate', self.switchVideo)
self.switch_item.show()
self.seperator2_item = Gtk.SeparatorMenuItem()
self.seperator2_item.show()
self.settings_item = Gtk.MenuItem('Start/Stop Wallpaper')
self.settings_item.connect('activate', self.opensettings)
self.settings_item.show()
self.settings_item2 = Gtk.MenuItem('Play/Pause Wallpaper')
self.settings_item2.connect('activate', self.opensettings2)
self.settings_item2.show()
self.menu.append(self.info_item)
self.menu.append(self.seperator_item)
self.menu.append(self.switch_item)
self.menu.append(self.seperator2_item)
self.menu.append(self.settings_item2)
self.menu.append(self.settings_item)
def opensettings(self, dude):
self.isIntegrated = self.checkIntegrated()
if self.isIntegrated:
os.system("ps aux | egrep '[/]usr/bin/atv4wall'| awk '{print $2}' | xargs kill"
)
else:
p = subprocess.Popen(['setsid', 'atv4wall'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
print 'finished'
sleep(1)
self.info_item.get_child().set_text(self.rendererString())
def opensettings2(self, dude):
os.system("echo 'cycle pause' | socat - /tmp/mpvsocket")
sleep(1)
self.info_item.get_child().set_text(self.rendererString())
def checkIntegrated(self):
(stat, out) = \
commands.getstatusoutput("ps aux | egrep '[/]usr/bin/atv4wall' | awk '{print $2}'"
)
return any(char.isdigit() for char in out)
def ignore(*args):
return Gtk.TRUE
def rendererString(self):
(stat, out) = \
commands.getstatusoutput("ps aux | grep '[x]winwrap ' | awk '{ print $NF }'"
)
out = out.replace('/opt/ATV4/', '')
return "Video: "+out
def switchVideo(self, dude):
os.system('/usr/bin/killall mpv')
sleep(1)
self.info_item.get_child().set_text(self.rendererString())
def main(self):
Gtk.main()
if __name__ == '__main__':
indicator = VidWall()
indicator.main()