Update: Kumo was updated
There has been alot of requests to bring back the SSB add add app to the menu or launcher, I have reintroduced those feature. Now the App will do the followling: 1. Add a Launcher to the Menu, 2. If deleted the file and record is deleted from the system and database 3. an icon can be selected to be used for the menu/launcher icon. Signed-off-by: debianpepper <pdpdebdevuan@protonmail.com>
This commit is contained in:
parent
c0da98b89c
commit
22068c9298
|
@ -11,20 +11,22 @@ import sqlite3
|
|||
import tkinter as tk
|
||||
import ttkbootstrap as ttk
|
||||
import bsconf
|
||||
from tkinter import filedialog
|
||||
|
||||
|
||||
# setup the window
|
||||
pwin = bsconf.bbstyle
|
||||
pwin.resizable(False, False)
|
||||
WINDOW_HEIGHT = 300
|
||||
WINDOW_HEIGHT = 380
|
||||
WINDOW_WIDTH = 640
|
||||
pwin.title('Peppermint Kumo (SSB Manager)')
|
||||
|
||||
|
||||
# Set the user path
|
||||
# Set the user paths used
|
||||
gusr = os.getlogin()
|
||||
spath = "/home/" + gusr + "/.local/share/pmostools/peptools"
|
||||
# Set the icon
|
||||
dpath = "/home/" + gusr + "/.local/share/applications/"
|
||||
# Set the window icon
|
||||
pwin.tk.call('wm', 'iconphoto', pwin,
|
||||
tk.PhotoImage(
|
||||
file=spath + '/images/kumosm.png'))
|
||||
|
@ -38,6 +40,21 @@ pcur.execute(""" CREATE TABLE IF NOT EXISTS kumoapp (id integer PRIMARY
|
|||
)
|
||||
|
||||
|
||||
def delete_ssb():
|
||||
""" Delete the ssb that is selected """
|
||||
get_name = cmbo.get()
|
||||
link_address = """ DELETE FROM kumoapp WHERE ssbname = ? """
|
||||
pcur.execute(link_address, (get_name,))
|
||||
dcon.commit()
|
||||
runaddr_value.delete('1.0', tk.END)
|
||||
for dfile in os.listdir(dpath):
|
||||
if dfile.startswith(get_name) and dfile.endswith('.desktop'):
|
||||
del_path = os.path.join(dpath, dfile)
|
||||
os.remove(del_path)
|
||||
pwin.destroy()
|
||||
os.system('python3 refresh.py')
|
||||
|
||||
|
||||
def center_screen():
|
||||
""" gets the coordinates of the center of the screen """
|
||||
screen_width = pwin.winfo_screenwidth()
|
||||
|
@ -52,26 +69,38 @@ def center_screen():
|
|||
)
|
||||
|
||||
|
||||
def make_desktop_file():
|
||||
""" this will make the ssb and store in the Home folder"""
|
||||
get_name = ssb_value.get("1.0", 'end-1c')
|
||||
get_url = urladdr_value.get("1.0", 'end-1c')
|
||||
get_local = cmbomenu.get()
|
||||
get_icon = icon_value.get("1.0", 'end-1c')
|
||||
write_path = dpath + get_name + '.desktop'
|
||||
selected_category_key = categories_reverse[get_local]
|
||||
app_content = f"""
|
||||
[Desktop Entry]
|
||||
Name={get_name}
|
||||
Exec= luakit -U {get_url}
|
||||
Icon={get_icon}
|
||||
Categories={selected_category_key}
|
||||
Type=Application
|
||||
"""
|
||||
with open(write_path, 'w') as app:
|
||||
app.write(app_content)
|
||||
|
||||
|
||||
def add_new_ssb():
|
||||
""" Add new ssb """
|
||||
make_desktop_file()
|
||||
ssb_name = ssb_value.get("1.0", 'end-1c')
|
||||
ssb_address = urladdr_value.get("1.0", 'end-1c')
|
||||
sql_insert = """ INSERT INTO kumoapp(ssbname,lnk) VALUES(?,?);"""
|
||||
pcur.execute(sql_insert, (ssb_name, ssb_address,))
|
||||
dcon.commit()
|
||||
dcon.commit()
|
||||
ssb_value.delete('1.0', tk.END)
|
||||
urladdr_value.delete('1.0', tk.END)
|
||||
pwin.destroy()
|
||||
os.system('python3 ' + spath + '/refresh.py')
|
||||
|
||||
|
||||
def delete_ssb():
|
||||
""" Delete the ssb that is selected """
|
||||
get_name = cmbo.get()
|
||||
link_address = """ DELETE FROM kumoapp WHERE ssbname = ? """
|
||||
pcur.execute(link_address, (get_name,))
|
||||
dcon.commit()
|
||||
runaddr_value.delete('1.0', tk.END)
|
||||
os.system('python3 ' + spath + '/refresh.py')
|
||||
pwin.destroy()
|
||||
os.system('python3 refresh.py')
|
||||
|
||||
|
@ -93,68 +122,106 @@ def fill_url_address():
|
|||
use_address = pcur.fetchone()
|
||||
runaddr_value.delete('1.0', tk.END)
|
||||
runaddr_value.insert("end-1c", use_address)
|
||||
|
||||
|
||||
def run_url_address():
|
||||
""" Run the ssb with the run button"""
|
||||
run_addrs = runaddr_value.get("1.0", 'end-1c')
|
||||
os.system('luakit -U ' + run_addrs + ' &')
|
||||
|
||||
### Create SSB side
|
||||
def select_icon():
|
||||
"""
|
||||
Select the icon to be used for the SSB in the system
|
||||
The starting folder is the pixmaps
|
||||
"""
|
||||
initial_dir = "/usr/share/pixmaps/"
|
||||
file_path = filedialog.askopenfilename(
|
||||
title="Select Icon",
|
||||
initialdir=initial_dir,
|
||||
filetypes=[("Icon files", "*.ico"), ("Icon files", "*.png"),
|
||||
("Icon files", "*.gif"), ("Icon files", "*.ppm"),
|
||||
("Icon files", "*.pgm")]
|
||||
)
|
||||
if file_path:
|
||||
icon_value.delete(1.0, tk.END)
|
||||
icon_value.insert(tk.END, file_path)
|
||||
|
||||
|
||||
|
||||
### Create SSB side objects used
|
||||
### Title
|
||||
new_label = ttk.Label(pwin, text="Create new SSBs",
|
||||
bootstyle="danger",
|
||||
font=("Helvetica", 14)
|
||||
)
|
||||
|
||||
new_label.place(x=10, y=20)
|
||||
|
||||
ssb_label = ttk.Label(pwin, text="Give the ssb a name:")
|
||||
ssb_label.place(x=10, y=50)
|
||||
ssb_label.place(x=10, y=55)
|
||||
ssb_value = tk.Text(pwin, height=1, width=25)
|
||||
ssb_value.place(x=10, y=75)
|
||||
|
||||
separator = ttk.Separator(pwin, orient='vertical')
|
||||
separator.place(relx=.495, rely=0, relheight=1)
|
||||
|
||||
ssb_value.place(x=10, y=80)
|
||||
lblcmbomenu = ttk.Label(pwin, text="Menu Location:")
|
||||
lblcmbomenu.place(x=10, y=113)
|
||||
categories = { 'AudioVideo' : 'AudioVideo', 'Audio':'Audio', 'Video':'Video',
|
||||
'Development':'Development', 'Education':'Education',
|
||||
'Game':'Game', 'Graphics':'Graphics', 'Network':'Internet',
|
||||
'Office':'Office', 'Settings':'Settings','System':'System',
|
||||
'Utility':'Utility'
|
||||
}
|
||||
categories_reverse = {value: key for key, value in categories.items()}
|
||||
cmbomenu = ttk.Combobox(pwin)
|
||||
cmbomenu.place(x=10, y=135)
|
||||
cmbomenu['values'] = list(categories.values())
|
||||
icon_default_text = 'Set the icon with the "Icon" button'
|
||||
icon_value = tk.Text(pwin, height=1, width=36)
|
||||
icon_value.insert(tk.END, icon_default_text)
|
||||
icon_value.place(x=10, y=172)
|
||||
icon_button = ttk.Button(pwin, text="Icon", width=7, cursor="hand2",
|
||||
bootstyle="light-outline", command=select_icon
|
||||
)
|
||||
icon_button.place(x=232, y=210)
|
||||
url_default_text = "example: https://www.example.com"
|
||||
urladdr_label = ttk.Label(pwin, text="Enter the Url:")
|
||||
urladdr_label.place(x=10, y=125)
|
||||
urladdr_value = tk.Text(pwin, height=4, width=30)
|
||||
urladdr_value.place(x=10, y=150)
|
||||
urladdr_label.place(x=10, y=224)
|
||||
urladdr_value = tk.Text(pwin, height=3, width=36)
|
||||
urladdr_value.insert(tk.END, url_default_text)
|
||||
urladdr_value.place(x=10, y=246)
|
||||
|
||||
btnsv = ttk.Button(
|
||||
pwin,
|
||||
text="save",
|
||||
text="Save",
|
||||
cursor="hand2",
|
||||
bootstyle="light-outline",
|
||||
width=5,
|
||||
command=add_new_ssb
|
||||
)
|
||||
btnsv.place(x=10, y=250)
|
||||
|
||||
btnsv.place(x=10, y=324)
|
||||
### The Separator for the window
|
||||
separator = ttk.Separator(pwin, orient='vertical')
|
||||
separator.place(relx=.495, rely=0, relheight=1)
|
||||
### Manage SSBs side)
|
||||
manage_label = ttk.Label(pwin, text="Manage SSBs",
|
||||
bootstyle="danger",
|
||||
font=("Helvetica", 14)
|
||||
)
|
||||
manage_label.place(x=340, y=20)
|
||||
|
||||
manage_label.place(x=330, y=20)
|
||||
lblcmbo = ttk.Label(pwin, text="Select SSB to Manage:")
|
||||
lblcmbo.place(x=340, y=50)
|
||||
lblcmbo.place(x=330, y=55)
|
||||
cmbo = ttk.Combobox(pwin)
|
||||
cmbo.place(x=340, y=70)
|
||||
cmbo.place(x=330, y=80)
|
||||
cmbo['values'] = (fill_dropdown())
|
||||
|
||||
runaddr_label = ttk.Label(pwin, text="Url Address:")
|
||||
runaddr_label.place(x=340, y=125)
|
||||
runaddr_value = tk.Text(pwin, height=4, width=30)
|
||||
runaddr_value.place(x=340, y=150)
|
||||
|
||||
runaddr_label.place(x=330, y=125)
|
||||
runaddr_value = tk.Text(pwin, height=4, width=36)
|
||||
runaddr_value.place(x=330, y=150)
|
||||
btnrun = ttk.Button(
|
||||
pwin,
|
||||
text="Run",
|
||||
cursor="hand2",
|
||||
bootstyle="light-outline",
|
||||
width=7,
|
||||
command=fill_url_address
|
||||
command=run_url_address
|
||||
)
|
||||
btnrun.place(x=340, y=250)
|
||||
|
||||
btnrun.place(x=330, y=324)
|
||||
btndelete = ttk.Button(
|
||||
pwin,
|
||||
text="Delete",
|
||||
|
@ -163,7 +230,26 @@ btndelete = ttk.Button(
|
|||
width=7,
|
||||
command=delete_ssb
|
||||
)
|
||||
btndelete.place(x=430, y=250)
|
||||
|
||||
btndelete.place(x=430, y=324)
|
||||
|
||||
|
||||
def set_state(event):
|
||||
"""
|
||||
Function that managse the state of the buttons and the Url address
|
||||
for the Manage SSBs section, this is an event function
|
||||
"""
|
||||
|
||||
selected_value = cmbo.get()
|
||||
if selected_value == "":
|
||||
btndelete["state"] = "disabled"
|
||||
btnrun["state"] = "disabled"
|
||||
else:
|
||||
btndelete["state"] = "normal"
|
||||
btnrun["state"] = "normal"
|
||||
fill_url_address()
|
||||
|
||||
cmbo.bind("<<ComboboxSelected>>", set_state)
|
||||
set_state(None)
|
||||
center_screen()
|
||||
pwin.mainloop()
|
||||
|
|
|
@ -36,6 +36,35 @@ def check_packages():
|
|||
store['state'] = tk.DISABLED
|
||||
|
||||
|
||||
def test():
|
||||
pth = ['/usr/bin/atril',
|
||||
'/usr/bin/snap',
|
||||
'/usr/bin/parole',
|
||||
'/usr/bin/gufw',
|
||||
'/usr/bin/flatpak',
|
||||
'/usr/bin/timeshift',
|
||||
'/usr/bin/keepassxc'
|
||||
]
|
||||
btn = [pdf_viewer
|
||||
snap
|
||||
media_player
|
||||
fire_wall
|
||||
flatpak
|
||||
backup_tool
|
||||
store
|
||||
|
||||
|
||||
]
|
||||
btn = [5,6,7,8]
|
||||
for i in pth:
|
||||
if os.path.exists(i):
|
||||
for b in btn:
|
||||
b['state'] = tk.DISABLED
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def check_web_browsers():
|
||||
""" Check what browsers are installed"""
|
||||
if os.path.exists('/usr/bin/firefox'):
|
||||
|
|
Loading…
Reference in New Issue