Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Close once finished" feature #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ pip-log.txt

#Mr Developer
.mr.developer.cfg

# temporary developer link dir
temp
6 changes: 6 additions & 0 deletions autoshutdown/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ def power_action(self):
self.os_hibernate()
elif self.config["system_state"] == 'suspend':
self.os_suspend()
elif self.config["system_state"] == 'close':
self.close_app()

def close_app(self):
log.info("[AutoShutDown] Closing Deluge...")
component.get('MainWindow').quit(shutdown=True)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If anyone could add some dialog with a countdown and "cancel" button, it would be nice.


def os_suspend(self):
log.info("[AutoShutDown] Suspending...")
Expand Down
19 changes: 18 additions & 1 deletion autoshutdown/data/config.glade
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@
<property name="position">3</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="button_close">
<property name="label" translatable="yes">Close Deluge</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="border_width">10</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<property name="group">button_shutdown</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="once_check">
<property name="label" translatable="yes">Only once, then Do Nothing</property>
Expand All @@ -99,7 +116,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
<property name="position">5</property>
</packing>
</child>
</widget>
Expand Down
4 changes: 4 additions & 0 deletions autoshutdown/gtkui.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def on_apply_prefs(self):
config["system_state"] = "shutdown"
elif self.glade.get_widget("button_suspend").get_active():
config["system_state"] = "suspend"
elif self.glade.get_widget("button_close").get_active():
config["system_state"] = "close"
if self.glade.get_widget("once_check").get_active():
config["once"] = True
else:
Expand All @@ -89,6 +91,8 @@ def cb_get_config(self, config):
"hibernate" == config["system_state"])
self.glade.get_widget("button_suspend").set_active(
"suspend" == config["system_state"])
self.glade.get_widget("button_close").set_active(
"close" == config["system_state"])
self.glade.get_widget("once_check").set_active(config["once"])
self.glade.get_widget("button_disable").set_active(
not config["enabled"] or not config["system_state"])
Expand Down
28 changes: 24 additions & 4 deletions create_dev_link.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
#!/bin/bash
mkdir temp

cd $(dirname "${0}")

export PYTHONPATH=./temp
python setup.py build develop --install-dir ./temp
cp ./temp/AutoShutdown.egg-link ~/.config/deluge/plugins
rm -fr ./temp

# Linux, BSD and Mac OSX
TARGET_DIR="~/.config/deluge/plugins"

# Windows
if [ ! -z "${APPDATA}" ];
then
TARGET_DIR="${APPDATA}/deluge/plugins"
fi

if [ ! -d "${PYTHONPATH}" ]; then
mkdir ${PYTHONPATH}
fi

find ${PYTHONPATH} -mindepth 1 -delete

python setup.py build develop --install-dir ${PYTHONPATH}

if [ -d "${TARGET_DIR}" ]; then
cp ${PYTHONPATH}/AutoShutdown.egg-link ${TARGET_DIR}
fi
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
__plugin_name__ = "AutoShutdown"
__author__ = "Calum Lind"
__author_email__ = "[email protected]"
__version__ = "1.5.0"
__version__ = "1.5.1"
__url__ = "https://github.com/cas--/autoshutdown/"
__license__ = "GPLv3"
__description__ = "Shutdown your system once torrents are complete"
__description__ = "Shutdown your system or close Deluge once torrents are complete"
__long_description__ = """
A plugin to automatically suspend, hibernate or shutdown your system.
A plugin to automatically suspend, hibernate or shutdown your system (can also close Deluge app).

Works on Linux and Windows but not OS X.
"""
Expand Down