10-20-2018, 10:08 AM
I'll have a try at these
Just let me know.
![[Image: X5qGkCg.png]](https://imgur.com/X5qGkCg.png)
(10-20-2018, 03:14 AM)Jerry link Wrote:#1 - Top logo also links to main website.
#2 - Add button somewhere logical that links to internal Help Manual. /usr/share/doc/litemanual/index.html
#3 - Could you please add our logo as a taskbar icon, points to in Series 4.x+: /usr/share/icons/Papirus/48x48/apps/liteicon.png (or whatever size suits)
#4 - Rename app to llabout.py
#5- pull and display the current LL version from /etc/llver file.Hope you're enjoying the challenges.
![[Image: llabout1.png]](https://preview.ibb.co/hKWPVf/llabout1.png)
#!/usr/bin/env python
# code by bitsnpcs
from Tkinter import *
import webbrowser
url1 = 'https://mityer.khdlhfjijfrupr.tk/development.html#team'
url2 = 'https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html'
url3 = 'https://mityer.khdlhfjijfrupr.tk/'
# open browser and display url at line 7 thru 9
def OpenUrl1():
webbrowser.open(url1)
def OpenUrl2():
webbrowser.open(url2)
def OpenUrl3():
webbrowser.open(url3)
def close_window():
window.destroy()
# Make window
window = Tk()
window.title("About Linux Lite")
window.geometry("242x242")
window.resizable(0,0)
# adding a logo
photo=PhotoImage(file="logo.png")
l1 = Button(image=photo,width=160, height=59, command=OpenUrl3)
l1.grid(row=4, column=0)
l1.place(x=36.3, y=12)
l1 = Label(window, text=" ")
l1.grid(row=5, column=0, sticky=W)
l1 = Label(window, text=" ")
l1.grid(row=6, column=0, sticky=W)
l1 = Label(window, text=" ")
l1.grid(row=7, column=0, sticky=W)
l1 = Label(window, text=" ")
l1.grid(row=8, column=0, sticky=W)
# adding a frame for ll website button
GUIFrame1=Frame(window)
GUIFrame1.grid(row=11, column=0)
#adding a frame for last row of buttons
GUIFrame2=Frame(window)
GUIFrame2.grid(row=13, column=0)
# define title, nym, year
l2 = Label(window, text=u"\u00a9Copyright 2012-2018 Jerry Bezencon", fg="grey", font="none 8")
l2.grid(row=15, column=0)
l3 = Label(window, text=" ")
l3.grid(row=0, column=0, sticky=W)
l3 = Label(window, text=" ")
l3.grid(row=10, column=0, sticky=W)
l3 = Label(window, text=" ")
l3.grid(row=12, column=0, sticky=W)
l3 = Label(window, text=" ")
l3.grid(row=14, column=0, sticky=W)
l4 = Label(window, text="Current Version: 5.0")
l4.grid(row=9, column=0)
# ll website button
l5 = Label(GUIFrame1, text=" ")
l5.grid(row=11, column=0, sticky=W)
Button(GUIFrame1, text="Visit Linux Lite website", width=16, command=OpenUrl3).grid(row=11, column=0)
# last row of buttons
l6 = Label(GUIFrame2, text=" ")
l6.grid(row=13, column=0)
Button(GUIFrame2, text="Credits", width=6, command=OpenUrl1).grid(row=13, column=1)
Button(GUIFrame2, text="License", width=6, command=OpenUrl2).grid(row=13, column=2)
Button(GUIFrame2, text="Close", width=6, command=window.destroy).grid(row=13, column=3)
window.mainloop()(10-20-2018, 03:14 AM)Jerry link Wrote:#1 - Top logo also links to main website.
#2 - Add button somewhere logical that links to internal Help Manual. /usr/share/doc/litemanual/index.html
#3 - Could you please add our logo as a taskbar icon, points to in Series 4.x+: /usr/share/icons/Papirus/48x48/apps/liteicon.png (or whatever size suits)#4 - Rename app to llabout.py
#5 - pull and display the current LL version from /etc/llver file.
Hope you're enjoying the challenges.
but likely only in this type of way rather than a tidy more advanced way.![[Image: llabout1.png]](https://preview.ibb.co/eEDuwL/llabout1.png)
![[Image: llabout2.png]](https://preview.ibb.co/knGmAf/llabout2.png)
![[Image: llabout3.png]](https://preview.ibb.co/gsJYqf/llabout3.png)
#!/usr/bin/env python
# code by bitsnpcs
from Tkinter import *
import webbrowser
url1 = 'https://mityer.khdlhfjijfrupr.tk/development.html#team'
url2 = 'https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html'
url3 = 'https://mityer.khdlhfjijfrupr.tk/'
url4 = 'https://mityer.khdlhfjijfrupr.tk/manual/'
url5 = 'https://mityer.khdlhfjijfrupr.tk/forums/index.php'
url6 = 'https://mityer.khdlhfjijfrupr.tk/donate.html'
url7 = 'https://mityer.khdlhfjijfrupr.tk/shop.html'
url8 = '/usr/share/doc/litemanual/index.html'
# open browser and display url at line 7 thru 13
def OpenUrl1():
webbrowser.open(url1)
def OpenUrl2():
webbrowser.open(url2)
def OpenUrl3():
webbrowser.open(url3)
def OpenUrl4():
webbrowser.open(url4)
def OpenUrl5():
webbrowser.open(url5)
def OpenUrl6():
webbrowser.open(url6)
def OpenUrl7():
webbrowser.open(url7)
def close_window():
window.destroy()
def OpenUrl8():
webbrowser.open(url8)
# Make window
window = Tk()
window.title("About Linux Lite")
window.geometry("242x242")
window.resizable(0,0)
# adding a menubar
menubar = Menu(window)
window.config(menu=menubar)
helpmenu = Menu(menubar)
menubar.add_cascade(label='Help', menu=helpmenu)
supportmenu = Menu(menubar)
menubar.add_cascade(label='Support', menu=supportmenu)
def doPrint( ): print 'doPrint'
def doSave( ): print 'doSave'
helpmenu.add_command(label='Help Manual (local)', command=OpenUrl8)
helpmenu.add_command(label='Help Manual (online)', command=OpenUrl4)
helpmenu.add_command(label='Ask Community', command=OpenUrl5)
helpmenu = Menu(menubar)
def doPrint( ): print 'doPrint'
def doSave( ): print 'doSave'
supportmenu.add_command(label='Donate', command=OpenUrl6)
supportmenu.add_command(label='Shop', command=OpenUrl7)
supportmenu = Menu(menubar)
# uncomment below to add separator in menu, place code where seperator is wanted
# filemenu.add_separator( )
# adding a logo
photo=PhotoImage(file="logo.png")
l1 = Button(image=photo,width=160, height=59, command=OpenUrl3)
l1.grid(row=4, column=0)
l1.place(x=36.3, y=12)
l1 = Label(window, text=" ")
l1.grid(row=5, column=0, sticky=W)
l1 = Label(window, text=" ")
l1.grid(row=6, column=0, sticky=W)
l1 = Label(window, text=" ")
l1.grid(row=7, column=0, sticky=W)
l1 = Label(window, text=" ")
l1.grid(row=8, column=0, sticky=W)
# adding a frame for ll website button
GUIFrame1=Frame(window)
GUIFrame1.grid(row=11, column=0)
#adding a frame for last row of buttons
GUIFrame2=Frame(window)
GUIFrame2.grid(row=13, column=0)
# define title, nym, year
l2 = Label(window, text=u"\u00a9Copyright 2012-2018 Jerry Bezencon", fg="grey", font="none 8")
l2.grid(row=15, column=0)
l3 = Label(window, text=" ")
l3.grid(row=0, column=0, sticky=W)
l3 = Label(window, text=" ")
l3.grid(row=10, column=0, sticky=W)
l3 = Label(window, text=" ")
l3.grid(row=12, column=0, sticky=W)
l3 = Label(window, text=" ")
l3.grid(row=14, column=0, sticky=W)
l4 = Label(window, text="Current Version: 5.0")
l4.grid(row=9, column=0)
# ll website button
l5 = Label(GUIFrame1, text=" ")
l5.grid(row=11, column=0, sticky=W)
Button(GUIFrame1, text="Visit Linux Lite website", width=16, command=OpenUrl3).grid(row=11, column=0)
# last row of buttons
l6 = Label(GUIFrame2, text=" ")
l6.grid(row=13, column=0)
Button(GUIFrame2, text="Credits", width=6, command=OpenUrl1).grid(row=13, column=1)
Button(GUIFrame2, text="License", width=6, command=OpenUrl2).grid(row=13, column=2)
Button(GUIFrame2, text="Close", width=6, command=window.destroy).grid(row=13, column=3)
window.mainloop()#!/usr/bin/env python# code by bitsnpcs
from Tkinter import *
import webbrowser
url1 = 'https://mityer.khdlhfjijfrupr.tk/development.html#team'
url2 = 'https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html'
url3 = 'https://mityer.khdlhfjijfrupr.tk/'
url4 = 'https://mityer.khdlhfjijfrupr.tk/manual/'
url5 = 'https://mityer.khdlhfjijfrupr.tk/forums/index.php'
url6 = 'https://mityer.khdlhfjijfrupr.tk/donate.html'
url7 = 'https://mityer.khdlhfjijfrupr.tk/shop.html'
url8 = '/usr/share/doc/litemanual/index.html'
# open browser and display url at line 7 thru 13
def OpenUrl1():
webbrowser.open(url1)
def OpenUrl2():
webbrowser.open(url2)
def OpenUrl3():
webbrowser.open(url3)
def OpenUrl4():
webbrowser.open(url4)
def OpenUrl5():
webbrowser.open(url5)
def OpenUrl6():
webbrowser.open(url6)
def OpenUrl7():
webbrowser.open(url7)
def close_window():
window.destroy()
def OpenUrl8():
webbrowser.open(url8)
# Make window
window = Tk()
window.title("About Linux Lite")
window.geometry("242x242")
window.resizable(0,0)
# adding a menubar
menubar = Menu(window)
window.config(menu=menubar)
helpmenu = Menu(menubar)
menubar.add_cascade(label='Help', menu=helpmenu)
supportmenu = Menu(menubar)
menubar.add_cascade(label='Support', menu=supportmenu)
def doHelp( ): print 'doHelp'
helpmenu.add_command(label='Help Manual (local)', command=OpenUrl8)
helpmenu.add_command(label='Help Manual (online)', command=OpenUrl4)
helpmenu.add_command(label='Ask Community', command=OpenUrl5)
helpmenu = Menu(menubar)
def doSupport( ): print 'doSupport'
supportmenu.add_command(label='Donate', command=OpenUrl6)
supportmenu.add_command(label='Shop', command=OpenUrl7)
supportmenu = Menu(menubar)
# uncomment below to add separator in menu, place code where seperator is wanted
# filemenu.add_separator( )
# adding a logo
photo=PhotoImage(file="logo.png")
l1 = Button(image=photo,width=160, height=59, command=OpenUrl3)
l1.grid(row=4, column=0)
l1.place(x=36.3, y=12)
l1 = Label(window, text=" ")
l1.grid(row=5, column=0, sticky=W)
l1 = Label(window, text=" ")
l1.grid(row=6, column=0, sticky=W)
l1 = Label(window, text=" ")
l1.grid(row=7, column=0, sticky=W)
l1 = Label(window, text=" ")
l1.grid(row=8, column=0, sticky=W)
# adding a frame for ll website button
GUIFrame1=Frame(window)
GUIFrame1.grid(row=11, column=0)
#adding a frame for last row of buttons
GUIFrame2=Frame(window)
GUIFrame2.grid(row=13, column=0)
# define title, nym, year
l2 = Label(window, text=u"\u00a9Copyright 2012-2018 Jerry Bezencon", fg="grey", font="none 8")
l2.grid(row=15, column=0)
l3 = Label(window, text=" ")
l3.grid(row=0, column=0, sticky=W)
l3 = Label(window, text=" ")
l3.grid(row=10, column=0, sticky=W)
l3 = Label(window, text=" ")
l3.grid(row=12, column=0, sticky=W)
l3 = Label(window, text=" ")
l3.grid(row=14, column=0, sticky=W)
l4 = Label(window, text="Current Version: 5.0")
l4.grid(row=9, column=0)
# ll website button
l5 = Label(GUIFrame1, text=" ")
l5.grid(row=11, column=0, sticky=W)
Button(GUIFrame1, text="Visit Linux Lite website", width=16, command=OpenUrl3).grid(row=11, column=0)
# last row of buttons
l6 = Label(GUIFrame2, text=" ")
l6.grid(row=13, column=0)
Button(GUIFrame2, text="Credits", width=6, command=OpenUrl1).grid(row=13, column=1)
Button(GUIFrame2, text="License", width=6, command=OpenUrl2).grid(row=13, column=2)
Button(GUIFrame2, text="Close", width=6, command=window.destroy).grid(row=13, column=3)
window.mainloop()![[Image: Screenshot-2018-10-20-21-21-58.png]](https://preview.ibb.co/jsDdqf/Screenshot-2018-10-20-21-21-58.png)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Distributed under terms of the GPL2 license.
import os
import sys
import urllib.request
import webbrowser
import subprocess
import fcntl
import tkinter
from configparser import ConfigParser
import gi
gi.require_version('WebKit', '3.0')
from gi.repository import WebKit as webkit
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk as gtk
from gi.repository.GdkPixbuf import Pixbuf
from os import stat as os_stat
import datetime
import apt
def run_once():
global fh
fh = open(os.path.realpath(__file__), 'r')
try:
fcntl.flock(fh, fcntl.LOCK_EX | fcntl.LOCK_NB)
except:
run_once_dialog()
def run_once_dialog():
window = gtk.Window()
dialog = gtk.MessageDialog(None, 0, gtk.MessageType.WARNING,
gtk.ButtonsType.OK, appname + ' - Error')
dialog.set_default_size(400, 250)
dialog.set_transient_for(window)
dialog.format_secondary_text("There is another instance of " + appname +
" already running.")
response = dialog.run()
if response == gtk.ResponseType.OK:
dialog.destroy()
sys.exit()
dialog.destroy()
def execute(command, ret=True):
if ret is True:
p = os.popen(command)
return p.readline()
else:
p = subprocess.Popen(command,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
return p.stdout
def functions(view, frame, req, data=None):
uri = req.get_uri()
lllink, path = uri.split('://', 1)
path = path.replace("%20", " ")
if lllink == "file":
return False
elif lllink == "about":
about = gtk.AboutDialog()
about.set_program_name(appname)
about.set_version(appver)
about.set_license(
'''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. ''')
about.set_authors([
"Johnathan 'ShaggyTwoDope'" +
" Jenkins\n<[email protected]>\n",
"Jerry Bezencon\n<[email protected]>\n",
"Milos Pavlovic\n<[email protected]>\n",
"Brian 'DarthLukan' Tomlinson\n<[email protected]>\n",
"Josh Erickson\n<[email protected]>"
])
about.set_comments("Designed for Linux Lite")
about.set_website("http://mityer.khdlhfjijfrupr.tk")
about.set_logo(Pixbuf.new_from_file(app_icon))
about.set_transient_for(window)
about.run()
about.destroy()
elif lllink == "admin":
subprocess.Popen(path, shell=True, executable='/bin/bash')
elif lllink == "script":
execute("{0}/scripts/{1}".format(app_dir, path))
elif lllink == "help":
webbrowser.open('file:///usr/share/doc/litemanual/index.html')
elif lllink == "forum":
webbrowser.open('http://mityer.khdlhfjijfrupr.tk/forums/')
elif lllink == "website":
webbrowser.open('http://mityer.khdlhfjijfrupr.tk/')
elif lllink == "facebook":
webbrowser.open('https://www.facebook.com/linuxliteos')
elif lllink == "twitter":
webbrowser.open('http://www.twitter.com/linuxlite/')
elif lllink == "google":
webbrowser.open('https://plus.google.com/+linuxliteos/')
elif lllink == "linkedin":
webbrowser.open('http://www.linkedin.com/in/jerrybezencon')
elif lllink == "screenshot":
os.system("/bin/bash -c 'scrot -u $HOME/liteccshot.png'")
subprocess.Popen(['/bin/bash', '-c',
'/usr/share/litecc/scripts/screenshot'])
elif lllink == "report":
subprocess.Popen(['/bin/bash', '-c', 'gksudo /usr/scripts/systemreport'
])
elif lllink == "update":
subprocess.Popen(['/bin/bash', '-c', 'gksudo /usr/scripts/updates-gui'
])
elif lllink == "refresh":
reload()
return True
def reload():
info = ""
get_info(info)
frontend = frontend_fill()
browser.load_html_string(frontend, "file://{0}/frontend/".format(app_dir))
return True
def connected(host='http://google.com'):
try:
urllib.request.urlopen(host)
return True
except:
return False
def mem_info():
f = open('/proc/meminfo')
for line in f:
if line.startswith('MemTotal:'):
mem_total = (int(line.split()[1]) * 1024.0)
elif line.startswith('Active:'):
mem_active = (int(line.split()[1]) * 1024.0)
elif line.startswith('Inactive:'):
mem_inactive = (int(line.split()[1]) * 1024.0)
elif line.startswith('MemFree:'):
mem_free = (int(line.split()[1]) * 1024.0)
elif line.startswith('Cached:'):
mem_cached = (int(line.split()[1]) * 1024.0)
elif line.startswith('Buffers:'):
mem_buffers = (int(line.split()[1]) * 1024.0)
f.close()
return (mem_total, mem_active, mem_inactive, mem_free, mem_cached,
mem_buffers)
def apt_info():
cache = apt.Cache()
cache.close()
cache.open()
upgrades = 0
cache.upgrade(dist_upgrade=False)
changes = cache.get_changes()
if changes:
counter = [change.name for change in changes]
upgrades = (len(counter))
return upgrades
def get_info(info):
try:
if info == "os":
try:
osin = open('/etc/llver', 'r').read().split('\\n')[0]
except:
infocmd = "lsb_release -d | sed 's/Description:[\t]//g'"
osin = execute(infocmd).split('\\n')[0]
return osin
if info == "desk":
desk_ses = os.environ.get("XDG_SESSION_DESKTOP")
if desk_ses is None:
desk_ses = os.environ.get("XDG_CURRENT_DESKTOP")
if "XFCE" in desk_ses or desk_ses.startswith("xfce"):
xfcev = "xfce4-session -V | grep xfce4-session"
return execute(xfcev).split('(')[1].split(')')[0].split(',')[0]
elif "ubuntu" in desk_ses:
return "Unity"
else:
return desk_ses
if desk_ses is None:
desk_ses = "Desktop Unknown"
return desk_ses
if info == "arc":
return os.uname()[4]
if info == "host":
return os.uname()[1]
if info == "kernel":
return "{0} {1}".format(os.uname()[0], os.uname()[2])
if info == "updates":
pkgcache = '/var/cache/apt/pkgcache.bin'
aptcount = apt_info()
if aptcount == 0:
count = ''
elif aptcount == 1:
count = ' (<font style=\"color: red;\">{0}</font> update available)'.format(
aptcount)
else:
count = ' (<font style=\"color: red;\">{0}</font> updates available)'.format(
aptcount)
if os.path.isfile(pkgcache):
mtime = os_stat(pkgcache).st_mtime
modtime = datetime.datetime.fromtimestamp(mtime).strftime(
'%Y-%m-%d %H:%M')
modday = datetime.datetime.fromtimestamp(mtime).strftime(
'%Y-%m-%d')
today = datetime.datetime.today().strftime('%Y-%m-%d')
if modday == today:
updaters = '''<section class="gradient">Last checked on <font style=\"color: green;\">{0}</font>{1} <button style=\"padding-bottom:0px;padding-left:50pxi\" onclick=\"location.href=('update://')\">Run Updates</button></section>'''.format(
modtime, count)
else:
updaters = '''<section class="gradient">Last checked on <font style=\"color: red;\">{0}</font>{1} <button style=\"padding-bottom:0px;padding-left:50pxi\" onclick=\"location.href=('update://')\">Run Updates</button></section>'''.format(
modtime, count)
else:
updaters = '''<section class="gradient">No Update History <button style=\"padding-bottom:0px;padding-left:50pxi\" onclick=\"location.href=('update://')\">Run Updates</button></section>'''
return updaters
if info == "processor":
proc = execute("grep 'model name' /proc/cpuinfo").split(':')[1]
return proc
if info == "mem":
total, active, inactive, free, cached, buffers, = mem_info()
pie = ((int(total) - int(free)) - (int(buffers) + int(cached)))
mem_usage = float(pie) * 100 / float(total)
ramdis = "%14dMB (Used: %8dMB %7.2f%%)" % (
int(total) / 1048576, pie / 1024 / 1024, mem_usage)
return ramdis
if info == "gfx":
return execute("lspci | grep VGA").split('controller:')[1].split(
'(rev')[0].split(',')[0]
if info == "audio":
audio = execute("lspci | grep 'Audio device:'")
if len(audio) == 0:
return execute("lspci | grep audio").split('controller:')[
1].split('(rev')[0].split(',')[0]
else:
return execute("lspci | grep Audio").split('device:')[1].split(
'(rev')[0].split(',')[0]
if info == "disk":
p1 = subprocess.Popen(
['df', '-Tlh', '--total', '-t', 'ext4', '-t', 'ext3', '-t',
'ext2', '-t', 'reiserfs', '-t'
'jfs', '-t', 'ntfs', '-t', 'fat32', '-t', 'btrfs', '-t',
'fuseblk', '-t', 'xfs'],
stdout=subprocess.PIPE).communicate()[0].decode("Utf-8")
total = p1.splitlines()[-1]
used = total.split()[3].replace(total.split()[3][-1:],
" " + total.split()[3][-1:] + "B")
size = total.split()[2].replace(total.split()[2][-1:],
" " + total.split()[2][-1:] + "B")
disk = "{0} (Used: {1})".format(size, used)
return disk
if info == "netstatus":
if connected():
status = '<font color=green>Active</font>'
else:
status = '<font color=red>Not connected</font>'
return status
if info == "netip":
ip = execute("hostname -I").split(' ')
if len(ip) > 1:
ip = ip[0]
elif ip == "":
ip = 'None'
else:
ip = 'None'
return ip
if info == "gateway":
gateway = execute("route -n | grep 'UG[ \t]' | awk '{print $2}'")
if len(gateway) == 0:
gateway = 'None'
return gateway
except (OSError, TypeError, Exception) as e:
print(e)
return " "
def which(program):
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
def get_modules(section):
window = gtk.Window()
try:
mod_dir = os.listdir("{0}/modules/{1}/".format(app_dir, section))
mod_dir.sort()
except Exception:
dialog = gtk.MessageDialog(None, 0, gtk.MessageType.WARNING,
gtk.ButtonsType.OK,
'Error Importing Module Data')
dialog.set_default_size(400, 250)
dialog.format_secondary_text("No modules could be found." +
" Please reinstall " + appname)
dialog.set_transient_for(window)
response = dialog.run()
if response == gtk.ResponseType.OK:
dialog.destroy()
sys.exit()
dialog.destroy()
if isinstance(mod_dir, list) and len(mod_dir) < 1:
return "<p>\"no modules found!\"</p>"
else:
parser = ConfigParser()
admin = ""
mod_dir.sort()
for i in mod_dir:
parser.read("{0}/modules/{1}/{2}".format(app_dir, section, i))
command = parser.get('module', 'command')
chk = command.split(' ')[0]
if chk == "gksudo":
chk = command.split(' ')[1]
elif chk == "gksu":
chk = command.split(' ')[1]
checking = which(chk)
if checking is not None:
ico = parser.get('module', 'ico')
ico = "{0}/frontend/icons/modules/{1}".format(app_dir, ico)
name = parser.get('module', 'name')
desc = parser.get('module', 'desc')
command = command.replace("'", ''' \\' ''')
admin += '''<div class="launcher" onclick="location.href='admin://{0}'" >
<img src="{1}" onerror='this.src = "/usr/share/litecc/frontend/icons/modules/notfound.png"'/>
<h3>{2}</h3>
<span>{3}</span>
</div>'''.format(command, ico, name, desc)
return admin
def frontend_fill():
filee = open("{0}/frontend/default.html".format(app_dir), "r")
page = filee.read()
for i in ['os', 'desk', 'arc', 'processor', 'mem', 'gfx', 'audio', 'disk',
'kernel', 'updates', 'host', 'netstatus', 'netip', 'gateway']:
page = page.replace("{%s}" % i, str(get_info(i)))
sections = ['software', 'system', 'desktop', 'hardware', 'networking']
sections.sort()
for i in sections:
page = page.replace("{%s_list}" % i, get_modules(i))
filee.close()
return page
def main():
global browser
global window
frontend = frontend_fill()
window = gtk.Window()
window.connect('destroy', gtk.main_quit)
window.set_title(appname)
window.set_icon(Pixbuf.new_from_file(app_icon))
rootsize = tkinter.Tk()
if rootsize.winfo_screenheight() > 700:
window.set_resizable(False)
window.set_size_request(880, 660)
else:
window.set_resizable(True)
window.set_size_request(880, 500)
window.set_position(gtk.WindowPosition.CENTER),
browser = webkit.WebView()
swindow = gtk.ScrolledWindow()
window.add(swindow)
swindow.add(browser)
window.show_all()
browser.connect("navigation-requested", functions)
browser.load_html_string(frontend, "file://{0}/frontend/".format(app_dir))
settings = browser.get_settings()
settings.set_property('enable-default-context-menu', False)
browser.set_settings(settings)
gtk.main()
if __name__ == '__main__':
appname = 'Linux Lite Control Center'
appver = '1.0-0310'
app_dir = '/usr/share/litecc'
app_icon = "/usr/share/pixmaps/lite-controlcenter.png"
fh = 0
try:
run_once()
main()
except (Exception, AttributeError) as e:
print("Exiting due to error: {0}".format(e))
sys.exit(1)![[Image: X5qGkCg.png]](https://imgur.com/X5qGkCg.png)
![[Image: X5qGkCg.png]](https://imgur.com/X5qGkCg.png)
(10-21-2018, 02:27 AM)Jerry link Wrote:Have a look in this file, there are some great clues there on how to pull info from LL.
Code:#!/usr/bin/env python3 # -*- coding: utf-8 -*- # vim:fenc=utf-8 # # Distributed under terms of the GPL2 license. import os import sys import urllib.request import webbrowser import subprocess import fcntl import tkinter from configparser import ConfigParser import gi gi.require_version('WebKit', '3.0') from gi.repository import WebKit as webkit gi.require_version('Gtk', '3.0') from gi.repository import Gtk as gtk from gi.repository.GdkPixbuf import Pixbuf from os import stat as os_stat import datetime import apt def run_once(): global fh fh = open(os.path.realpath(__file__), 'r') try: fcntl.flock(fh, fcntl.LOCK_EX | fcntl.LOCK_NB) except: run_once_dialog() def run_once_dialog(): window = gtk.Window() dialog = gtk.MessageDialog(None, 0, gtk.MessageType.WARNING, gtk.ButtonsType.OK, appname + ' - Error') dialog.set_default_size(400, 250) dialog.set_transient_for(window) dialog.format_secondary_text("There is another instance of " + appname + " already running.") response = dialog.run() if response == gtk.ResponseType.OK: dialog.destroy() sys.exit() dialog.destroy() def execute(command, ret=True): if ret is True: p = os.popen(command) return p.readline() else: p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) return p.stdout def functions(view, frame, req, data=None): uri = req.get_uri() lllink, path = uri.split('://', 1) path = path.replace("%20", " ") if lllink == "file": return False elif lllink == "about": about = gtk.AboutDialog() about.set_program_name(appname) about.set_version(appver) about.set_license( '''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. ''') about.set_authors([ "Johnathan 'ShaggyTwoDope'" + " Jenkins\n<[email protected]>\n", "Jerry Bezencon\n<[email protected]>\n", "Milos Pavlovic\n<[email protected]>\n", "Brian 'DarthLukan' Tomlinson\n<[email protected]>\n", "Josh Erickson\n<[email protected]>" ]) about.set_comments("Designed for Linux Lite") about.set_website("http://mityer.khdlhfjijfrupr.tk") about.set_logo(Pixbuf.new_from_file(app_icon)) about.set_transient_for(window) about.run() about.destroy() elif lllink == "admin": subprocess.Popen(path, shell=True, executable='/bin/bash') elif lllink == "script": execute("{0}/scripts/{1}".format(app_dir, path)) elif lllink == "help": webbrowser.open('file:///usr/share/doc/litemanual/index.html') elif lllink == "forum": webbrowser.open('http://mityer.khdlhfjijfrupr.tk/forums/') elif lllink == "website": webbrowser.open('http://mityer.khdlhfjijfrupr.tk/') elif lllink == "facebook": webbrowser.open('https://www.facebook.com/linuxliteos') elif lllink == "twitter": webbrowser.open('http://www.twitter.com/linuxlite/') elif lllink == "google": webbrowser.open('https://plus.google.com/+linuxliteos/') elif lllink == "linkedin": webbrowser.open('http://www.linkedin.com/in/jerrybezencon') elif lllink == "screenshot": os.system("/bin/bash -c 'scrot -u $HOME/liteccshot.png'") subprocess.Popen(['/bin/bash', '-c', '/usr/share/litecc/scripts/screenshot']) elif lllink == "report": subprocess.Popen(['/bin/bash', '-c', 'gksudo /usr/scripts/systemreport' ]) elif lllink == "update": subprocess.Popen(['/bin/bash', '-c', 'gksudo /usr/scripts/updates-gui' ]) elif lllink == "refresh": reload() return True def reload(): info = "" get_info(info) frontend = frontend_fill() browser.load_html_string(frontend, "file://{0}/frontend/".format(app_dir)) return True def connected(host='http://google.com'): try: urllib.request.urlopen(host) return True except: return False def mem_info(): f = open('/proc/meminfo') for line in f: if line.startswith('MemTotal:'): mem_total = (int(line.split()[1]) * 1024.0) elif line.startswith('Active:'): mem_active = (int(line.split()[1]) * 1024.0) elif line.startswith('Inactive:'): mem_inactive = (int(line.split()[1]) * 1024.0) elif line.startswith('MemFree:'): mem_free = (int(line.split()[1]) * 1024.0) elif line.startswith('Cached:'): mem_cached = (int(line.split()[1]) * 1024.0) elif line.startswith('Buffers:'): mem_buffers = (int(line.split()[1]) * 1024.0) f.close() return (mem_total, mem_active, mem_inactive, mem_free, mem_cached, mem_buffers) def apt_info(): cache = apt.Cache() cache.close() cache.open() upgrades = 0 cache.upgrade(dist_upgrade=False) changes = cache.get_changes() if changes: counter = [change.name for change in changes] upgrades = (len(counter)) return upgrades def get_info(info): try: if info == "os": try: osin = open('/etc/llver', 'r').read().split('\\n')[0] except: infocmd = "lsb_release -d | sed 's/Description:[\t]//g'" osin = execute(infocmd).split('\\n')[0] return osin if info == "desk": desk_ses = os.environ.get("XDG_SESSION_DESKTOP") if desk_ses is None: desk_ses = os.environ.get("XDG_CURRENT_DESKTOP") if "XFCE" in desk_ses or desk_ses.startswith("xfce"): xfcev = "xfce4-session -V | grep xfce4-session" return execute(xfcev).split('(')[1].split(')')[0].split(',')[0] elif "ubuntu" in desk_ses: return "Unity" else: return desk_ses if desk_ses is None: desk_ses = "Desktop Unknown" return desk_ses if info == "arc": return os.uname()[4] if info == "host": return os.uname()[1] if info == "kernel": return "{0} {1}".format(os.uname()[0], os.uname()[2]) if info == "updates": pkgcache = '/var/cache/apt/pkgcache.bin' aptcount = apt_info() if aptcount == 0: count = '' elif aptcount == 1: count = ' (<font style=\"color: red;\">{0}</font> update available)'.format( aptcount) else: count = ' (<font style=\"color: red;\">{0}</font> updates available)'.format( aptcount) if os.path.isfile(pkgcache): mtime = os_stat(pkgcache).st_mtime modtime = datetime.datetime.fromtimestamp(mtime).strftime( '%Y-%m-%d %H:%M') modday = datetime.datetime.fromtimestamp(mtime).strftime( '%Y-%m-%d') today = datetime.datetime.today().strftime('%Y-%m-%d') if modday == today: updaters = '''<section class="gradient">Last checked on <font style=\"color: green;\">{0}</font>{1} <button style=\"padding-bottom:0px;padding-left:50pxi\" onclick=\"location.href=('update://')\">Run Updates</button></section>'''.format( modtime, count) else: updaters = '''<section class="gradient">Last checked on <font style=\"color: red;\">{0}</font>{1} <button style=\"padding-bottom:0px;padding-left:50pxi\" onclick=\"location.href=('update://')\">Run Updates</button></section>'''.format( modtime, count) else: updaters = '''<section class="gradient">No Update History <button style=\"padding-bottom:0px;padding-left:50pxi\" onclick=\"location.href=('update://')\">Run Updates</button></section>''' return updaters if info == "processor": proc = execute("grep 'model name' /proc/cpuinfo").split(':')[1] return proc if info == "mem": total, active, inactive, free, cached, buffers, = mem_info() pie = ((int(total) - int(free)) - (int(buffers) + int(cached))) mem_usage = float(pie) * 100 / float(total) ramdis = "%14dMB (Used: %8dMB %7.2f%%)" % ( int(total) / 1048576, pie / 1024 / 1024, mem_usage) return ramdis if info == "gfx": return execute("lspci | grep VGA").split('controller:')[1].split( '(rev')[0].split(',')[0] if info == "audio": audio = execute("lspci | grep 'Audio device:'") if len(audio) == 0: return execute("lspci | grep audio").split('controller:')[ 1].split('(rev')[0].split(',')[0] else: return execute("lspci | grep Audio").split('device:')[1].split( '(rev')[0].split(',')[0] if info == "disk": p1 = subprocess.Popen( ['df', '-Tlh', '--total', '-t', 'ext4', '-t', 'ext3', '-t', 'ext2', '-t', 'reiserfs', '-t' 'jfs', '-t', 'ntfs', '-t', 'fat32', '-t', 'btrfs', '-t', 'fuseblk', '-t', 'xfs'], stdout=subprocess.PIPE).communicate()[0].decode("Utf-8") total = p1.splitlines()[-1] used = total.split()[3].replace(total.split()[3][-1:], " " + total.split()[3][-1:] + "B") size = total.split()[2].replace(total.split()[2][-1:], " " + total.split()[2][-1:] + "B") disk = "{0} (Used: {1})".format(size, used) return disk if info == "netstatus": if connected(): status = '<font color=green>Active</font>' else: status = '<font color=red>Not connected</font>' return status if info == "netip": ip = execute("hostname -I").split(' ') if len(ip) > 1: ip = ip[0] elif ip == "": ip = 'None' else: ip = 'None' return ip if info == "gateway": gateway = execute("route -n | grep 'UG[ \t]' | awk '{print $2}'") if len(gateway) == 0: gateway = 'None' return gateway except (OSError, TypeError, Exception) as e: print(e) return " " def which(program): def is_exe(fpath): return os.path.isfile(fpath) and os.access(fpath, os.X_OK) fpath, fname = os.path.split(program) if fpath: if is_exe(program): return program else: for path in os.environ["PATH"].split(os.pathsep): path = path.strip('"') exe_file = os.path.join(path, program) if is_exe(exe_file): return exe_file return None def get_modules(section): window = gtk.Window() try: mod_dir = os.listdir("{0}/modules/{1}/".format(app_dir, section)) mod_dir.sort() except Exception: dialog = gtk.MessageDialog(None, 0, gtk.MessageType.WARNING, gtk.ButtonsType.OK, 'Error Importing Module Data') dialog.set_default_size(400, 250) dialog.format_secondary_text("No modules could be found." + " Please reinstall " + appname) dialog.set_transient_for(window) response = dialog.run() if response == gtk.ResponseType.OK: dialog.destroy() sys.exit() dialog.destroy() if isinstance(mod_dir, list) and len(mod_dir) < 1: return "<p>\"no modules found!\"</p>" else: parser = ConfigParser() admin = "" mod_dir.sort() for i in mod_dir: parser.read("{0}/modules/{1}/{2}".format(app_dir, section, i)) command = parser.get('module', 'command') chk = command.split(' ')[0] if chk == "gksudo": chk = command.split(' ')[1] elif chk == "gksu": chk = command.split(' ')[1] checking = which(chk) if checking is not None: ico = parser.get('module', 'ico') ico = "{0}/frontend/icons/modules/{1}".format(app_dir, ico) name = parser.get('module', 'name') desc = parser.get('module', 'desc') command = command.replace("'", ''' \\' ''') admin += '''<div class="launcher" onclick="location.href='admin://{0}'" > <img src="{1}" onerror='this.src = "/usr/share/litecc/frontend/icons/modules/notfound.png"'/> <h3>{2}</h3> <span>{3}</span> </div>'''.format(command, ico, name, desc) return admin def frontend_fill(): filee = open("{0}/frontend/default.html".format(app_dir), "r") page = filee.read() for i in ['os', 'desk', 'arc', 'processor', 'mem', 'gfx', 'audio', 'disk', 'kernel', 'updates', 'host', 'netstatus', 'netip', 'gateway']: page = page.replace("{%s}" % i, str(get_info(i))) sections = ['software', 'system', 'desktop', 'hardware', 'networking'] sections.sort() for i in sections: page = page.replace("{%s_list}" % i, get_modules(i)) filee.close() return page def main(): global browser global window frontend = frontend_fill() window = gtk.Window() window.connect('destroy', gtk.main_quit) window.set_title(appname) window.set_icon(Pixbuf.new_from_file(app_icon)) rootsize = tkinter.Tk() if rootsize.winfo_screenheight() > 700: window.set_resizable(False) window.set_size_request(880, 660) else: window.set_resizable(True) window.set_size_request(880, 500) window.set_position(gtk.WindowPosition.CENTER), browser = webkit.WebView() swindow = gtk.ScrolledWindow() window.add(swindow) swindow.add(browser) window.show_all() browser.connect("navigation-requested", functions) browser.load_html_string(frontend, "file://{0}/frontend/".format(app_dir)) settings = browser.get_settings() settings.set_property('enable-default-context-menu', False) browser.set_settings(settings) gtk.main() if __name__ == '__main__': appname = 'Linux Lite Control Center' appver = '1.0-0310' app_dir = '/usr/share/litecc' app_icon = "/usr/share/pixmaps/lite-controlcenter.png" fh = 0 try: run_once() main() except (Exception, AttributeError) as e: print("Exiting due to error: {0}".format(e)) sys.exit(1)