diff --git a/README.md b/README.md index 6c582a3..c174147 100644 --- a/README.md +++ b/README.md @@ -50,12 +50,17 @@ and all the data transfer happens in the background, meaning the only commands y ![Editing Port Demo](https://github.com/cmdvmd/common-clipboard/blob/main/static/edit_port.gif) -4. On the device running the server, the names and local IPv4 addresses of all connected devices can be viewed from the +4. To view whether the current device is connected to the Common Clipboard server, hover over the icon in the system + tray + + ![Viewing if Connected to Server Demo](https://github.com/cmdvmd/common-clipboard/blob/main/static/connection_status.png) + +5. On the device running the server, the names and local IPv4 addresses of all connected devices can be viewed from the system tray ![Viewing Connected Devices Demo](https://github.com/cmdvmd/common-clipboard/blob/main/static/view_connected.png) -5. To quit the Common Clipboard application, use the "Quit" option in the system tray +6. To quit the Common Clipboard application, use the "Quit" option in the system tray ![Quitting Demo](https://github.com/cmdvmd/common-clipboard/blob/main/static/quit.png) diff --git a/src/common_clipboard.py b/src/common_clipboard.py index bb2a0c5..de3489c 100644 --- a/src/common_clipboard.py +++ b/src/common_clipboard.py @@ -6,6 +6,7 @@ import time import win32clipboard as clipboard import sys +import os import pickle from socket import gethostbyname, gethostname from threading import Thread @@ -135,8 +136,12 @@ def close(): run_app = False if server_process is not None: server_process.terminate() + + if not os.path.exists(data_dir): + os.makedirs(data_dir) with open(preferences_file, 'wb') as save_file: pickle.dump([port, running_server], save_file) + systray.stop() sys.exit(0) @@ -150,6 +155,7 @@ def edit_port(): port = new_port if running_server and server_process is not None: server_process.terminate() + connected_devices.clear() start_server() @@ -182,7 +188,8 @@ def get_menu_items(): server_process: Process = None - preferences_file = 'preferences.pickle' + data_dir = os.path.join(os.getenv('LOCALAPPDATA'), 'CommonClipboard') + preferences_file = os.path.join(data_dir, 'preferences.pickle') try: with open(preferences_file, 'rb') as preferences: port, running_server = pickle.load(preferences) diff --git a/src/device_list.py b/src/device_list.py index 5eb2c28..df69918 100644 --- a/src/device_list.py +++ b/src/device_list.py @@ -25,6 +25,9 @@ def add_device(self, ip, name): 'received': False }}) + def clear(self): + self._devices.clear() + def update_activity(self, ip): self._devices[ip]['last active'] = time.time() diff --git a/src/installer_setup.iss b/src/installer_setup.iss new file mode 100644 index 0000000..07d7ea1 --- /dev/null +++ b/src/installer_setup.iss @@ -0,0 +1,56 @@ +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + +#define MyAppName "Common Clipboard" +#define MyAppVersion "1.0b0" +#define MyAppPublisher "cmdvmd" +#define MyAppURL "https://github.com/cmdvmd/common-clipboard" +#define MyAppExeName "common_clipboard.exe" + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{8C71C396-D195-4BA8-BD0A-1E09F95C4535} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +;AppVerName={#MyAppName} {#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +DefaultDirName={autopf}\{#MyAppName} +UninstallDisplayName={#MyAppName} +UninstallDisplayIcon={app}\{#MyAppExeName} +DisableProgramGroupPage=yes +LicenseFile=..\LICENSE +; Uncomment the following line to run in non administrative install mode (install for current user only.) +;PrivilegesRequired=lowest +OutputDir=build +OutputBaseFilename=common_clipboard_installer +SetupIconFile=..\static\installer_icon.ico +Compression=lzma +SolidCompression=yes +WizardStyle=modern + +[UninstallDelete] +Type: filesandordirs; Name: "{localappdata}\CommonClipboard" + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked + +[Files] +Source: ".\build\exe.win-amd64-3.11\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion +Source: ".\build\exe.win-amd64-3.11\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" +Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon +Name: "{commonstartup}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" + +[Run] +Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent + diff --git a/src/setup.py b/src/setup.py index bb90d12..93cfaee 100644 --- a/src/setup.py +++ b/src/setup.py @@ -2,26 +2,6 @@ from cx_Freeze import setup, Executable -def generate_shortcut_table(shortcuts): - table = [] - for location in shortcuts: - table.append(( - f'{location}Shortcut', - f'{location}Folder', - 'Common Clipboard', - 'TARGETDIR', - '[TARGETDIR]common_clipboard.exe', - None, - None, - None, - None, - None, - None, - 'TARGETDIR' - )) - return table - - if __name__ == '__main__': setup( name='common_clipboard', @@ -36,6 +16,7 @@ def generate_shortcut_table(shortcuts): 'time', 'win32clipboard', 'sys', + 'os', 'pickle', 'socket', 'threading', @@ -64,11 +45,6 @@ def generate_shortcut_table(shortcuts): 'systray_icon.ico' ], 'optimize': 2 - }, - 'bdist_msi': { - 'data': { - 'Shortcut': generate_shortcut_table(['Desktop', 'StartMenu', 'Startup']) - } } }, executables=[ diff --git a/static/connection_status.png b/static/connection_status.png new file mode 100644 index 0000000..d128647 Binary files /dev/null and b/static/connection_status.png differ