Skip to content

Commit

Permalink
Configure to install with exe installer
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdvmd committed Aug 18, 2023
1 parent bf700b9 commit 2a56d2b
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 28 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 8 additions & 1 deletion src/common_clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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()


Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/device_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
56 changes: 56 additions & 0 deletions src/installer_setup.iss
Original file line number Diff line number Diff line change
@@ -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

26 changes: 1 addition & 25 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -36,6 +16,7 @@ def generate_shortcut_table(shortcuts):
'time',
'win32clipboard',
'sys',
'os',
'pickle',
'socket',
'threading',
Expand Down Expand Up @@ -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=[
Expand Down
Binary file added static/connection_status.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2a56d2b

Please sign in to comment.