Skip to content

Commit

Permalink
Final release
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrek committed Apr 6, 2018
1 parent de3adad commit 12652c4
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 18 deletions.
Binary file removed .DS_Store
Binary file not shown.
Binary file not shown.
Binary file added AppCycler.zip
Binary file not shown.
Binary file removed AppCycler/.DS_Store
Binary file not shown.
49 changes: 38 additions & 11 deletions AppCycler/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
var appsToBeCycled = [[String]]()
var running = NSWorkspace.shared.runningApplications.filter{ $0.activationPolicy == .regular}.sorted{ $0.localizedName! < $1.localizedName!}


@IBOutlet weak var interval: NSTextFieldCell!

@IBOutlet weak var refreshList: NSButton!
@IBOutlet weak var app1: NSTextField!
@IBOutlet weak var app2: NSTextField!
@IBOutlet weak var app3: NSTextField!
Expand Down Expand Up @@ -73,16 +75,17 @@ class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var cycleButton: NSButton!

func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application

refreshApps((Any).self)
cycleButton.isEnabled = false
// NSLog(orderApp1.titleOfSelectedItem!)

}

func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}

func textFieldEditingDidChange() {

}

@IBAction func refreshApps(_ sender: Any) {
cycleButton.isEnabled = false
Expand Down Expand Up @@ -185,9 +188,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

}

// Check if any apps is chosen and timer is not blank
@IBAction func enableCycyleButton(_ sender: Any) {
if (orderApp1.titleOfSelectedItem == "-") &&
if ((orderApp1.titleOfSelectedItem == "-") &&
(orderApp2.titleOfSelectedItem == "-") &&
(orderApp3.titleOfSelectedItem == "-") &&
(orderApp4.titleOfSelectedItem == "-") &&
Expand All @@ -202,7 +205,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
(orderApp13.titleOfSelectedItem == "-") &&
(orderApp14.titleOfSelectedItem == "-") &&
(orderApp15.titleOfSelectedItem == "-") &&
(orderApp16.titleOfSelectedItem == "-")
(orderApp16.titleOfSelectedItem == "-")) || interval.stringValue == ""
{
cycleButton.isEnabled = false
}
Expand All @@ -212,6 +215,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

@IBAction func startCycling(_ sender: Any) {
validateInterval((Any).self)
if interval.stringValue == "" {
return
}
if cycleButton.title == "Stop" {
cycleButton.title = "Cycle"
cycleTimer.invalidate()
Expand Down Expand Up @@ -244,7 +251,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
if orderApp16.titleOfSelectedItem != "-" { appsToBeCycled.append( [app16.stringValue, orderApp16.titleOfSelectedItem!]) }

appsToBeCycled = appsToBeCycled.sorted { $0[1] < $1[1] }
cycleTimer = Timer.scheduledTimer(timeInterval: 15.0, target: self, selector: #selector(AppDelegate.cycleApp), userInfo: nil, repeats: true)
cycleTimer = Timer.scheduledTimer(timeInterval: Double(interval.stringValue)!, target: self, selector: #selector(AppDelegate.cycleApp), userInfo: nil, repeats: true)

}

Expand All @@ -265,6 +272,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
orderApp14.isEnabled = false
orderApp15.isEnabled = false
orderApp16.isEnabled = false
interval.isEnabled = false
refreshList.isEnabled = false
}

func enableDropDowns() {
Expand All @@ -284,20 +293,38 @@ class AppDelegate: NSObject, NSApplicationDelegate {
orderApp14.isEnabled = true
orderApp15.isEnabled = true
orderApp16.isEnabled = true
interval.isEnabled = true
refreshList.isEnabled = true
}

@IBAction func quitApp(_ sender: Any) {
NSApplication.shared.terminate(self)
}

@objc func cycleApp() {
// Apps workarounds

if appsToBeCycled[cycle][0] == "iTerm2" {
appsToBeCycled[cycle][0] = "iTerm"
}

NSWorkspace.shared.launchApplication(appsToBeCycled[cycle][0])
cycle = cycle + 1
if cycle == appsToBeCycled.count {
cycle = 0
}


}

@IBAction func validateInterval(_ sender: Any) {
let regex = try! NSRegularExpression(pattern: "[A-Za-z\\W]", options: [])
if regex.firstMatch(in: interval.stringValue, options: [], range: NSMakeRange(0, interval.stringValue.count)) != nil {
interval.stringValue = ""
cycleButton.isEnabled = false
}
else
{
enableCycyleButton((Any).self)
}
}
}

46 changes: 39 additions & 7 deletions AppCycler/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14109" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14109"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down Expand Up @@ -47,6 +47,7 @@
<outlet property="appIcon8" destination="Ji6-Fc-hJJ" id="oLL-DO-aGh"/>
<outlet property="appIcon9" destination="7p2-B4-Af1" id="QTu-7d-aEf"/>
<outlet property="cycleButton" destination="8Hd-cM-eMm" id="fXA-eX-Spl"/>
<outlet property="interval" destination="Ek2-bu-r0X" id="3CO-5t-poY"/>
<outlet property="orderApp1" destination="NZX-Is-Q7x" id="Qdo-x3-pjH"/>
<outlet property="orderApp10" destination="oJA-DG-jzB" id="Ofm-96-RW5"/>
<outlet property="orderApp11" destination="f6H-Sf-E4Y" id="KpE-kQ-ty6"/>
Expand All @@ -63,6 +64,7 @@
<outlet property="orderApp7" destination="mML-QB-G5W" id="Ijm-kN-uod"/>
<outlet property="orderApp8" destination="bo3-iL-se5" id="QiO-cQ-arN"/>
<outlet property="orderApp9" destination="cK6-85-gwG" id="0aP-hO-xXl"/>
<outlet property="refreshList" destination="yQT-ho-jdJ" id="wBK-xN-Jxs"/>
<outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
</connections>
</customObject>
Expand Down Expand Up @@ -132,15 +134,15 @@
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="335" y="390" width="480" height="503"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1028"/>
<value key="minSize" type="size" width="480" height="793"/>
<value key="maxSize" type="size" width="480" height="802"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1418"/>
<value key="minSize" type="size" width="480" height="503"/>
<value key="maxSize" type="size" width="480" height="503"/>
<view key="contentView" autoresizesSubviews="NO" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="480" height="503"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<subviews>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="vZe-Jy-fHd">
<rect key="frame" x="400" y="13" width="66" height="32"/>
<rect key="frame" x="395" y="13" width="66" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<buttonCell key="cell" type="push" title="Quit" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Agy-aN-Ph7">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
Expand All @@ -162,7 +164,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="yQT-ho-jdJ">
<rect key="frame" x="313" y="13" width="87" height="32"/>
<rect key="frame" x="308" y="13" width="87" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<buttonCell key="cell" type="push" title="Refresh" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="j2Q-DL-VtW">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
Expand Down Expand Up @@ -926,6 +928,36 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="p5B-Ok-1R9">
<rect key="frame" x="169" y="19" width="41" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="right" title="30" drawsBackground="YES" id="Ek2-bu-r0X">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<action selector="validateInterval:" target="Voe-Tx-rLC" id="xnZ-4H-5Zv"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dit-jt-M77">
<rect key="frame" x="114" y="22" width="49" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Interval" id="WqQ-F2-gOc">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Uux-it-mub">
<rect key="frame" x="212" y="21" width="72" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="s" id="uL3-7f-qCx">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</view>
<point key="canvasLocation" x="48" y="-33.5"/>
Expand Down
2 changes: 2 additions & 0 deletions AppCycler/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
# AppCycler
<p align="center">
<img src="/images/logo_128x128.png">
</p>

An open-source application cycler

## Getting started

This simple application will let you automaticaly cycle through running applications

### Installing

Download latest version from [here](https://github.com/tbrek/AppCycler/raw/master/AppCycler.zip)

Simply copy it to your /Application folder and run.

## Usage

Open AppCycler application. List of currently running appliction will be populated automaticaly. Set the order, set the interval (default 30s) and click Cycle.

## Change log

1.0 Inital release

Binary file added images/logo_128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 12652c4

Please sign in to comment.