Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…d Main.tq to xnomad and added shebangs
  • Loading branch information...
commit d2f448d08b672ff4aa4b9e39aebd64e87fc4d858 1 parent 7ba762e
@fjolnir authored
View
1  .gitignore
@@ -1 +0,0 @@
-xnomad
View
2  Accessibility.tq
@@ -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
3  Layouts.tq
@@ -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
16 README.md
@@ -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
20 WindowManager.tq
@@ -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
View
107 xnomad
@@ -0,0 +1,107 @@
+#!/usr/local/tranquil/bin/tranquil
+
+import "WindowManager"
+import "Hotkeys"
+import "Layouts"
+
+wm = WindowManager new
+ setDefaultRatio: 0.7;
+ setWindowsInMaster: 1;
+ setLayouts: [MultiColLayout new,
+ MultiColLayout new setHorizontallyFlipped: yes; self,
+ FullscreenLayout new];
+ reflow; self
+
+mgr = HotkeyManager new
+
+mod1 = [#option, #control]
+mod2 = mod1 + [#command]
+
+\ Selection
+mgr registerHotkey: #k withModifiers: mod1 handler: {
+ wm selectPreviousWindow: AccessibilityWindow frontMostWindow
+ wm reflow
+}
+
+mgr registerHotkey: #j withModifiers: mod1 handler: {
+ wm selectNextWindow: AccessibilityWindow frontMostWindow
+ wm reflow
+}
+
+\ Swapping
+mgr registerHotkey: #s withModifiers: mod1 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
+}
+mgr registerHotkey: #k withModifiers: mod2 handler: {
+ wm swapWithPreviousWindow: AccessibilityWindow frontMostWindow; reflow
+}
+
+mgr registerHotkey: #j withModifiers: mod2 handler: {
+ wm swapWithNextWindow: AccessibilityWindow frontMostWindow; reflow
+}
+
+\ Ratio
+mgr registerHotkey: #l withModifiers: mod1 handler: {
+ screen = AccessibilityWindow frontMostWindow screen
+ space = wm currentSpaceId
+ wm setRatio: (wm ratioForScreen: screen space: space) + 0.05 forScreen: screen space: space
+ wm reflow
+}
+
+mgr registerHotkey: #h withModifiers: mod1 handler: {
+ screen = AccessibilityWindow frontMostWindow screen
+ space = wm currentSpaceId
+ wm setRatio: (wm ratioForScreen: screen space: space) - 0.05 forScreen: screen space: space
+ wm reflow
+}
+
+\ Master/slave count
+mgr registerHotkey: #"." withModifiers: mod1 handler: {
+ screen = AccessibilityWindow frontMostWindow screen
+ space = wm currentSpaceId
+ wm setMaxMasters: (wm maxMastersOnScreen: screen space: space) + 1
+ onScreen: screen
+ space: space
+ wm reflow
+}
+
+mgr registerHotkey: #"," withModifiers: mod1 handler: {
+ screen = AccessibilityWindow frontMostWindow screen
+ space = wm currentSpaceId
+ wm setMaxMasters: (wm maxMastersOnScreen: screen space: space) - 1
+ onScreen: screen
+ space: space
+ wm reflow
+}
+
+mgr registerHotkey: #" " withModifiers: mod2 handler: {
+ wm cycleLayouts; reflow
+}
+
+\ Display focus
+mgr registerHotkey: #w withModifiers: mod1 handler: {
+ wm focusOnScreen: screens[0] if (screens = NSScreen screens) count >= 1
+}
+mgr registerHotkey: #e withModifiers: mod1 handler: {
+ wm focusOnScreen: screens[1] if (screens = NSScreen screens) count >= 2
+}
+
+\ Moving windows between displays
+mgr registerHotkey: #w withModifiers: mod2 handler: {
+ if (screens = NSScreen screens) count >= 1 {
+ wm moveWindow: AccessibilityWindow frontMostWindow toScreen: screens[0]
+ wm reflow
+ }
+}
+mgr registerHotkey: #e withModifiers: mod2 handler: {
+ if (screens = NSScreen screens) count >= 2 {
+ wm moveWindow: AccessibilityWindow frontMostWindow toScreen: screens[1]
+ wm reflow
+ }
+}
+
+NSApplication sharedApplication run
View
20 xnomad.default
@@ -1,20 +0,0 @@
-{
- "Ratio": 0.7,
- "WindowsInMaster": 1,
- "Hotkeys": {
- "Swap": { "key": "s", "modifiers": [ "option", "control" ] },
- "SelectPrev": { "key": "k", "modifiers": [ "option", "control" ] },
- "SelectNext": { "key": "j", "modifiers": [ "option", "control" ] },
- "SwapPrev": { "key": "k", "modifiers": [ "option", "control", "command" ] },
- "SwapNext": { "key": "j", "modifiers": [ "option", "control", "command" ] },
- "FocusDisplay1": { "key": "w", "modifiers": [ "option", "control" ] },
- "FocusDisplay2": { "key": "e", "modifiers": [ "option", "control" ] },
- "ToDisplay1": { "key": "w", "modifiers": [ "option", "control", "command" ] },
- "ToDisplay2": { "key": "e", "modifiers": [ "option", "control", "command" ] },
- "CycleLayouts": { "key": " ", "modifiers": [ "option", "control" ] },
- "IncreaseRatio": { "key": "l", "modifiers": [ "option", "control" ] },
- "DecreaseRatio": { "key": "h", "modifiers": [ "option", "control" ] },
- "MoreMasters": { "key": ".", "modifiers": [ "option", "control" ] },
- "FewerMasters": { "key": ",", "modifiers": [ "option", "control" ] }
- }
-}
Please sign in to comment.
Something went wrong with that request. Please try again.