Skip to content

Commit

Permalink
Merge branch 'dev' into gui-shutdown-trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
maltfield committed Jun 12, 2023
2 parents c965cab + 5b6f3cb commit 35b6126
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ jobs:
ls -lah
RELEASE_FILE="`ls -1 | grep buskill-win*.zip | head -n1`"
echo ${RELEASE_FILE}
curl --location --header "authorization: token ${GITHUB_TOKEN}" --header "Content-Type: application/zlib" --data-binary "@${RELEASE_FILE}" "https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${RELEASE_FILE}"
curl --verbose --location --http1.1 --header "authorization: token ${GITHUB_TOKEN}" --header "Content-Type: application/zlib" --data-binary "@${RELEASE_FILE}" "https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${RELEASE_FILE}"
shell: bash

- name: Trigger cryptographic signature workflow
env:
BUSKILL_BOT_DISPATCH_TOKEN: ${{ secrets.BUSKILL_BOT_DISPATCH_TOKEN }}
run: |
curl -i --header "Authorization: Bearer ${BUSKILL_BOT_DISPATCH_TOKEN}" -d '{"event_type":"sign_release", "client_payload": {"release_id":"${{ steps.create_release.outputs.id }}"}}' https://api.github.com/repos/${GITHUB_REPOSITORY}/dispatches
curl --verbose -i --header "Authorization: Bearer ${BUSKILL_BOT_DISPATCH_TOKEN}" -d '{"event_type":"sign_release", "client_payload": {"release_id":"${{ steps.create_release.outputs.id }}"}}' https://api.github.com/repos/${GITHUB_REPOSITORY}/dispatches
shell: bash

mac:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This is the codebase for our cross-platform (CLI and) GUI app for [BusKill](http

# What is BusKill?

The quickest way to understand what BusKill is to watch our 2-minute [BusKill Explainer Video](https://buskill.in/#demo).

| <a href="https://www.buskill.in/#demo"><img src="docs/images/buskill_explainer_video_20211210.gif?raw=true" alt="What is BusKill? (Explainer Video)"></a> |
|:--:|
| *Watch the <a href="https://www.buskill.in/#demo">BusKill Explainer Video</a> for more info <a href="https://www.youtube.com/v/qPwyoD_cQR4">youtube.com/v/qPwyoD_cQR4</a>* |
Expand Down
20 changes: 17 additions & 3 deletions build/mac/buildDmg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ ${PIP_PATH} download python-gnupg
${PYTHON_PATH} -m pip download python-gnupg
filename="`ls -1 | head -n1`"
signature_url=`curl -s https://pypi.org/simple/python-gnupg/ | grep -oE "https://.*${filename}#" | sed 's/#/.asc/'`
wget "${signature_url}"
#wget "${signature_url}"
# switching from wget to curl to avoid "dyld Library not loaded" brew issues
# * https://github.com/BusKill/buskill-app/issues/70
curl --remote-name "${signature_url}"

mkdir gnupg
chmod 0700 gnupg
Expand All @@ -215,7 +218,10 @@ pushd "${tmpDir}"
${PIP_PATH} download libusb1
filename="`ls -1 | head -n1`"
signature_url=`curl -s https://pypi.org/simple/libusb1/ | grep -oE "https://.*${filename}#" | sed 's/#/.asc/'`
wget "${signature_url}"
#wget "${signature_url}"
# switching from wget to curl to avoid "dyld Library not loaded" brew issues
# * https://github.com/BusKill/buskill-app/issues/70
curl --remote-name "${signature_url}"

mkdir gnupg
chmod 0700 gnupg
Expand Down Expand Up @@ -304,11 +310,19 @@ a = Analysis(['../src/main.py'],
binaries=[],
datas=[
( '../KEYS', '.' ),
# needed for the taskbar icon when the app is running (kivy)
('../src/images/buskill-icon-150.png', '.'),
# needed for the icon of the .app when viewed in Finder
('buskill-icon.icns', '.'),
('/usr/local/bin/gpg', '.')
# needed for gpg https://github.com/BusKill/buskill-app/issues/71
('/usr/local/bin/gpg', '.'),
('/usr/local/lib/libgcrypt.20.dylib', '.'),
('/usr/local/lib/libassuan.0.dylib', '.'),
('/usr/local/lib/libnpth.0.dylib', '.'),
('/usr/local/lib/libgpg-error.0.dylib', '.')
],
hiddenimports=['pkg_resources.py2_warn'],
hookspath=[],
Expand Down
6 changes: 5 additions & 1 deletion build/usb/usbDrive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,15 @@ P7Z="`which 7z`"
#RAR=`which rar`"
TAR="`which tar`"


###################################
# DOWNLOAD LATEST STABLE RELEASES #
###################################

# prevent "detected dubious ownership in repository" error
pwd
git config --global --add safe.directory .
git config --global --add safe.directory /root/buskill-app

# get the latest version tag
latest_version=`git tag | grep -iE '^v[0-9]*\.[0-9]*' | tail -n1`

Expand Down
7 changes: 6 additions & 1 deletion docs/attribution.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,10 @@ The reader may be interested to investigate the following similar projects:
* `s53 <https://github.com/BrassHornCommunications/s53>`_
* `swatd <https://github.com/defuse/swatd>`_
* `Centry <https://github.com/0xPoly/Centry>`_
* `PanicKit <https://guardianproject.info/code/panickit/>`_ & `Ripple <https://guardianproject.info/apps/info.guardianproject.ripple/>`_
* `Duress <https://github.com/x13a/Duress>`_
* `xxUSBSentinel <https://github.com/thereisnotime/xxUSBSentinel>`_
* `Ripple <https://guardianproject.info/apps/info.guardianproject.ripple/>`_
* `lockup <https://github.com/levlesec/lockup>`_
* `pam_duress <https://github.com/rafket/pam_duress>`_
* `pam_panic <https://github.com/pampanic/pam_panic>`_
* `pam_party <https://github.com/x13a/pam-party>`_
21 changes: 20 additions & 1 deletion docs/hardware_dev/bom.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,24 @@ If your device has USB type C ports and no USB type A ports, you can make a BusK

Grand Total: ~$65

TODO: picture
.. figure:: /images/buskill_cable_usb_c.jpg
:height: 300px
:alt: image of the BusKill USB-C cable
:align: center

A custom-made USB-C BusKill cable. Source: `neilzone.co.uk <https://neilzone.co.uk/2022/01/implementing-buskill-shutting-down-a-debian-11-bullseye-machine-when-a-specific-usb-device-is-removed>`_

USB-C Hybrid
------------

If your device only has USB-C ports, but you want to use the cheaper USB-A cable, you can build the USB-A cable above and just buy a `USB-C to USB-A Hub for about $10 <usbchub_>`_.

.. figure:: /images/buskill_usb_c_hub.jpg
:height: 300px
:alt: image of a USB-C to USB-A hub
:align: center

A `$10 USB-C Hub <usbchub_>`_ can unlock the USB-A BusKill cable on a device with only USB-C ports

.. note:: While the BusKill cable has an open-source design, some of the individual components used to build the BusKill cable do not have open-source designs.

Expand Down Expand Up @@ -81,3 +98,5 @@ TODO: picture
https://www.amazon.com/gp/product/B07MCS2WWC/ref=as_li_tl?ie=UTF8&tag=docsbuskill-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=B07MCS2WWC&linkId=20164822af30ec0d4b7b33dc454e0e78 https://docs.buskill.in/buskill-app/en/stable/hardware_dev/bom.html usbcmagneticbreakaway1

https://www.amazon.com/gp/product/B07KR5PP91/ref=as_li_tl?ie=UTF8&tag=docsbuskill-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=B07KR5PP91&linkId=8e9238d9f13cba94a6a5ec3073f28d2c https://docs.buskill.in/buskill-app/en/stable/hardware_dev/bom.html usbc3mextension1

https://www.amazon.com/gp/product/B09535D89X/?&_encoding=UTF8&tag=docsbuskill-20&linkCode=ur2&linkId=133b43e848d180a4a7e88720b02ee0dc&camp=1789&creative=9325 https://docs.buskill.in/buskill-app/en/stable/hardware_dev/bom.html usbchub
Binary file added docs/images/buskill_cable_usb_c.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/buskill_usb_c_hub.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion docs/software_usr/requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ You can help the BusKill project by testing the BusKill app on other platforms a
+------------+-----------------------------------+-------------------------------------------------------+
| MacOS | 10.15 (Catalina) | Supported |
+------------+-----------------------------------+-------------------------------------------------------+
| MacOS | 12.6.5 (Monterey) | Supported |
+------------+-----------------------------------+-------------------------------------------------------+
| MacOS | 13.4 (Ventura) | Supported |
+------------+-----------------------------------+-------------------------------------------------------+
| Linux | Ubuntu 20.04 LTS (Focal Fossa) | Supported |
+------------+-----------------------------------+-------------------------------------------------------+
| Linux | Ubuntu 18.04 LTS (Bionic) | Supported |
| Linux | Ubuntu 18.04 LTS (Bionic) | Supported |
+------------+-----------------------------------+-------------------------------------------------------+
46 changes: 44 additions & 2 deletions src/packages/buskill/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,9 @@ def hotplugCallbackNix( self, *argv ):
msg = "event:|" +str(event)+ "|"
print( msg ); logger.debug( msg )

msg = "usb1.HOTPLUG_EVENT_DEVICE_ARRIVED:|" +str(usb1.HOTPLUG_EVENT_DEVICE_ARRIVED)+ "|"
print( msg ); logger.debug( msg )

msg = "usb1.HOTPLUG_EVENT_DEVICE_LEFT:|" +str(usb1.HOTPLUG_EVENT_DEVICE_LEFT)+ "|"
print( msg ); logger.debug( msg )

Expand Down Expand Up @@ -1064,6 +1067,12 @@ def trigger_lockscreen_lin(self):
# first we try to lock with xdg-screensaver
self.trigger_lockscreen_lin_xdg()

# in Cinnamon (Linux Mint) `xdg-screensaver` exists, exits zero, doesn't
# throw any errors, and doesn't lock the screen.
# * https://en.wikipedia.org/wiki/Cinnamon_(desktop_environment)
# * https://github.com/BusKill/buskill-app/issues/64
self.trigger_lockscreen_lin_cinnamon()

# this function will gently shutdown a Linux machine
def trigger_softshutdown_lin(self):
msg = "DEBUG: BusKill soft-shutdown trigger executing now"
Expand Down Expand Up @@ -1121,15 +1130,48 @@ def trigger_lockscreen_lin_xscreensaver(self):
print( msg ); logger.debug( msg )

if result.returncode != 0:
# that didn't work; log it and give up :(
# that didn't work; log it and try fallback
msg = "ERROR: Failed to execute `xscreensaver -lock`! "
print( msg ); logger.error(msg)

except Exception as e:
# that didn't work; log it and give up :(
# that didn't work; log it and try fallback
msg = "ERROR: Failed to execute `xscreensaver -lock`! " +str(e)
print( msg ); logger.error(msg)

def trigger_lockscreen_lin_cinnamon(self):

try:
# unset PYTHONHOME to fix AppImage fs encoding error
# ModuleNotFoundError: No module named 'encodings'
# * https://github.com/BusKill/buskill-app/issues/64#issuecomment-1537221491
if 'PYTHONHOME' in os.environ:
del os.environ['PYTHONHOME']

# try to lock the screen with cinnamon-screensaver command
msg = "INFO: Attempting to execute `cinnamon-screensaver-command --lock`"
print( msg ); logger.debug( msg )
result = subprocess.run( ['cinnamon-screensaver-command', '--lock'], capture_output=True, text=True )

msg = "DEBUG: subprocess returncode|" +str(result.returncode)+ "|"
print( msg ); logger.debug( msg )

msg = "DEBUG: subprocess stdout|" +str(result.stdout)+ "|"
print( msg ); logger.debug( msg )

msg = "DEBUG: subprocess stderr|" +str(result.stderr)+ "|"
print( msg ); logger.debug( msg )

if result.returncode != 0:
# that didn't work; log it and give up :(
msg = "ERROR: Failed to execute `cinnamon-screensaver-command --lock`! "
print( msg ); logger.error(msg)

except Exception as e:
# that didn't work; log it and give up :(
msg = "ERROR: Failed to execute `cinnamon-screensaver-command --lock`! " +str(e)
print( msg ); logger.error(msg)

def trigger_softshutdown_lin_shutdown(self):

try:
Expand Down

0 comments on commit 35b6126

Please sign in to comment.