From 28e1b38710817e544a8795bd0cf2793492db670a Mon Sep 17 00:00:00 2001 From: Don Harper Date: Thu, 3 Jun 2021 20:02:08 -0500 Subject: [PATCH 1/3] Switched to getopt from getopts, added usage, added long arguments --- styli.sh | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/styli.sh b/styli.sh index 6b67294..a6d2f3f 100755 --- a/styli.sh +++ b/styli.sh @@ -40,18 +40,36 @@ reddit(){ wget -T $timeout -U "$useragent" --no-check-certificate -q -P down -O "wallpaper.jpg" $target_url &>/dev/null } +usage(){ + echo "Usage: styli.sh [-s | --search ] + [-h | --hight ] + [-w | --width ] + [-b | --fehbg ] + [-c | --fehopt ] + [-r | --subreddit ] + [-l | --link ] + [-p | --termcolor]" + exit 2 +} pywal=0 -while getopts h:w:s:l:b:r:c:p flag +PARSED_ARGUMENTS=$(getopt -a -n $0 -o h:w:s:l:b:r:c:p --long search:,hight:,width:,fehbg:,fehopt:,subreddit:,termcolor -- "$@") +VALID_ARGUMENTS=$? +if [ "$VALID_ARGUMENTS" != "0" ]; then + usage +fi +while : do - case "${flag}" in - b) bgtype=${OPTARG};; - s) search=${OPTARG};; - h) height=${OPTARG};; - w) width=${OPTARG};; - l) link=${OPTARG};; - r) sub=${OPTARG};; - c) custom=${OPTARG};; - p) pywal=1;; + case "${1}" in + -b | --fehbg) bgtype=${2} ; shift 2 ;; + -s | --search) search=${2} ; shift 2 ;; + -h | --height) height=${2} ; shift 2 ;; + -w | --width) width=${2} ; shift 2 ;; + -l | --link) link=${2} ; shift 2 ;; + -r | --subreddit) sub=${2} ; shift 2 ;; + -c | --fehopt) custom=${2} ; shift 2 ;; + -p | --termcolor) pywal=1 ; shift ;; + -- | '') shift; break ;; + *) echo "Unexpected option: $1 - this should not happen." ; usage ;; esac done feh=(feh) From c2ca9a1aadb1aee178ab5d4518319207c437075d Mon Sep 17 00:00:00 2001 From: Creator54 Date: Fri, 4 Jun 2021 07:31:13 +0530 Subject: [PATCH 2/3] make script portable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit not all distros have /bin/bash in there $PATH ```NixOS``` 😅 --- styli.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styli.sh b/styli.sh index 6b67294..746b711 100755 --- a/styli.sh +++ b/styli.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash link="https://source.unsplash.com/random/" reddit(){ useragent="thevinter" From 6f5ba2fbf94366324b25b4c1cb134d59af83c0ca Mon Sep 17 00:00:00 2001 From: Nikita Brancatisano <33670112+thevinter@users.noreply.github.com> Date: Fri, 4 Jun 2021 07:34:10 +0200 Subject: [PATCH 3/3] Licence added MIT licence --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6361155 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Nikita Brancatisano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.