From b2d305371e6697d9d85035911630f094c8e4cd92 Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 15 Jun 2016 11:15:30 +0200 Subject: [PATCH 1/4] Quit function now offer french localization for quit label. --- .../Quit/Quit.xcodeproj/project.pbxproj | 22 ++++++++++++++---- .../Quit/{ => en.lproj}/Localizable.strings | Bin .../Quit/Quit/fr.lproj/Localizable.strings | Bin 0 -> 190 bytes 3 files changed, 18 insertions(+), 4 deletions(-) rename src/Plugins/Quit/Quit/{ => en.lproj}/Localizable.strings (100%) create mode 100644 src/Plugins/Quit/Quit/fr.lproj/Localizable.strings diff --git a/src/Plugins/Quit/Quit.xcodeproj/project.pbxproj b/src/Plugins/Quit/Quit.xcodeproj/project.pbxproj index 4f6276b..f123565 100644 --- a/src/Plugins/Quit/Quit.xcodeproj/project.pbxproj +++ b/src/Plugins/Quit/Quit.xcodeproj/project.pbxproj @@ -8,8 +8,8 @@ /* Begin PBXBuildFile section */ E1AF40571B529AB70017B4DD /* HITPQuit.m in Sources */ = {isa = PBXBuildFile; fileRef = E1AF40561B529AB70017B4DD /* HITPQuit.m */; }; - E1AF405B1B529B3C0017B4DD /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = E1AF405A1B529B3C0017B4DD /* Localizable.strings */; }; E1B2C9191B5947E0005A9936 /* HITDevKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E1B2C9181B5947E0005A9936 /* HITDevKit.framework */; }; + F89297401D11356100E431E2 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = F89297421D11356100E431E2 /* Localizable.strings */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -17,8 +17,9 @@ E1AF40451B529AA10017B4DD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; E1AF40551B529AB70017B4DD /* HITPQuit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HITPQuit.h; sourceTree = ""; }; E1AF40561B529AB70017B4DD /* HITPQuit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HITPQuit.m; sourceTree = ""; }; - E1AF405A1B529B3C0017B4DD /* Localizable.strings */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = ""; }; E1B2C9181B5947E0005A9936 /* HITDevKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = HITDevKit.framework; path = "../../../../../Library/Developer/Xcode/DerivedData/Hello_IT-dblktlmawojysuccadblmqsuewcj/Build/Products/Debug/HITDevKit.framework"; sourceTree = ""; }; + F89297411D11356100E431E2 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; + F89297431D11359800E431E2 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -53,7 +54,7 @@ E1AF40431B529AA10017B4DD /* Quit */ = { isa = PBXGroup; children = ( - E1AF405A1B529B3C0017B4DD /* Localizable.strings */, + F89297421D11356100E431E2 /* Localizable.strings */, E1AF40441B529AA10017B4DD /* Supporting Files */, E1AF40551B529AB70017B4DD /* HITPQuit.h */, E1AF40561B529AB70017B4DD /* HITPQuit.m */, @@ -109,6 +110,7 @@ hasScannedForEncodings = 0; knownRegions = ( en, + fr, ); mainGroup = E1AF40381B529AA10017B4DD; productRefGroup = E1AF40421B529AA10017B4DD /* Products */; @@ -125,7 +127,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - E1AF405B1B529B3C0017B4DD /* Localizable.strings in Resources */, + F89297401D11356100E431E2 /* Localizable.strings in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -142,6 +144,18 @@ }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXVariantGroup section */ + F89297421D11356100E431E2 /* Localizable.strings */ = { + isa = PBXVariantGroup; + children = ( + F89297411D11356100E431E2 /* en */, + F89297431D11359800E431E2 /* fr */, + ); + name = Localizable.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + /* Begin XCBuildConfiguration section */ E1AF40461B529AA10017B4DD /* Debug */ = { isa = XCBuildConfiguration; diff --git a/src/Plugins/Quit/Quit/Localizable.strings b/src/Plugins/Quit/Quit/en.lproj/Localizable.strings similarity index 100% rename from src/Plugins/Quit/Quit/Localizable.strings rename to src/Plugins/Quit/Quit/en.lproj/Localizable.strings diff --git a/src/Plugins/Quit/Quit/fr.lproj/Localizable.strings b/src/Plugins/Quit/Quit/fr.lproj/Localizable.strings new file mode 100644 index 0000000000000000000000000000000000000000..27b5661047e4200b48b1bba42384c175c771bd21 GIT binary patch literal 190 zcmXAjI}XA?3S1tn|t dtk`k%jwKros)bdlXKrT4e`mg;SI?X)7y*MFAj1Fv literal 0 HcmV?d00001 From 0d4cf4b0d51e1635bb00f41a5e47834c7407f51f Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 15 Jun 2016 11:15:56 +0200 Subject: [PATCH 2/4] Updating sample script who show main IP --- .../ScriptedItem/SampleScript/DisplayIP.sh | 40 ------------------- .../com.github.ygini.Hello-IT.DisplayIP.sh | 31 ++++++++++++++ 2 files changed, 31 insertions(+), 40 deletions(-) delete mode 100755 src/Plugins/ScriptedItem/SampleScript/DisplayIP.sh create mode 100755 src/Plugins/ScriptedItem/SampleScript/com.github.ygini.Hello-IT.DisplayIP.sh diff --git a/src/Plugins/ScriptedItem/SampleScript/DisplayIP.sh b/src/Plugins/ScriptedItem/SampleScript/DisplayIP.sh deleted file mode 100755 index 8f9bdd5..0000000 --- a/src/Plugins/ScriptedItem/SampleScript/DisplayIP.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -function updateTitleWithMainIP { - ipFound="no" - globalNetworkState="$3" - - while read line - do - ip=$(networksetup -getinfo "$line" | grep "IP" | grep -v "IPv6" | cut -f2- -d ':' | xargs) - if [ -n "$ip" ] - then - if [[ "$ip" != "169.254.*" ]] - then - echo "hitp-title: $ip" - echo "hitp-state: ok" - echo "hitp-tooltip: Having an IP address don't mean you've Internet access" - ipFound="yes" - break - fi - fi - done < <(networksetup -listnetworkserviceorder | grep "(\d)" | cut -f2- -d ' ') - - if [[ "$ipFound" == "no" ]] - then - echo "hitp-title: No IP Address" - if [[ "$globalNetworkState" == "1" ]] - then - echo "hitp-state: error" - echo "hitp-tooltip: Please, check your Ethernet or WiFi connection" - else - echo "hitp-state: unavailable" - echo "hitp-tooltip: No network connection available" - fi - fi -} -echo "hitp-enabled: NO" -updateTitleWithMainIP -echo "hitp-enabled: YES" - -exit 0 diff --git a/src/Plugins/ScriptedItem/SampleScript/com.github.ygini.Hello-IT.DisplayIP.sh b/src/Plugins/ScriptedItem/SampleScript/com.github.ygini.Hello-IT.DisplayIP.sh new file mode 100755 index 0000000..ca1ea04 --- /dev/null +++ b/src/Plugins/ScriptedItem/SampleScript/com.github.ygini.Hello-IT.DisplayIP.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +function updateTitleWithMainIP { + ipAddress="" + globalNetworkState="$3" + + mainBSDInterface=$(route -n get 8.8.8.8 | grep "interface: " | awk -F ": " '{print $2}') + ipAddress=$(ifconfig "$mainBSDInterface" | grep "inet " | sed "s/.*inet \([0-9.]*\).*/\1/" | head -n1) + + if [ -z "$ipAddress" ] + then + echo "hitp-title: No IP Address" + if [[ "$globalNetworkState" == "1" ]] + then + echo "hitp-state: error" + echo "hitp-tooltip: Please, check your Ethernet or WiFi connection" + else + echo "hitp-state: unavailable" + echo "hitp-tooltip: No network connection available" + fi + else + echo "hitp-title: $ipAddress" + echo "hitp-state: ok" + echo "hitp-tooltip: Having an IP address doesn't mean you've Internet access" + fi +} +echo "hitp-enabled: NO" +updateTitleWithMainIP +echo "hitp-enabled: YES" + +exit 0 From 622a602a36ebfc52ae90cf19391f45afcc6250fa Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 15 Jun 2016 11:16:40 +0200 Subject: [PATCH 3/4] Updating script function to support pathless script setup using only script name and /Library/Application Support/com.github.ygini.hello-it/CustomScripts location --- package/Hello IT.pkgproj | 35 ++++++++++++++++++- src/Hello IT/AppDelegate.m | 6 ++++ src/Hello IT/Info.plist | 4 +-- .../ScriptedItem/HITPScriptedItem.m | 9 +++-- 4 files changed, 49 insertions(+), 5 deletions(-) diff --git a/package/Hello IT.pkgproj b/package/Hello IT.pkgproj index 45d0b24..354f455 100755 --- a/package/Hello IT.pkgproj +++ b/package/Hello IT.pkgproj @@ -87,6 +87,39 @@ UID 0 + + CHILDREN + + + CHILDREN + + GID + 80 + PATH + ../src/Plugins/ScriptedItem/SampleScript/com.github.ygini.Hello-IT.DisplayIP.sh + PATH_TYPE + 1 + PERMISSIONS + 493 + TYPE + 3 + UID + 0 + + + GID + 80 + PATH + CustomScripts + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 2 + UID + 0 + CHILDREN @@ -577,7 +610,7 @@ RELOCATABLE VERSION - 1.2.1 + 1.2.2 PROJECT_COMMENTS diff --git a/src/Hello IT/AppDelegate.m b/src/Hello IT/AppDelegate.m index ae8de2b..5b10705 100644 --- a/src/Hello IT/AppDelegate.m +++ b/src/Hello IT/AppDelegate.m @@ -70,6 +70,12 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { @"URL": @"https://github.com/ygini/Hello-IT/wiki/Preferences" } }, + @{@"functionIdentifier": @"public.script.item", + @"settings": @{ + @"script": @"com.github.ygini.Hello-IT.DisplayIP.sh", + @"skipForGlobalState": @YES + } + }, @{@"functionIdentifier": @"public.separator"}, @{@"functionIdentifier": @"public.quit"} ] diff --git a/src/Hello IT/Info.plist b/src/Hello IT/Info.plist index 9d21545..a79954f 100644 --- a/src/Hello IT/Info.plist +++ b/src/Hello IT/Info.plist @@ -17,11 +17,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.2.1 + 1.2.2 CFBundleSignature ???? CFBundleVersion - 94 + 95 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) LSUIElement diff --git a/src/Plugins/ScriptedItem/ScriptedItem/HITPScriptedItem.m b/src/Plugins/ScriptedItem/ScriptedItem/HITPScriptedItem.m index f269515..c11cdf0 100644 --- a/src/Plugins/ScriptedItem/ScriptedItem/HITPScriptedItem.m +++ b/src/Plugins/ScriptedItem/ScriptedItem/HITPScriptedItem.m @@ -9,7 +9,8 @@ #import "HITPScriptedItem.h" -#define kHITPSubCommandScript @"path" +#define kHITPSubCommandScriptPath @"path" +#define kHITPSubCommandScriptName @"script" #define kHITPSubCommandOptions @"options" #define kHITPSubCommandArgs @"args" #define kHITPSubCommandNetworkRelated @"network" @@ -31,7 +32,11 @@ - (instancetype)initWithSettings:(NSDictionary*)settings { self = [super initWithSettings:settings]; if (self) { - _script = [[settings objectForKey:kHITPSubCommandScript] stringByExpandingTildeInPath]; + _script = [[settings objectForKey:kHITPSubCommandScriptPath] stringByExpandingTildeInPath]; + + if ([_script length] == 0) { + _script = [[NSString stringWithFormat:@"/Library/Application Support/com.github.ygini.hello-it/CustomScripts"] stringByAppendingPathComponent:[settings objectForKey:kHITPSubCommandScriptName]]; + } asl_log(NULL, NULL, ASL_LEVEL_INFO, "Loading script based plugin with script at path %s", [_script cStringUsingEncoding:NSUTF8StringEncoding]); From 44a780d2493c3e791f76215f2dca6c333f8818c3 Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 15 Jun 2016 11:19:57 +0200 Subject: [PATCH 4/4] Release build number for 1.2.2 --- src/Hello IT/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hello IT/Info.plist b/src/Hello IT/Info.plist index a79954f..c67234f 100644 --- a/src/Hello IT/Info.plist +++ b/src/Hello IT/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 95 + 98 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) LSUIElement