From 1d9eacb34f59f3bf82a9de0d7b474cb4c501e3fd Mon Sep 17 00:00:00 2001 From: Paul Gideon Dann Date: Thu, 19 May 2011 10:55:19 +0100 Subject: [PATCH 1/5] Plugin to make WOL nice & easy --- plugins/wakeonlan/wakeonlan.plugin.zsh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 plugins/wakeonlan/wakeonlan.plugin.zsh diff --git a/plugins/wakeonlan/wakeonlan.plugin.zsh b/plugins/wakeonlan/wakeonlan.plugin.zsh new file mode 100644 index 000000000..08db1bdea --- /dev/null +++ b/plugins/wakeonlan/wakeonlan.plugin.zsh @@ -0,0 +1,15 @@ +function wake() { + local config_file=~/.wakeonlan/$1 + if [[ ! -f $config_file ]]; then + echo "ERROR: There is no configuration file at \"$config_file\"." + return + fi + + which wakeonlan > /dev/null + if [[ ! $? == 0 ]]; then + echo "ERROR: Can't find \"wakeonlan\". Are you sure it's installed?" + return + fi + + wakeonlan -f $config_file +} From 14411cb904b7682fe2a5c69861bfffa96f124707 Mon Sep 17 00:00:00 2001 From: Paul Gideon Dann Date: Mon, 19 Sep 2011 12:40:29 +0100 Subject: [PATCH 2/5] Tweaks to the wakeonlan plugin These were suggested by sorin-ionescu in pull request #343. --- plugins/wakeonlan/wakeonlan.plugin.zsh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/wakeonlan/wakeonlan.plugin.zsh b/plugins/wakeonlan/wakeonlan.plugin.zsh index 08db1bdea..752bfc600 100644 --- a/plugins/wakeonlan/wakeonlan.plugin.zsh +++ b/plugins/wakeonlan/wakeonlan.plugin.zsh @@ -1,15 +1,18 @@ function wake() { - local config_file=~/.wakeonlan/$1 - if [[ ! -f $config_file ]]; then + local config_file="$HOME/.wakeonlan/$1" + if [[ ! -f "$config_file" ]]; then echo "ERROR: There is no configuration file at \"$config_file\"." - return + return 1 fi - which wakeonlan > /dev/null - if [[ ! $? == 0 ]]; then + if (( ! $+commands[wakeonlan] )); then echo "ERROR: Can't find \"wakeonlan\". Are you sure it's installed?" - return + return 1 fi wakeonlan -f $config_file } + +if (( $+functions[compdef] )); then + compdef "_arguments '1:device to wake:_files -W '\''$HOME/.wakeonlan'\'''" wake +fi From aa7ddd51cc4bd6afca23760ba3e3cc777305b1da Mon Sep 17 00:00:00 2001 From: Paul Gideon Dann Date: Mon, 19 Sep 2011 12:45:34 +0100 Subject: [PATCH 3/5] Forgot to quote the path parameter to wakeonlan --- plugins/wakeonlan/wakeonlan.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/wakeonlan/wakeonlan.plugin.zsh b/plugins/wakeonlan/wakeonlan.plugin.zsh index 752bfc600..8406b8f7d 100644 --- a/plugins/wakeonlan/wakeonlan.plugin.zsh +++ b/plugins/wakeonlan/wakeonlan.plugin.zsh @@ -10,7 +10,7 @@ function wake() { return 1 fi - wakeonlan -f $config_file + wakeonlan -f "$config_file" } if (( $+functions[compdef] )); then From e94039d62b04e61507cbaa57c5fa955d97c8eca9 Mon Sep 17 00:00:00 2001 From: Paul Gideon Dann Date: Mon, 19 Sep 2011 15:42:58 +0100 Subject: [PATCH 4/5] Splitting wakeonlan plugin completion into separate file --- plugins/wakeonlan/_wake | 4 ++++ plugins/wakeonlan/wakeonlan.plugin.zsh | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 plugins/wakeonlan/_wake diff --git a/plugins/wakeonlan/_wake b/plugins/wakeonlan/_wake new file mode 100644 index 000000000..4ab10d374 --- /dev/null +++ b/plugins/wakeonlan/_wake @@ -0,0 +1,4 @@ +#compdef wake +#autoload + +_arguments "1:device to wake:_files -W '$HOME/.wakeonlan'" && return 0 diff --git a/plugins/wakeonlan/wakeonlan.plugin.zsh b/plugins/wakeonlan/wakeonlan.plugin.zsh index 8406b8f7d..6cef7d44a 100644 --- a/plugins/wakeonlan/wakeonlan.plugin.zsh +++ b/plugins/wakeonlan/wakeonlan.plugin.zsh @@ -12,7 +12,3 @@ function wake() { wakeonlan -f "$config_file" } - -if (( $+functions[compdef] )); then - compdef "_arguments '1:device to wake:_files -W '\''$HOME/.wakeonlan'\'''" wake -fi From 7ba54d197dac8d5ae380271259ba4d8843f01b4f Mon Sep 17 00:00:00 2001 From: Paul Gideon Dann Date: Tue, 20 Sep 2011 09:26:32 +0100 Subject: [PATCH 5/5] Adding README file for the wakeonlan plugin --- plugins/wakeonlan/README | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 plugins/wakeonlan/README diff --git a/plugins/wakeonlan/README b/plugins/wakeonlan/README new file mode 100644 index 000000000..16fdd4587 --- /dev/null +++ b/plugins/wakeonlan/README @@ -0,0 +1,29 @@ +This plugin provides a wrapper around the "wakeonlan" tool available from most +distributions' package repositories, or from the following website: + +http://gsd.di.uminho.pt/jpo/software/wakeonlan/ + +In order to use this wrapper, create the ~/.wakeonlan directory, and place in +that directory one file for each device you would like to be able to wake. Give +the file a name that describes the device, such as its hostname. Each file +should contain a line with the mac address of the target device and the network +broadcast address. + +For instance, there might be a file ~/.wakeonlan/leto with the following +contents: + +00:11:22:33:44:55:66 192.168.0.255 + +To wake that device, use the following command: + +# wake leto + +The available device names will be autocompleted, so: + +# wake + +...will suggest "leto", along with any other configuration files that were +placed in the ~/.wakeonlan directory. + +For more information regarding the configuration file format, check the +wakeonlan man page.