6 Commits

Author SHA1 Message Date
Asger Geel Weirsøe
280436f050 fixes setup version v0.1.4 to new file 2020-09-15 14:37:41 +02:00
Asger Geel Weirsøe
7b7d371332 fixes setup to new file 2020-09-15 14:36:28 +02:00
Asger Geel Weirsøe
0a44792155 adds extra monitors to the possible outputs 2020-09-15 14:31:23 +02:00
Asger Geel Weirsøe
2659ec1d9e Automatically deploys to pypi 2020-09-05 13:34:35 +02:00
Asger Geel Weirsøe
d6b8aa7dce updates build script to remove old builds before uploading 2020-09-05 13:05:09 +02:00
Asger Geel Weirsøe
4ae10eb8dd updates build script to remove old builds before uploading 2020-09-05 12:39:58 +02:00
4 changed files with 61 additions and 23 deletions

31
.github/workflows/python-publish.yml vendored Normal file
View File

@@ -0,0 +1,31 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: Upload Python Package
on:
release:
types: [created]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload --repository pypi dist/*

View File

@@ -1,35 +1,32 @@
import argparse import argparse
import subprocess import subprocess
import pathlib
import os
def main(): def main():
parser = argparse.ArgumentParser("Build script for pypi and pypi test") parser = argparse.ArgumentParser("Build script for pypi and pypi test")
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
'--test',
action='store_true',
help='Build to test.pypi.org'
)
group.add_argument(
'--re',
action='store_true',
help='Build to pypi.org'
)
group.add_argument(
'--check',
action='store_true',
help='Displays the twine check for dist'
)
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--test', action='store_true', help='Build to test.pypi.org')
group.add_argument('--pypi', action='store_true', help='Build to pypi.org')
group.add_argument('--check', action='store_true', help='Displays the twine check for dist')
args = parser.parse_args() args = parser.parse_args()
subprocess.call(['python3', 'setup.py', 'sdist', 'bdist_wheel']) for path in pathlib.Path('dist').iterdir():
os.remove(path)
subprocess.call(['python3', 'setup.py', 'sdist', 'bdist_wheel'], stdout=subprocess.PIPE)
if args.test: if args.test:
subprocess.call(['twine', 'upload', '--config-file', '.pypirc', '--repository', 'testpypi', 'dist/*']) subprocess.call(['twine', 'upload', '--config-file', '.pypirc', '--repository', 'testpypi', 'dist/*'])
elif args.re:
elif args.pypi:
subprocess.call(['twine', 'upload', '--config-file', '.pypirc', '--repository', 'pypi', 'dist/*']) subprocess.call(['twine', 'upload', '--config-file', '.pypirc', '--repository', 'pypi', 'dist/*'])
else: else:
subprocess.call(['twine', 'check', 'dist/*']) subprocess.call(['twine', 'check', 'dist/*'])
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@@ -3,6 +3,7 @@ import sys
import pynput import pynput
import re import re
import argparse import argparse
import pprint
class WorkSpacer: class WorkSpacer:
@@ -24,7 +25,7 @@ class WorkSpacer:
self.config = self.i3.get_config().__dict__['config'] self.config = self.i3.get_config().__dict__['config']
config_outputs = {} config_outputs = {}
for matchNo, match in enumerate( for matchNo, match in enumerate(
re.finditer(r'set (\$[a-zA-Z]+) ((HDMI|DP|VGA)-\d)', self.config, re.MULTILINE), start=1 re.finditer(r'set (\$[a-zA-Z]+) ((HDMI|DP|VGA|eDP)(-|)\d)', self.config, re.MULTILINE), start=1
): ):
config_outputs[match.group(1)] = match.group(2) config_outputs[match.group(1)] = match.group(2)
config_workspace_names = {} config_workspace_names = {}
@@ -38,8 +39,11 @@ class WorkSpacer:
if not self.workspaces_on_outputs.keys().__contains__(config_outputs[match.group(2)]): if not self.workspaces_on_outputs.keys().__contains__(config_outputs[match.group(2)]):
self.workspaces_on_outputs[config_outputs[match.group(2)]] = [] self.workspaces_on_outputs[config_outputs[match.group(2)]] = []
self.workspaces_on_outputs[config_outputs[match.group(2)]].append(config_workspace_names[match.group(1)]) self.workspaces_on_outputs[config_outputs[match.group(2)]].append(config_workspace_names[match.group(1)])
self.print_if_debug("All workspaces with outputs")
self.print_if_debug(self.workspaces_on_outputs)
except Exception as exc: except Exception as exc:
self.print_if_debug(exc)
sys.exit(1) sys.exit(1)
self.workspaces = [workspaces for workspaces in self.i3.get_workspaces()] self.workspaces = [workspaces for workspaces in self.i3.get_workspaces()]
outputs = self.i3.get_outputs() outputs = self.i3.get_outputs()
@@ -79,11 +83,17 @@ class WorkSpacer:
def _get_workspaces_for_output(self, output): def _get_workspaces_for_output(self, output):
return [workspace for workspace in self.workspaces if workspace.__dict__['output'] == output] return [workspace for workspace in self.workspaces if workspace.__dict__['output'] == output]
def print_if_debug(self, to_print):
if self.args.debug:
pprint.pprint(to_print)
def main(): def main():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description="Dynamic changes the workspace, based on what output your cursoer is on." description="Dynamic changes the workspace, based on what output your cursoer is on."
) )
parser.add_argument('-d', '--debug', action='store_true',
help='Turn on debug mode.')
required_group = parser.add_argument_group('Required', '') required_group = parser.add_argument_group('Required', '')
required_group.add_argument("-i", "--index", type=int, required=True, required_group.add_argument("-i", "--index", type=int, required=True,
@@ -94,7 +104,7 @@ def main():
help="if present, moves the current active window to target workspace") help="if present, moves the current active window to target workspace")
shift_group.add_argument('-k', '--keep-with-it', action='store_true', shift_group.add_argument('-k', '--keep-with-it', action='store_true',
help='if present, moves with the ') help='if present, moves with the ')
pprint.pprint(parser.parse_args().__dict__)
WorkSpacer(parser.parse_args()).run() WorkSpacer(parser.parse_args()).run()

View File

@@ -4,7 +4,7 @@ with open('README.rst', 'r') as fh:
setup( setup(
name='pi3-smart-workspace', name='pi3-smart-workspace',
version='0.1.2', version='0.1.4',
packages=['pi3'], packages=['pi3'],
url='https://github.com/GeneralDenmark/PyOutputHandler', url='https://github.com/GeneralDenmark/PyOutputHandler',
license='Apache-2.0 License ', license='Apache-2.0 License ',
@@ -23,7 +23,7 @@ setup(
author_email='asger@weirsoe.dk', author_email='asger@weirsoe.dk',
description='Simple program that looks through the i3 config and finds the bound workspaces for each output, and then opening that workspace on the output, that the mouse is currently on.', description='Simple program that looks through the i3 config and finds the bound workspaces for each output, and then opening that workspace on the output, that the mouse is currently on.',
classifiers=[ classifiers=[
"Development Status :: 3 - Alpha", "Development Status :: 4 - Alpha",
"License :: OSI Approved :: Apache Software License", "License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX :: Linux", "Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",