From 985b56606517971330c08686c49a8d06db763f3c Mon Sep 17 00:00:00 2001 From: nik gaffney Date: Tue, 30 May 2023 10:59:12 +0200 Subject: [PATCH] Go slowly all the way round the outside --- .github/workflows/melpazoid-quiet.yml | 30 ++++++++++++++++++++++ quiet.el | 37 +++++++++++++++++---------- 2 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/melpazoid-quiet.yml diff --git a/.github/workflows/melpazoid-quiet.yml b/.github/workflows/melpazoid-quiet.yml new file mode 100644 index 0000000..08b309e --- /dev/null +++ b/.github/workflows/melpazoid-quiet.yml @@ -0,0 +1,30 @@ +# melpazoid build checks. + +# for quiet package + +name: melpazoid-quiet +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Install + run: | + python -m pip install --upgrade pip + sudo apt-get install emacs && emacs --version + git clone https://github.com/riscy/melpazoid.git ~/melpazoid + pip install ~/melpazoid + - name: Run + env: + LOCAL_REPO: ${{ github.workspace }} + # RECIPE is your recipe as written for MELPA: + RECIPE: (quiet :repo "zzkt/quiet" :fetcher github) + # set this to false (or remove it) if the package isn't on MELPA: + EXIST_OK: true + run: echo $GITHUB_REF && make -C ~/melpazoid diff --git a/quiet.el b/quiet.el index f678d96..4e73ac9 100644 --- a/quiet.el +++ b/quiet.el @@ -45,20 +45,27 @@ ;;; Code: -(defcustom quiet-disconnect "networksetup -setairportpower airport off" +(defcustom quiet-disconnect "networksetup -setairportpower airport off" "Shell command to turn off network connection(s)." - :type 'string - :options '("networksetup -setairportpower airport off" "ifdown wlan0") + :type '(choice + (string :tag "macOS" "networksetup -setairportpower airport off") + (string :tag "GNU/Linux" "ifdown wlan0") + (string :tag "*BSD" "ifdown wlan0") + (string :tag "other" "")) :group 'quiet) -(defcustom quiet-connect "networksetup -setairportpower airport on" +(defcustom quiet-connect "networksetup -setairportpower airport on" "Shell command to turn on network connection(s)." - :type 'string - :options '("networksetup -setairportpower airport off" "ifup wlan0") - :group 'quiet) + :type '(choice + (string :tag "macOS" "networksetup -setairportpower airport on") + (string :tag "GNU/Linux" "ifup wlan0") + (string :tag "*BSD" "ifup wlan0") + (string :tag "other" "")) + :group 'quiet) -(defcustom quiet-timer 0 - "Timer to reconnect network after a given time (in minutes). A value of 0 will leave the connection off." +(defcustom quiet-timer 0 + "Timer to reconnect network after a given time (in minutes). +A value of 0 will leave the connection off." :type 'integer :group 'quiet) @@ -67,11 +74,11 @@ "Quieten network distractions for a while..." (interactive) (save-window-excursion - (message "disconnecting...") - (async-shell-command quiet-disconnect)) + (message "disconnecting...") + (async-shell-command quiet-disconnect)) (if (not (= quiet-timer 0)) (progn - (run-at-time (* quiet-timer 60) nil 'quiet-reconnect)))) + (run-at-time (* quiet-timer 60) nil 'quiet-reconnect)))) ;; provide a 'disconnect' alias (fset 'disconnect 'quiet) @@ -81,8 +88,10 @@ "Reconnect to networked distractions." (interactive) (save-window-excursion - (message "reconnecting after ~%d %s" quiet-timer (if (= quiet-timer 1) "minute" "minutes")) - (async-shell-command quiet-connect))) + (message "reconnecting after ~%d %s" + quiet-timer + (if (= quiet-timer 1) "minute" "minutes")) + (async-shell-command quiet-connect))) (provide 'quiet)