uruk-conf.py 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #!/usr/bin/env python3
  2. #
  3. # Uruk Update Manager
  4. #
  5. # Copyright 2022 hayder majid <hayder@riseup.net>
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  20. # MA 02110-1301, USA.
  21. from tkinter import *
  22. from tkinter import messagebox
  23. import os
  24. import configparser
  25. gui=Tk()
  26. gui.configure(background='#ffffff')
  27. gui.title("Uruk Update Manager")
  28. photo = PhotoImage(file ='/usr/share/urukUpdater/pixmap/urukupdater-up-to-date.png')
  29. gui.iconphoto(False, photo)
  30. confDir = '/usr/share/urukUpdater/config.conf'
  31. config = configparser.ConfigParser()
  32. config.read(confDir)
  33. try:
  34. time_ref = IntVar(value=int(config['CONFVAL']['time_refresh']))
  35. show_not = IntVar(value=int(config['CONFVAL']['show_notification']))
  36. # auto_ref = IntVar(value=int(config['CONFVAL']['auto_refresh']))
  37. full_upg = IntVar(value=int(config['CONFVAL']['full_upgrade']))
  38. print('Stored initial values loaded!')
  39. except:
  40. time_ref = IntVar(value=int(config['DEFAULT']['time_refresh']))
  41. show_not = IntVar(value=int(config['DEFAULT']['show_notification']))
  42. # auto_ref = IntVar(value=int(config['DEFAULT']['auto_refresh']))
  43. full_upg = IntVar(value=int(config['DEFAULT']['full_upgrade']))
  44. print('Default values loaded!')
  45. def apply_conf():
  46. try:
  47. int(textBox.get())
  48. config['CONFVAL']['time_refresh'] = str(int(textBox.get())*60)
  49. config['CONFVAL']['show_notification'] = str(show_not.get())
  50. # config['CONFVAL']['auto_refresh'] = str(auto_ref.get())
  51. config['CONFVAL']['full_upgrade'] = str(full_upg.get())
  52. if int(show_not.get()) == 1:
  53. os.system('sed -i "s/#NOTIFY8 /NOTIFY /" /usr/lib/urukUpdater/setter')
  54. else:
  55. os.system('sed -i "s/NOTIFY /#NOTIFY8 /" /usr/lib/urukUpdater/setter')
  56. # if int(auto_ref.get()) == 1:
  57. # os.system('touch /home/$USER/.urukUpdater/auto_ref.FLAG 2> /dev/null')
  58. # else:
  59. # os.system('rm /home/$USER/.urukUpdater/auto_ref.FLAG 2> /dev/null ')
  60. if int(full_upg.get()) == 1:
  61. os.system('sed -i "s/NUM=.*/NUM=dist-upgrade/" /usr/lib/urukUpdater/u-mode')
  62. os.system('sudo /usr/lib/urukUpdater/u-mode')
  63. else:
  64. os.system('sed -i "s/NUM=.*/NUM=upgrade/" /usr/lib/urukUpdater/u-mode')
  65. os.system('sudo /usr/lib/urukUpdater/u-mode')
  66. with open(confDir, 'w') as setconf:
  67. config.write(setconf)
  68. messagebox.showinfo(title="Apply changes", message="All changes have been applied ")
  69. print("Stored ",textBox.get()," as new automatic update time, All changes have been applied " )
  70. os.system('sudo /usr/lib/urukUpdater/checker &> /dev/null ')
  71. except ValueError:
  72. messagebox.showerror(title="error", message="Please enter a valid number")
  73. print('Wrong value entered!')
  74. def messageBox():
  75. messagebox.showinfo(title="About Uruk Update Manager", message="Uruk Update Manager \n Free and Open Source System Update Manager to manage your Debian based system \n by hayder majid <hayder@riseup.net> \n version 1.0 \n under (GPLv3) or later 2022 ")
  76. labelList = Label(gui,text = "Preferences \n ", fg = "#636e72", bg='#ffffff', font=("noto", 12, "bold"))
  77. labelList.grid(column=1, row=1, padx=1, pady=3, sticky='w')
  78. labelList = Label(gui,text = "Auto-refresh check time (in min) ", fg = "#636e72", bg='#ffffff', font=("noto", 9, "bold"))
  79. labelList.grid(column=1, row=3, padx=1, pady=4, sticky='w')
  80. labelList = Label(gui,text = "Show Desktop notification", fg = "#636e72", bg='#ffffff', font=("noto", 9, "bold"))
  81. labelList.grid(column=1, row=5, padx=1, pady=4, sticky='w')
  82. # labelList = Label(gui,text = "Automatically Download update ", fg = "#636e72", bg='#ffffff', font=( "noto", 9, "bold"))
  83. # labelList.grid(column=1, row=7, padx=1, pady=4, sticky='w')
  84. labelList = Label(gui,text = "Use Full Upgrade for \n checking and updating system", fg = "#636e72", bg='#ffffff', font=("noto", 9, "bold"))
  85. labelList.grid(column=1, row=8, padx=1, pady=4, sticky='w')
  86. textBox=Entry(gui, width=8, borderwidth=0, bg='#ffffff')
  87. textBox.insert(0,int(time_ref.get()/60))
  88. textBox.grid(column=0, row=3, padx=10, pady=14, sticky='e')
  89. checkBox1 = Checkbutton(gui, variable = show_not, borderwidth=0,highlightthickness=0,bd=0, fg = "#636e72", bg='#ffffff')
  90. checkBox1.grid(column=0, row=5, padx=10, pady=14, sticky='e')
  91. # checkBox1 = Checkbutton(gui, variable = auto_ref, borderwidth=0, fg = "#636e72", bg='#ffffff')
  92. # checkBox1.grid(column=0, row=7, padx=0, pady=4, sticky='e')
  93. checkBox2 = Checkbutton(gui, variable = full_upg, borderwidth=0,highlightthickness=0,bd=0, fg = "#636e72", bg='#ffffff')
  94. checkBox2.grid(column=0, row=8, padx=10, pady=14, sticky='e')
  95. buttonDll=Button(gui, height=0, width=16, text="Apply", fg='white', bg='#5599ff', font=('noto', 10, "bold"), borderwidth=0, command=lambda: apply_conf())
  96. buttonDll.grid(column=1, row=9,padx=10, pady=12)
  97. buttonEx=Button(gui, height=0, width=8, text="Exit", fg='white', bg='#ff7675', font=('noto', 10, "bold"), borderwidth=0, command=gui.destroy)
  98. buttonEx.grid(column=0, row=9, padx=10,pady=12)
  99. gui.geometry("380x280")
  100. mainloop()