{ "info": { "author": "Peter Odding", "author_email": "peter@peterodding.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: End Users/Desktop", "Intended Audience :: Information Technology", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Operating System :: Unix", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Desktop Environment" ], "description": "dwim: Location aware application launcher\n=========================================\n\nThe ``dwim`` program is a location aware application launcher. To use it you\nare required to create a profile at ``~/.dwimrc``. This profile is a simple\nPython_ script that defines which applications you want to start automatically,\nin which order the applications should start and whether some applications\nshould only be started when your computer is on a specific physical location.\nThe location awareness works by matching a unique property of the network that\nyour computer is connected to (the `MAC address`_ of your current `network\ngateway`_).\n\nEvery time you run the ``dwim`` program your ``~/.dwimrc`` profile is evaluated\nand your applications are started automatically. If you run ``dwim`` again it\nwill not start duplicate instances of your applications, but when you quit an\napplication and then rerun ``dwim`` the application will be started again.\n\n.. contents::\n :local:\n :depth: 2\n\nInstallation\n------------\n\nThe `dwim` package is available on PyPI_ which means installation should be as\nsimple as:\n\n.. code-block:: sh\n\n $ pip install dwim\n\nThere's actually a multitude of ways to install Python packages (e.g. the `per\nuser site-packages directory`_, `virtual environments`_ or just installing\nsystem wide) and I have no intention of getting into that discussion here, so\nif this intimidates you then read up on your options before returning to these\ninstructions ;-).\n\nUsage\n-----\n\nThere are two ways to use the `dwim` package: As the command line program\n``dwim`` and as a Python API. For details about the Python API please refer to\nthe API documentation available on `Read the Docs`_. The command line interface\nis described below.\n\nPlease note that you need to `create a profile`_ (see below) before you can use\nthe program.\n\nCommand line interface\n~~~~~~~~~~~~~~~~~~~~~~\n\n.. A DRY solution to avoid duplication of the `dwim --help' text:\n..\n.. [[[cog\n.. from humanfriendly.usage import inject_usage\n.. inject_usage('dwim.cli')\n.. ]]]\n\n**Usage:** `dwim [OPTIONS]`\n\nThe dwim program is a location aware application launcher. To use it you are\nrequired to create a profile at ~/.dwimrc. This profile is a simple Python\nscript that defines which applications you want to start automatically, in\nwhich order the applications should start and whether some applications\nshould only be started given a specific physical location.\n\nThe location awareness works by checking the MAC address of your gateway\n(the device on your network that connects you to the outside world, usually\na router) to a set of known MAC addresses that you define in ~/.dwimrc.\n\nEvery time you run the dwim program your ~/.dwimrc profile is evaluated and\nyour applications are started automatically. If you run dwim again it will\nnot start duplicate instances of your applications, but when you quit an\napplication and then rerun dwim the application will be started again.\n\n**Supported options:**\n\n.. csv-table::\n :header: Option, Description\n :widths: 30, 70\n\n\n \"``-c``, ``--config=FILE``\",Override the default location of the profile script.\n \"``-v``, ``--verbose``\",Increase logging verbosity (can be repeated).\n \"``-q``, ``--quiet``\",Decrease logging verbosity (can be repeated).\n \"``-h``, ``--help``\",Show this message and exit.\n\n.. [[[end]]]\n\n.. _create a profile:\n\nCreating a profile\n~~~~~~~~~~~~~~~~~~\n\nTo use ``dwim`` you need to create a profile at ``~/.dwimrc``. The profile is a\nsimple Python_ script that defines which applications you want to start\nautomatically, in which order the applications should start and whether some\napplications should only be started on a specific physical location. The\nprofile script has access to functions provided by the ``dwim`` Python package.\nPlease refer to `the documentation`_ for the available functions. The examples\nbelow show the most useful functions.\n\n.. contents::\n :local:\n\nStarting your first program\n```````````````````````````\n\nIf you'd like to get your feet wet with a simple example, try this:\n\n.. code-block:: python\n\n launch_program('pidgin')\n\nWhen you've created the above profile script and you run the ``dwim`` program\nit will start the Pidgin_ chat client on the first run. On the next run nothing\nwill happen because Pidgin is already running.\n\nModifying the \"is running\" check\n````````````````````````````````\n\nThe default \"is running\" check comes down to the following shell command line:\n\n.. code-block:: bash\n\n # Replace `pidgin' with any program name.\n pidof $(which pidgin)\n\nThis logic will not work for all programs. For example in my profile I start\nthe Dropbox_ client using a wrapper script. Once the Dropbox client has been\nstarted the wrapper script terminates so the ``pidof`` check fails. The\nsolution is to customize the \"is running\" check:\n\n.. code-block:: python\n\n launch_program('dropbox start', is_running='pgrep -f \"$HOME/.dropbox-dist/*/dropbox\"')\n\nThe example above is for the Dropbox client, but the same principle can be\napplied to all other programs. The only trick is to find a shell command that\ncan correctly tell whether the program is running. Unfortunately this part\ncannot be automated in a completely generic manner. The advanced profile\nexample below contains more examples of defining custom ``pidof`` checks and\n``pgrep -f`` checks.\n\nEnabling location awareness\n```````````````````````````\n\nThe first step to enabling location awareness is to add the following line\nto your profile:\n\n.. code-block:: python\n\n determine_network_location()\n\nEven if you don't pass any information to this function it will still report\nyour current gateway's MAC address. This saves me from having to document the\nshell commands needed to do the same thing :-). Run the ``dwim`` command and\ntake note of a line that looks like this:\n\n.. code-block:: text\n\n We're not connected to a known network (unknown gateway MAC address 84:9c:a6:76:23:8e).\n\nNow edit your profile and change the line you just added:\n\n.. code-block:: python\n\n location = determine_network_location(home=['84:9c:a6:76:23:8e'])\n\nWhen you now rerun ``dwim`` it will say:\n\n.. code-block:: text\n\n We're connected to the home network.\n\nSo what did we just do? We took note of the current gateway's MAC address and\nassociated that MAC address with a location named \"home\". In our profile we can\nnow start programs on the condition that we're connected to the home network:\n\n.. code-block:: python\n\n if location == 'home':\n # Client for Music Player Daemon.\n launch_program('ario --minimized')\n else:\n # Standalone music player.\n launch_program('rhythmbox')\n\nThe example profile below (my profile) contains a more advanced example\ncombining multiple networks and networks with multiple gateways.\n\nExample profile\n```````````````\n\nI've been using variants of ``dwim`` (previously in the form of a Bash_ script\n:-) for years now so my profile has grown quite a bit. Because of this it may\nprovide some interesting examples of things you can do:\n\n.. code-block:: python\n\n # vim: fileencoding=utf-8\n\n # ~/.dwimrc: Profile for dwim, my location aware application launcher.\n # For more information please see https://github.com/xolox/python-dwim/.\n\n # Standard library modules.\n import os\n import time\n\n # Packages provided by dwim and its dependencies.\n from executor import execute\n from dwim import (determine_network_location, launch_program, LaunchStatus\n set_random_background, wait_for_internet_connection)\n\n # This is required for graphical Vim and gnome-terminal to have nicely\n # anti-aliased fonts. See http://awesome.naquadah.org/wiki/Autostart.\n if launch_program('gnome-settings-daemon') == LaunchStatus.started:\n\n # When my window manager is initially started I need to wait for a moment\n # before launching user programs because otherwise strange things can\n # happen, for example programs that place an icon in the notification area\n # might be started in the background without adding the icon, so there's\n # no way to access the program but `dwim' will never restart the program\n # because it's already running! \u0ca0_\u0ca0\n logger.debug(\"Sleeping for 10 seconds to give Awesome a moment to initialize ..\")\n time.sleep(10)\n\n # Determine the physical location of this computer by matching the MAC address\n # of the gateway against a set of known MAC addresses. In my own copy I've\n # documented which MAC addresses belong to which devices, but that doesn't seem\n # very relevant for the outside world :-)\n location = determine_network_location(home=['84:9C:A6:76:23:8E'],\n office=['00:15:C5:5F:92:79',\n 'B6:25:B2:19:28:61',\n '00:18:8B:F8:AF:33'])\n\n # Correctly configure my multi-monitor setup based on physical location.\n if location == 'home':\n # At home I use a 24\" ASUS monitor as my primary screen.\n # My MacBook Air sits to the left as the secondary screen.\n execute('xrandr --output eDP1 --auto --noprimary')\n execute('xrandr --output HDMI1 --auto --primary')\n execute('xrandr --output HDMI1 --right-of eDP1')\n if location == 'work':\n # At work I use a 24\" LG monitor as my primary screen.\n # My Asus Zenbook sits to the right as the secondary screen.\n execute('xrandr --output eDP1 --auto')\n execute('xrandr --output HDMI1 --auto')\n execute('xrandr --output HDMI1 --left-of eDP1')\n\n # Set a random desktop background from my collection of wallpapers. I use the\n # program `feh' for this because it supports my desktop environment / window\n # manager (Awesome). You can install `feh' using `sudo apt-get install feh'.\n set_random_background(command='feh --bg-scale {image}',\n directory=os.path.expanduser('~/Pictures/Backgrounds'))\n\n # Start my favorite programs.\n launch_program('gvim')\n launch_program('nm-applet')\n launch_program('keepassx $HOME/Documents/Passwords/Personal.kdb -min -lock',\n is_running='pgrep -f \"keepassx $HOME/Documents/Passwords/Personal.kdb\"')\n # I actually use three encrypted key passes, two of them for work. I omitted\n # those here, but their existence explains the complex is_running command.\n launch_program('fluxgui', is_running='pgrep -f $(which fluxgui)')\n\n # The remaining programs require an active internet connection.\n wait_for_internet_connection()\n\n launch_program('chromium-browser', is_running='pidof /usr/lib/chromium-browser/chromium-browser')\n launch_program('pidgin')\n if location == 'home':\n # Mozilla Thunderbird is only useful at home (at work IMAPS port 993 is blocked).\n launch_program('thunderbird', is_running='pidof /usr/lib/thunderbird/thunderbird')\n launch_program('dropbox start', is_running='pgrep -f \"$HOME/.dropbox-dist/*/dropbox\"')\n launch_program('spotify')\n\nLocation awareness\n------------------\n\nThe location awareness works by matching the `MAC address`_ of your current\n`network gateway`_ (your router). I've previously also used public IPv4\naddresses but given the fact that most consumers will have a dynamic IP address\nI believe the gateway MAC access is the most stable unique property to match.\n\nAbout the name\n--------------\n\nIn programming culture the abbreviation DWIM stands for `Do What I Mean`_. The\nlinked Wikipedia article refers to Interlisp_ but I actually know the term from\nthe world of Perl_. The reason I chose this name for my application launcher is\nbecause I like to make computer systems anticipate what I want. Plugging in a\nnetwork cable, booting my laptop and having all my commonly used programs\n(depending on my physical location) instantly available at startup is a great\nexample of Do What I Mean if you ask me :-)\n\nContact\n-------\n\nThe latest version of `dwim` is available on PyPI_ and GitHub_. The\ndocumentation is hosted on `Read the Docs`_. For bug reports please create an\nissue on GitHub_. If you have questions, suggestions, etc. feel free to send me\nan e-mail at `peter@peterodding.com`_.\n\nLicense\n-------\n\nThis software is licensed under the `MIT license`_.\n\n\u00a9 2017 Peter Odding.\n\n.. External references:\n.. _Bash: http://en.wikipedia.org/wiki/Bash_(Unix_shell)\n.. _Do What I Mean: http://en.wikipedia.org/wiki/DWIM\n.. _Dropbox: http://en.wikipedia.org/wiki/Dropbox_(service)\n.. _GitHub: https://github.com/xolox/python-dwim\n.. _Interlisp: http://en.wikipedia.org/wiki/Interlisp\n.. _MAC address: http://en.wikipedia.org/wiki/MAC_address\n.. _MIT license: http://en.wikipedia.org/wiki/MIT_License\n.. _network gateway: http://en.wikipedia.org/wiki/Gateway_(telecommunications)\n.. _per user site-packages directory: https://www.python.org/dev/peps/pep-0370/\n.. _Perl: http://en.wikipedia.org/wiki/Perl\n.. _peter@peterodding.com: peter@peterodding.com\n.. _Pidgin: http://en.wikipedia.org/wiki/Pidgin_(software)\n.. _PyPI: https://pypi.python.org/pypi/dwim\n.. _Python: http://en.wikipedia.org/wiki/Python_(programming_language)\n.. _Read the Docs: https://dwim.readthedocs.io/en/latest/\n.. _the documentation: https://dwim.readthedocs.io/en/latest/#function-reference\n.. _virtual environments: http://docs.python-guide.org/en/latest/dev/virtualenvs/\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://dwim.readthedocs.io/en/latest/", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "dwim", "package_url": "https://pypi.org/project/dwim/", "platform": "", "project_url": "https://pypi.org/project/dwim/", "project_urls": { "Homepage": "https://dwim.readthedocs.io/en/latest/" }, "release_url": "https://pypi.org/project/dwim/0.3.1/", "requires_dist": [ "coloredlogs (>=0.8)", "executor (>=1.6)", "verboselogs (>=1.0.1)", "flufl.enum (>=4.0.1); python_version == \"2.6\" or python_version == \"2.7\" or python_version == \"3.0\" or python_version == \"3.1\" or python_version == \"3.2\" or python_version == \"3.3\"" ], "requires_python": "", "summary": "Location aware application launcher", "version": "0.3.1" }, "last_serial": 2907584, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "51e48c78524f58bb64ac6802a0b7edd7", "sha256": "b4b0c255da58ade98fedaaaec4084cc6427e2e5dba8773d5153615b4622d4884" }, "downloads": -1, "filename": "dwim-0.1.tar.gz", "has_sig": false, "md5_digest": "51e48c78524f58bb64ac6802a0b7edd7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10470, "upload_time": "2014-10-19T20:49:40", "url": "https://files.pythonhosted.org/packages/4e/e8/4f2f3339d89883931415c0c7dd07abb7cbd972547e2a2045b974ae6f823f/dwim-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "da74a4665e1913e90b0352bdc0f68b17", "sha256": "63dacefa9f0fe9aee0679d3014adaa278bbb2cd8ffc17d42fe50c865a7b24caa" }, "downloads": -1, "filename": "dwim-0.2.tar.gz", "has_sig": false, "md5_digest": "da74a4665e1913e90b0352bdc0f68b17", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10975, "upload_time": "2014-11-01T00:50:39", "url": "https://files.pythonhosted.org/packages/57/92/5327203c2b620e6de6b06e364af8990c4225a402bc2b09602d925b7725a7/dwim-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "1e7c270b4c5c6f9ac53476973e2508f2", "sha256": "3c9f1d102ac4de3ca9f9e04d5a5698b04ddc12a7524ca2a5037dd28d7dac7ca6" }, "downloads": -1, "filename": "dwim-0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1e7c270b4c5c6f9ac53476973e2508f2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 18070, "upload_time": "2017-05-29T21:04:29", "url": "https://files.pythonhosted.org/packages/9f/c1/a91c3acf88aa51d56481304a6727eea7539d6cb4710f98dae8707706630e/dwim-0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d84744dd231e6da088e55aa020059d9c", "sha256": "d3aa3fda17436dab9f5fe0188c672386c63ffbba1ada42731dc0f4f6e71336e7" }, "downloads": -1, "filename": "dwim-0.3.tar.gz", "has_sig": false, "md5_digest": "d84744dd231e6da088e55aa020059d9c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17321, "upload_time": "2017-05-29T21:04:30", "url": "https://files.pythonhosted.org/packages/0e/09/52e8f51c01b5b16d51131e9f0cb4fc1b1d335d75ca24f5d56db921b71e49/dwim-0.3.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "af006c44ba3232cd55b985eda5c8d66b", "sha256": "41b3d93ab52c620cb4a87940a3e6ff7e51af205a1da1513dc19cb3a7a0f56380" }, "downloads": -1, "filename": "dwim-0.3.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "af006c44ba3232cd55b985eda5c8d66b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 18101, "upload_time": "2017-05-29T21:19:22", "url": "https://files.pythonhosted.org/packages/90/f5/9174438f18b0f2347e7ac1709117c40be63ab3808155f6c9afc9f517d86d/dwim-0.3.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8c2e6b05891dbe13d70d92fbc7e3b684", "sha256": "03c03fc434391e4a3edb232e10b579425b97508085f6772c59c5a5f2c8d4e733" }, "downloads": -1, "filename": "dwim-0.3.1.tar.gz", "has_sig": false, "md5_digest": "8c2e6b05891dbe13d70d92fbc7e3b684", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17316, "upload_time": "2017-05-29T21:19:23", "url": "https://files.pythonhosted.org/packages/70/71/b3a67724c3930677a6762fa4becba41435f3277562f14a758b5fb0c0bf9c/dwim-0.3.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "af006c44ba3232cd55b985eda5c8d66b", "sha256": "41b3d93ab52c620cb4a87940a3e6ff7e51af205a1da1513dc19cb3a7a0f56380" }, "downloads": -1, "filename": "dwim-0.3.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "af006c44ba3232cd55b985eda5c8d66b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 18101, "upload_time": "2017-05-29T21:19:22", "url": "https://files.pythonhosted.org/packages/90/f5/9174438f18b0f2347e7ac1709117c40be63ab3808155f6c9afc9f517d86d/dwim-0.3.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8c2e6b05891dbe13d70d92fbc7e3b684", "sha256": "03c03fc434391e4a3edb232e10b579425b97508085f6772c59c5a5f2c8d4e733" }, "downloads": -1, "filename": "dwim-0.3.1.tar.gz", "has_sig": false, "md5_digest": "8c2e6b05891dbe13d70d92fbc7e3b684", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17316, "upload_time": "2017-05-29T21:19:23", "url": "https://files.pythonhosted.org/packages/70/71/b3a67724c3930677a6762fa4becba41435f3277562f14a758b5fb0c0bf9c/dwim-0.3.1.tar.gz" } ] }