First Wire-Py
This commit is contained in:
commit
c9677a3421
7
.idea/misc.xml
generated
Normal file
7
.idea/misc.xml
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Black">
|
||||||
|
<option name="sdkName" value="Python 3.10" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
101
.idea/workspace.xml
generated
Normal file
101
.idea/workspace.xml
generated
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AutoImportSettings">
|
||||||
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
|
</component>
|
||||||
|
<component name="ChangeListManager">
|
||||||
|
<list default="true" id="5634609e-1114-4f62-9cea-e246287a6807" name="Changes" comment="">
|
||||||
|
<change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||||
|
</list>
|
||||||
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
|
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||||
|
</component>
|
||||||
|
<component name="FileTemplateManagerImpl">
|
||||||
|
<option name="RECENT_TEMPLATES">
|
||||||
|
<list>
|
||||||
|
<option value="Python Script" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="Git.Settings">
|
||||||
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectColorInfo">{
|
||||||
|
"associatedIndex": 4
|
||||||
|
}</component>
|
||||||
|
<component name="ProjectId" id="2Zor9rCroxQrldvjWlmg216eKeL" />
|
||||||
|
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||||
|
<component name="ProjectViewState">
|
||||||
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
|
<option name="showLibraryContents" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PropertiesComponent">{
|
||||||
|
"keyToString": {
|
||||||
|
"Notification.DisplayName-DoNotAsk-CythonWarning": "Python debugger native extension available",
|
||||||
|
"Notification.DoNotAsk-CythonWarning": "true",
|
||||||
|
"Python.main.executor": "Run",
|
||||||
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
|
"git-widget-placeholder": "master",
|
||||||
|
"last_opened_file_path": "/home/punix/PycharmProjects/ctk_test/pythonProject1/main.py"
|
||||||
|
}
|
||||||
|
}</component>
|
||||||
|
<component name="RunManager">
|
||||||
|
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
||||||
|
<module name="pythonProject1" />
|
||||||
|
<option name="ENV_FILES" value="" />
|
||||||
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
|
<option name="PARENT_ENVS" value="true" />
|
||||||
|
<envs>
|
||||||
|
<env name="PYTHONUNBUFFERED" value="1" />
|
||||||
|
</envs>
|
||||||
|
<option name="SDK_HOME" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||||
|
<option name="IS_MODULE_SDK" value="true" />
|
||||||
|
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||||
|
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||||
|
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
|
||||||
|
<option name="PARAMETERS" value="" />
|
||||||
|
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||||
|
<option name="EMULATE_TERMINAL" value="false" />
|
||||||
|
<option name="MODULE_MODE" value="false" />
|
||||||
|
<option name="REDIRECT_INPUT" value="false" />
|
||||||
|
<option name="INPUT_FILE" value="" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
||||||
|
<component name="SharedIndexes">
|
||||||
|
<attachedChunks>
|
||||||
|
<set>
|
||||||
|
<option value="bundled-python-sdk-50da183f06c8-d3b881c8e49f-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-233.13135.95" />
|
||||||
|
</set>
|
||||||
|
</attachedChunks>
|
||||||
|
</component>
|
||||||
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||||
|
<component name="TaskManager">
|
||||||
|
<task active="true" id="Default" summary="Default task">
|
||||||
|
<changelist id="5634609e-1114-4f62-9cea-e246287a6807" name="Changes" comment="" />
|
||||||
|
<created>1703099124640</created>
|
||||||
|
<option name="number" value="Default" />
|
||||||
|
<option name="presentableId" value="Default" />
|
||||||
|
<updated>1703099124640</updated>
|
||||||
|
</task>
|
||||||
|
<servers />
|
||||||
|
</component>
|
||||||
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
|
<option name="TAB_STATES">
|
||||||
|
<map>
|
||||||
|
<entry key="MAIN">
|
||||||
|
<value>
|
||||||
|
<State />
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
133
main.py
Normal file
133
main.py
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
import tkinter as tk
|
||||||
|
|
||||||
|
# Dieser Befehl zeigt den aktiven Tunnel an
|
||||||
|
wg_s = os.popen('nmcli connection show | grep -iPo "(.*)(wireguard)"').read().strip().split()
|
||||||
|
tl = wg_s[::3] # tl = Tunnelliste # Hiermit wird jedes 4. Element der Liste gezeigt
|
||||||
|
|
||||||
|
lbg_color = '#c9c9c9'
|
||||||
|
bg_color = '#2f2f2f'
|
||||||
|
a_bg_color = '#484848' # color on active Button
|
||||||
|
up = os.popen('whoami').read().strip()
|
||||||
|
p1 = '/home/'
|
||||||
|
p2 = '/.config/wg_nmcli/'
|
||||||
|
wg_on = True
|
||||||
|
|
||||||
|
|
||||||
|
# Funktion um den aktuell aktiven Tunnel anzuzeigen
|
||||||
|
def active():
|
||||||
|
wg_a = os.popen('nmcli connection show --active | grep -iPo "(.*)(wireguard)"').read().strip().split()
|
||||||
|
if not wg_a:
|
||||||
|
wg_a = ''
|
||||||
|
return wg_a
|
||||||
|
|
||||||
|
else:
|
||||||
|
for tunnel in wg_a:
|
||||||
|
return tunnel
|
||||||
|
|
||||||
|
|
||||||
|
a = active()
|
||||||
|
|
||||||
|
|
||||||
|
class WG(tk.Tk):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.title('Wire-Py')
|
||||||
|
self.geometry('430x290')
|
||||||
|
# Load the image file from disk.
|
||||||
|
wg_icon = tk.PhotoImage(file=r'icons/wg-vpn-48.png')
|
||||||
|
# Set it as the window icon.
|
||||||
|
self.iconphoto(True, wg_icon)
|
||||||
|
|
||||||
|
self.wgi_on = tk.PhotoImage(file=r'icons/wire-switch-on-48.png')
|
||||||
|
self.wgi_off = tk.PhotoImage(file=r'icons/wire-switch-off-48.png')
|
||||||
|
self.imp_pic = tk.PhotoImage(file=r'icons/wg-import.png')
|
||||||
|
|
||||||
|
self.btn_i = tk.Button(self, image=self.imp_pic, bd=0, bg=bg_color, activebackground=bg_color)
|
||||||
|
self.btn_i.config(width=52, height=52, highlightthickness=0)
|
||||||
|
self.btn_i.place(x=95, y=110)
|
||||||
|
#
|
||||||
|
self.lbi = tk.Label(self, text='Import', bg=bg_color, fg='yellow')
|
||||||
|
self.lbi.config(font=("Ubuntu", 9))
|
||||||
|
self.lbi.pack(pady=5)
|
||||||
|
self.lbi.place(x=101, y=85)
|
||||||
|
|
||||||
|
self.tr_pic = tk.PhotoImage(file=r'icons/wg-trash.png')
|
||||||
|
self.btn_tr = tk.Button(self, image=self.tr_pic, bd=0, bg=bg_color, activebackground=bg_color)
|
||||||
|
self.btn_tr.config(width=52, height=52, text='Trash', highlightthickness=0)
|
||||||
|
self.btn_tr.place(x=170, y=110)
|
||||||
|
|
||||||
|
self.lb_tr = tk.Label(self, text='Remove', bg=bg_color, fg='red')
|
||||||
|
self.lb_tr.config(font=("Ubuntu", 9))
|
||||||
|
self.lb_tr.pack(pady=5)
|
||||||
|
self.lb_tr.place(x=170, y=85)
|
||||||
|
|
||||||
|
self.lb_stst = tk.Label(self, text='On/Off', bg=bg_color, fg='#1c77f8')
|
||||||
|
self.lb_stst.config(font=("Ubuntu", 9))
|
||||||
|
self.lb_stst.pack(pady=5)
|
||||||
|
self.lb_stst.place(x=25, y=85)
|
||||||
|
|
||||||
|
self.btn_stst = tk.Button(self, image=self.wgi_on, bg=bg_color, activebackground=bg_color, bd=0,
|
||||||
|
command=self.wg_switch)
|
||||||
|
self.btn_stst.config(image=self.wgi_on, width=50, height=75, highlightthickness=0)
|
||||||
|
self.config(bg=bg_color)
|
||||||
|
self.btn_stst.place(x=20, y=113)
|
||||||
|
|
||||||
|
self.lb = tk.Label(self, text='Active: ', bg=bg_color, fg='white')
|
||||||
|
self.lb.config(font=("Ubuntu", 11, "bold"))
|
||||||
|
self.lb.pack(padx=10, pady=10)
|
||||||
|
self.lb.place(x=30, y=10)
|
||||||
|
|
||||||
|
self.lb_tunnel = tk.Label(self, text=f'{a}', bg=bg_color, fg='yellow')
|
||||||
|
self.lb_tunnel.config(font=("Ubuntu", 11, "bold"))
|
||||||
|
self.lb_tunnel.pack(pady=5, side='bottom')
|
||||||
|
self.lb_tunnel.place(x=90, y=10)
|
||||||
|
|
||||||
|
self.lb_2 = tk.Label(self, text='''If no tunnels are listed
|
||||||
|
you must first import your tunnel.''', bg=bg_color, fg='white')
|
||||||
|
self.lb_2.config(font=("Ubuntu", 9, "bold"))
|
||||||
|
self.lb_2.pack(pady=5, side='left')
|
||||||
|
self.lb_2.place(x=20, y=40)
|
||||||
|
|
||||||
|
self.scrollbar = tk.Scrollbar(self)
|
||||||
|
self.l_box = tk.Listbox(self, height=110, bg=lbg_color, fg='#606060', selectmode='single')
|
||||||
|
self.l_box.config(highlightthickness=0, relief='flat')
|
||||||
|
self.scrollbar.config(command=self.l_box.yview)
|
||||||
|
self.l_box.config(font=("Ubuntu", 12, "bold"))
|
||||||
|
self.l_box.pack(side='right', pady=30)
|
||||||
|
|
||||||
|
for tunnels in tl:
|
||||||
|
self.l_box.insert("end", tunnels)
|
||||||
|
|
||||||
|
self.wg_autostart = tk.Checkbutton(self, text='Autoconnect on PC Start', bg=bg_color,
|
||||||
|
activebackground=bg_color, fg='white')
|
||||||
|
self.wg_autostart.config(height=2, bg=bg_color, highlightthickness=0)
|
||||||
|
self.wg_autostart.pack()
|
||||||
|
self.wg_autostart.place(x=20, y=190)
|
||||||
|
self.wg_update = tk.Checkbutton(self, text='\nSearch automatically for\nWire-Py updates', bg=bg_color,
|
||||||
|
activebackground=bg_color, fg='white')
|
||||||
|
self.wg_update.config(height=0, bg=bg_color, highlightthickness=0)
|
||||||
|
self.wg_update.pack()
|
||||||
|
self.wg_update.place(x=20, y=215)
|
||||||
|
|
||||||
|
def wg_switch(self):
|
||||||
|
global wg_on
|
||||||
|
if wg_on:
|
||||||
|
self.btn_stst.config(image=self.wgi_off, width=50, height=75)
|
||||||
|
self.config(bg=bg_color)
|
||||||
|
self.btn_stst.place(x=20, y=113)
|
||||||
|
wg_on = False
|
||||||
|
else:
|
||||||
|
self.btn_stst.config(image=self.wgi_on, width=50, height=75)
|
||||||
|
self.config(bg=bg_color)
|
||||||
|
self.btn_stst.place(x=20, y=113)
|
||||||
|
wg_on = True
|
||||||
|
|
||||||
|
|
||||||
|
# scrollbar.pack(side='left', fill='y')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
window = WG()
|
||||||
|
window.mainloop()
|
Loading…
x
Reference in New Issue
Block a user