Skip to content

Commit

Permalink
Updated README and improved build-script
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennolium committed Oct 10, 2023
1 parent e492ae5 commit 40eb173
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 60 deletions.
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
alt="commit activity" >
<a></a>
<a href="https://github.com/Lennolium/swiftGuard#download" >
<img src="https://img.shields.io/badge/Version-0.0.1-brightgreen"
<img src="https://img.shields.io/badge/Version-0.0.2-brightgreen"
alt="stable version" >
<br>
<a href="https://github.com/Lennolium/swiftGuard/issues" >
Expand Down Expand Up @@ -93,11 +93,10 @@ shutdown process.
- __Discrete:__ Operates in the macOS system tray, minimizing
interruptions.
- __Customizable:__ Allows users to configure various settings, including
action (shutdown/hibernate), countdown timer and whitelist.
action (shutdown/hibernate), countdown timer and auto start.
- __Lightweight:__ Designed to consume minimal system resources for optimal
performance.
- __Privacy:__ Does not require an internet connection, ensuring the privacy
of your data.
- __Privacy:__ Only connects to the internet to check for updates at startup.
- __Open Source:__ Provides transparency and
allows community contributions for continuous development.

Expand Down Expand Up @@ -146,13 +145,11 @@ regulations. swiftGuard helps maintain compliance by preventing unauthorized dat
1. Obtain the most recent version by downloading it from [Releases](https://github.com/Lennolium/swiftGuard/releases).
2. Open the downloaded `swiftGuard.dmg` file.
3. Drag the swiftGuard application into the Applications folder.
4. Grant necessary permissions by opening `System Preferences > Security & Privacy > Privacy > Automation` and adding swiftGuard to
the list of applications.
5. For startup at login, open `System Preferences > General > Login Items` and add swiftGuard to the list of applications.
6. Open the swiftGuard application from the Applications folder.
7. swiftGuard should now appear in the macOS system tray.
8. Test at least once if the shutdown or hibernation is executed correctly. On first run you will be asked to grant the necessary
4. Open the swiftGuard application from the Applications folder (by right-clicking and selecting `Open`, see Note below)
5. swiftGuard should now appear in the macOS system tray.
6. Test at least once if the shutdown or hibernation is executed correctly. On first run you will be asked to grant the necessary
permissions by macOS.
7. Automatic startup at login can be enabled in the app's settings menu.

&nbsp;
> **Important**: Make sure you use FileVault, macOS's built-in disk encryption feature, encrypt your entire disk,
Expand All @@ -161,7 +158,7 @@ permissions by macOS.
>__Note:__ If you get a warning that the application is from an _unidentified developer_, you have to open
>`System Preferences > Security & Privacy > Security` and click `Open Anyway`
>to allow the application to run. Alternatively, you can right-click on the application icon and select `Open`.
>to allow the application to run.
&nbsp;

Expand Down
3 changes: 3 additions & 0 deletions build-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ if pyinstaller "pyinstaller.spec"
then
_ok "PyInstaller successfully created build."
_ok "Find swiftGuard.app in /dist folder."
app_size_raw=$(du -sh dist/swiftGuard)
app_size=${app_size_raw:1:4}
_ok "File size: $app_size"
_ok "SCRIPT FINISHED!"
else
_error "BUILD FAILED!"
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ requests = "^2.31.0"

[tool.poetry.group.dev.dependencies]
black = "^23.9.1"
bandit = "^1.7.5"
pyinstaller = "^6.0.0"
pyinstaller-hooks-contrib = "^2023.9"

Expand Down
31 changes: 3 additions & 28 deletions src/swiftguard/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
__status__ = "Prototype"

# Imports.
import configparser
import datetime
import signal
import sys
Expand All @@ -61,7 +60,7 @@
QWidget,
)

from swiftguard.const import APP_PATH
from swiftguard.const import APP_PATH, DARK, LIGHT
# pylint: disable=unused-import
# noinspection PyUnresolvedReferences
from swiftguard.resources import resources_rc # noqa: F401
Expand All @@ -79,27 +78,6 @@
LOG_COUNT = LogCount()
LOGGER = create_logger(LOG_COUNT)

# Resource paths.
LIGHT = {
"checkmark": ":/resources/light/checkmark.svg",
"usb-connection": ":/resources/light/usb-connection.svg",
"shield-check": ":/resources/light/shield-check.svg",
"shield-slash": ":/resources/light/shield-slash.svg",
"shield-tamper": ":/resources/light/shield-tamper.svg",
"app-icon": ":/resources/light/[email protected]",
"app-logo": ":/resources/[email protected]",
}

DARK = {
"checkmark": ":/resources/dark/checkmark.svg",
"usb-connection": ":/resources/dark/usb-connection.svg",
"shield-check": ":/resources/dark/shield-check.svg",
"shield-slash": ":/resources/dark/shield-slash.svg",
"shield-tamper": ":/resources/dark/shield-tamper.svg",
"app-icon": ":/resources/dark/[email protected]",
"app-logo": ":/resources/[email protected]",
}


class CustomDialog(QDialog):
"""
Expand Down Expand Up @@ -399,9 +377,6 @@ class TrayApp:
:ivar resources: The resource paths for icons and images based on
the current theme.
:type resources: dict
:ivar config: The application configuration loaded from the
configuration file.
:type config: configparser.ConfigParser
:ivar start_devices_count: A Counter object to keep track of
initially connected USB devices.
:type start_devices_count: collections.Counter
Expand Down Expand Up @@ -669,7 +644,7 @@ def whitelist_update(self, device_menu, checked):
config_write(self.config)

# Signal the worker, that the whitelist was updated.
self.worker.updated_whitelist()
self.worker.update()

return

Expand All @@ -689,7 +664,7 @@ def whitelist_update(self, device_menu, checked):
config_write(self.config)

# Signal the worker, that the whitelist was updated.
self.worker.updated_whitelist()
self.worker.update()

return

Expand Down
21 changes: 21 additions & 0 deletions src/swiftguard/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,24 @@
re.compile(".+ID\s(?P<id>\w+:\w+)"), # noqa: W605
re.compile("0x([0-9a-z]{4})"),
]

# Resource paths.
LIGHT = {
"checkmark": ":/resources/light/checkmark.svg",
"usb-connection": ":/resources/light/usb-connection.svg",
"shield-check": ":/resources/light/shield-check.svg",
"shield-slash": ":/resources/light/shield-slash.svg",
"shield-tamper": ":/resources/light/shield-tamper.svg",
"app-icon": ":/resources/light/[email protected]",
"app-logo": ":/resources/[email protected]",
}

DARK = {
"checkmark": ":/resources/dark/checkmark.svg",
"usb-connection": ":/resources/dark/usb-connection.svg",
"shield-check": ":/resources/dark/shield-check.svg",
"shield-slash": ":/resources/dark/shield-slash.svg",
"shield-tamper": ":/resources/dark/shield-tamper.svg",
"app-icon": ":/resources/dark/[email protected]",
"app-logo": ":/resources/[email protected]",
}
24 changes: 4 additions & 20 deletions src/swiftguard/utils/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(self, interface):
self.allowed_devices = None

# Updated/load the whitelist.
self.updated_whitelist()
self.update()

def stop(self):
"""
Expand Down Expand Up @@ -113,7 +113,7 @@ def whitelist(self):
f"for right formatting.\nExiting ... \nError: {str(e)}"
)

def updated_whitelist(self):
def update(self):
# Get the allowed devices from config file.
self.allowed_devices = self.whitelist()

Expand Down Expand Up @@ -145,24 +145,8 @@ def loop(self):
:return: None
"""

# Get all connected devices at startup.
if self.interface == "USB":
start_devices = usb_devices()
elif self.interface == "Bluetooth":
start_devices = bt_devices()
else:
raise RuntimeError(f"Unknown interface: {self.interface}.")

# Remove allowed devices from start devices. They are
# allowed to disconnect and connect freely.
if self.allowed_devices:
# Remove allowed devices from start devices.
for device in self.allowed_devices:
if device in start_devices:
start_devices.remove(device)

# Count of each device at startup (minus allowed devices).
self.start_devices_count = Counter(start_devices)
# Get the whitelist and start devices.
self.update()

# Start the main working loop.
LOGGER.info(
Expand Down

0 comments on commit 40eb173

Please sign in to comment.