Permalink
Browse files

Removed json config, now we use tranquil to configure instead, rename…

…d Main.tq to xnomad and added shebangs
  • Loading branch information...
fjolnir committed Mar 5, 2013
1 parent 7ba762e commit d2f448d08b672ff4aa4b9e39aebd64e87fc4d858
Showing with 121 additions and 271 deletions.
  1. +0 −1 .gitignore
  2. +1 −1 Accessibility.tq
  3. +0 −13 JSON.tq
  4. +1 −2 Layouts.tq
  5. +0 −210 Main.tq
  6. +6 −10 README.md
  7. +6 −14 WindowManager.tq
  8. +107 −0 xnomad
  9. +0 −20 xnomad.default
View
@@ -1 +0,0 @@
-xnomad
View
@@ -9,7 +9,7 @@ import "CGSPrivate"
klass = rolePtr value case: {
#AXApplication => `AccessibilityApplication`,
#AXWindow => `AccessibilityWindow`
- } else: `AccessibilityElement`
+ } default: `AccessibilityElement`
^klass new setAxElement: element; self
}
+ systemWide `self withAXElement: AXUIElementCreateSystemWide() autorelease`
View
13 JSON.tq
@@ -1,13 +0,0 @@
-parseJSONFile = { path |
- data = NSData dataWithContentsOfFile: (path stringByExpandingTildeInPath)
- if data == nil {
- "File '«path»' not found" print
- ^nil
- }
- result = NSJSONSerialization JSONObjectWithData: data options: 0 error: (err = TQPointer toObject)
- if err value ~= nil {
- "Error parsing JSON at '«path»': «err value localizedDescription»" print
- ^nil
- }
- ^result
-}
View
@@ -95,9 +95,8 @@ min = `a,b| (a > b) ? b ! a`
x = i * masterWidth
x = screenFrame[1][0] - x - masterWidth if @horizontallyFlipped
x += left
- y = top
masterCount = wm maxMastersOnScreen: screen space: spaceId
- frame = [[x, y], [masterWidth, screenFrame[1][1]]]
+ frame = [[x, top], [masterWidth, screenFrame[1][1]]]
win setFrame: frame
} else {
h = screenFrame[1][1] / subCount
View
210 Main.tq
@@ -1,210 +0,0 @@
-import "WindowManager"
-import "Hotkeys"
-import "JSON"
-
-prefs = parseJSONFile("~/.xnomad")
-
-wm = WindowManager new
-wm defaultRatio = prefs[#Ratio] || 0.7
-wm windowsInMaster = prefs[#WindowsInMaster] || 1
-wm reflow
-
-mgr = HotkeyManager new
-hotkeys = prefs[#Hotkeys]
-
-if key = hotkeys[#SelectPrev] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- wm selectPreviousWindow: AccessibilityWindow frontMostWindow
- wm reflow
- }
-}
-if key = hotkeys[#SelectNext] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- wm selectNextWindow: AccessibilityWindow frontMostWindow
- wm reflow
- }
-}
-
-if key = hotkeys[#Swap] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- win = AccessibilityWindow frontMostWindow
- other = wm swapWithCounterpart: win
- other raise if (other frame)[0][0] > 10 \ If the other window was made primary
- \ then it makes sense to give it focus
- wm reflow
- }
-}
-if key = hotkeys[#SwapPrev] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- wm swapWithPreviousWindow: AccessibilityWindow frontMostWindow
- wm reflow
- }
-}
-if key = hotkeys[#SwapNext] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- wm swapWithNextWindow: AccessibilityWindow frontMostWindow
- wm reflow
- }
-}
-
-if key = hotkeys[#IncreaseRatio] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- screen = AccessibilityWindow frontMostWindow screen
- space = wm currentSpaceId
- wm setRatio: (wm ratioForScreen: screen space: space) + 0.05 forScreen: screen space: space
- wm reflow
- }
-}
-
-if key = hotkeys[#DecreaseRatio] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- screen = AccessibilityWindow frontMostWindow screen
- space = wm currentSpaceId
- wm setRatio: (wm ratioForScreen: screen space: space) - 0.05 forScreen: screen space: space
- wm reflow
- }
-}
-
-if key = hotkeys[#MoreMasters] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- screen = AccessibilityWindow frontMostWindow screen
- space = wm currentSpaceId
- wm setMaxMasters: (wm maxMastersOnScreen: screen space: space) + 1 onScreen: screen space: space
- wm reflow
- }
-}
-
-if key = hotkeys[#FewerMasters] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- screen = AccessibilityWindow frontMostWindow screen
- space = wm currentSpaceId
- wm setMaxMasters: (wm maxMastersOnScreen: screen space: space) - 1 onScreen: screen space: space
- wm reflow
- }
-}
-
-if key = hotkeys[#CycleLayouts] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- wm cycleLayouts; reflow
- }
-}
-
-if key = hotkeys[#FocusDisplay1] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- screens = NSScreen screens
- if screens count >= 1 then wm focusOnScreen: screens[0]
- }
-}
-if key = hotkeys[#FocusDisplay2] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- screens = NSScreen screens
- if screens count >= 2 then wm focusOnScreen: screens[1]
- }
-}
-if key = hotkeys[#FocusDisplay3] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- screens = NSScreen screens
- if screens count >= 3 then wm focusOnScreen: screens[2]
- }
-}
-
-if key = hotkeys[#ToDisplay1] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- screens = NSScreen screens
- if screens count >= 1 {
- wm moveWindow: AccessibilityWindow frontMostWindow toScreen: screens[0]
- wm reflow
- }
- }
-}
-if key = hotkeys[#ToDisplay2] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- screens = NSScreen screens
- if screens count >= 2 {
- wm moveWindow: AccessibilityWindow frontMostWindow toScreen: screens[1]
- wm reflow
- }
- }
-}
-if key = hotkeys[#ToDisplay3] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- screens = NSScreen screens
- if screens count >= 3 {
- wm moveWindow: AccessibilityWindow frontMostWindow toScreen: screens[2]
- wm reflow
- }
- }
-}
-
-\ Space shortcuts are not enabled by default because they aren't perfect yet.
-\ (You can use TotalSpaces if you want to disable the switching animation; that's what I do)
-if key = hotkeys[#Space1] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- wm switchToSpace: 0
- wm reflow
- }
-}
-if key = hotkeys[#Space2] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- wm switchToSpace: 1
- wm reflow
- }
-}
-if key = hotkeys[#Space3] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- wm switchToSpace: 2
- wm reflow
- }
-}
-if key = hotkeys[#Space4] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- wm switchToSpace: 3
- wm reflow
- }
-}
-if key = hotkeys[#Space5] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- wm switchToSpace: 4
- wm reflow
- }
-}
-if key = hotkeys[#Space6] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- wm switchToSpace: 5
- wm reflow
- }
-}
-if key = hotkeys[#Space7] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- wm switchToSpace: 6
- wm reflow
- }
-}
-if key = hotkeys[#Space8] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- wm switchToSpace: 7
- wm reflow
- }
-}
-if key = hotkeys[#Space9] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- wm switchToSpace: 8
- wm reflow
- }
-}
-if key = hotkeys[#ToSpace1] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- wm moveWindow: AccessibilityWindow frontMostWindow toSpace: 0
- }
-}
-if key = hotkeys[#ToSpace2] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- wm moveWindow: AccessibilityWindow frontMostWindow toSpace: 1
- }
-}
-if key = hotkeys[#ToSpace3] {
- mgr registerHotkey: key[#key] withModifiers: key[#modifiers] handler: {
- wm moveWindow: AccessibilityWindow frontMostWindow toSpace: 2
- }
-}
-NSApplication sharedApplication run
View
@@ -9,11 +9,9 @@ A tiling window manager for OS X; written in [tranquil](https://github.com/fjoln
##setup
-[Download](http://d.asgeirsson.is/sfEI) a binary, then copy `xnomad.default` to your home directory & rename it to `.xnomad` (Resulting path is `~/.xnomad`)
-
-And then just execute xnomad, your windows will be snapped in place. (Make sure "Access for Assistive Devices" is enabled in Accessibility Preferences)
-
-To learn the hotkeys, read xnomad.default
+* Download & install [tranquil](https://github.com/fjolnir/Tranquil)
+* Make sure "Access for Assistive Devices" is enabled in Accessibility Preferences
+* Clone xnomad, and execute `./xnomad`
OS X 10.8 or newer is required.
@@ -25,12 +23,10 @@ OS X 10.8 or newer is required.
* Fullscreen
* Additional ones are easy to write
-## protip
+##protips
In order to make the most of xnomad, I recommend you also install [afloat](http://infinite-labs.net/afloat/). It will add shortcuts for making windows floating (and therefore ignored by xnomad) and resizing/moving windows without having to spend precious milliseconds looking for the window edges.
-The rounded corner hack is discussed under this issue: https://github.com/fjolnir/xnomad/issues/6
+Another nice addition is [menufela](http://github.com/fjolnir/menufela) which hides the menubar)
-##building
-
-In order to build xnomad you'll first need to install [tranquil](https://github.com/fjolnir/tranquil). Then you can simply write (assuming you added /usr/local/tranquil/bin to your PATH) `tqc Main.tq -framework Carbon -framework ApplicationServices -o xnomad` and a binary will appear.
+The rounded corner hack is discussed under this issue: https://github.com/fjolnir/xnomad/issues/6
View
@@ -1,5 +1,4 @@
import "Accessibility"
-import "Layouts"
@NSNotificationCenter
{
@@ -14,6 +13,7 @@ import "Layouts"
accessor: #windowsInMaster initialValue: 1
accessor: #defaultRatio initialValue: 0.7
accessor: #defaultMaxMasters initialValue: 1
+ accessor: #layouts initialValue: []
- init
{
@@ -23,14 +23,6 @@ import "Layouts"
@screensThatNeedReflowing = []
@spacesThatNeedReflowing = []
- @layouts = [
- MultiColLayout new,
- MultiColLayout new setHorizontallyFlipped: yes; self,
- TallLayout new,
- WideLayout new,
- FullscreenLayout new
- ]
-
workspace = NSWorkspace sharedWorkspace
workspace runningApplications each: { app |
self addApplicationWithPID: app processIdentifier unless app bundleIdentifier hasPrefix: "com.apple.dashboard"
@@ -84,6 +76,7 @@ import "Layouts"
(self managedWindowsForScreen: NSScreen mainScreen spaces: destSpace) first raise
}
}
+
\ This doesn't work yet, not sure if my function prototype is wrong, or if you need elevated permissions to move windows around
\ - moveWindow: window toSpace: destSpaceIdx
\ {
@@ -284,12 +277,12 @@ import "Layouts"
- swapWithCounterpart: window
{
\ Get the existing reference managing the same physical window
- screen = window screen
- space = self currentSpaceId
+ screen = window screen
+ space = self currentSpaceId
windows = self managedWindowsForScreen: screen space: space
- idx = windows indexOf: window
+ idx = windows indexOf: window
masterCount = self maxMastersOnScreen: screen space: space
- isOnLeft = idx < masterCount
+ isOnLeft = idx < masterCount
winCount = windows count
if isOnLeft {
@@ -301,7 +294,6 @@ import "Layouts"
self swapWindow: window with: windows[otherIdx]
}
-
- focusOnScreen: screen
{
(self managedWindowsForScreen: screen space: self currentSpaceId) first raise
Oops, something went wrong.

0 comments on commit d2f448d

Please sign in to comment.