Welcome to the Power Users community on Codidact!
Power Users is a Q&A site for questions about the usage of computer software and hardware. We are still a small site and would like to grow, so please consider joining our community. We are looking forward to your questions and answers; they are the building blocks of a repository of knowledge we are building together.
Post History
One possibility is to use Hammerspoon with the following configuration: hs.hotkey.bind({ "cmd" }, "Right", function() local NextSpace = 1 for k, v in pairs(hs.spaces.allSpaces()[hs.scree...
Answer
#7: Post edited
- One possibility is to use [Hammerspoon](https://github.com/Hammerspoon/hammerspoon) with the following configuration:
- ```
- hs.hotkey.bind({ "cmd" }, "Right", function()
- local NextSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- NextSpace = k
- end
- end
- NextSpace = NextSpace+1
if (NextSpace == 4) then- NextSpace = 1
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", NextSpace))
- end)
- hs.hotkey.bind({ "cmd" }, "Left", function()
- local PrevSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- PrevSpace = k
- end
- end
- PrevSpace = PrevSpace - 1
- if (PrevSpace == 0) then
PrevSpace = 3- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", PrevSpace))
- end)
- ```
- In case one would also like to use mouse/trackpad gestures to circulate through spaces, one can use this newly defined Hammerspoon shortcut in [Jitouch](https://github.com/JitouchApp/Jitouch)
- Caveats:
- - this answer assumes that `cmd+number` is the shortcut to go to the space of a specific number. If you use another shortcut, you'll need to adjust the code accordingly
- this answer assumes that you have 3 spaces. Adjust the numbers in `PrevSpace = 3` and `NextSpace == 4` to match your number of spaces(+1)- - the animation when cycling between last/first might look counter intuitive. Switching off all animation with the "reduced motion" option from system preferences might be a solution
- One possibility is to use [Hammerspoon](https://github.com/Hammerspoon/hammerspoon) with the following configuration:
- ```
- hs.hotkey.bind({ "cmd" }, "Right", function()
- local NextSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- NextSpace = k
- end
- end
- NextSpace = NextSpace+1
- if (NextSpace == (#hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]+1)) then
- NextSpace = 1
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", NextSpace))
- end)
- hs.hotkey.bind({ "cmd" }, "Left", function()
- local PrevSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- PrevSpace = k
- end
- end
- PrevSpace = PrevSpace - 1
- if (PrevSpace == 0) then
- PrevSpace = #hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", PrevSpace))
- end)
- ```
- In case one would also like to use mouse/trackpad gestures to circulate through spaces, one can use this newly defined Hammerspoon shortcut in [Jitouch](https://github.com/JitouchApp/Jitouch)
- Caveats:
- - this answer assumes that `cmd+number` is the shortcut to go to the space of a specific number. If you use another shortcut, you'll need to adjust the code accordingly
- - the animation when cycling between last/first might look counter intuitive. Switching off all animation with the "reduced motion" option from system preferences might be a solution
#6: Post edited
- One possibility is to use [Hammerspoon](https://github.com/Hammerspoon/hammerspoon) with the following configuration:
- ```
- hs.hotkey.bind({ "cmd" }, "Right", function()
- local NextSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- NextSpace = k
- end
- end
- NextSpace = NextSpace+1
- if (NextSpace == 4) then
- NextSpace = 1
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", NextSpace))
- end)
- hs.hotkey.bind({ "cmd" }, "Left", function()
- local PrevSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- PrevSpace = k
- end
- end
- PrevSpace = PrevSpace - 1
- if (PrevSpace == 0) then
- PrevSpace = 3
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", PrevSpace))
- end)
- ```
- In case one would also like to use mouse/trackpad gestures to circulate through spaces, one can use this newly defined Hammerspoon shortcut in [Jitouch](https://github.com/JitouchApp/Jitouch)
(this answer assumes that `cmd+number` is the shortcut to go to the space of a specific number)
- One possibility is to use [Hammerspoon](https://github.com/Hammerspoon/hammerspoon) with the following configuration:
- ```
- hs.hotkey.bind({ "cmd" }, "Right", function()
- local NextSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- NextSpace = k
- end
- end
- NextSpace = NextSpace+1
- if (NextSpace == 4) then
- NextSpace = 1
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", NextSpace))
- end)
- hs.hotkey.bind({ "cmd" }, "Left", function()
- local PrevSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- PrevSpace = k
- end
- end
- PrevSpace = PrevSpace - 1
- if (PrevSpace == 0) then
- PrevSpace = 3
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", PrevSpace))
- end)
- ```
- In case one would also like to use mouse/trackpad gestures to circulate through spaces, one can use this newly defined Hammerspoon shortcut in [Jitouch](https://github.com/JitouchApp/Jitouch)
- Caveats:
- - this answer assumes that `cmd+number` is the shortcut to go to the space of a specific number. If you use another shortcut, you'll need to adjust the code accordingly
- - this answer assumes that you have 3 spaces. Adjust the numbers in `PrevSpace = 3` and `NextSpace == 4` to match your number of spaces(+1)
- - the animation when cycling between last/first might look counter intuitive. Switching off all animation with the "reduced motion" option from system preferences might be a solution
#5: Post edited
- One possibility is to use [Hammerspoon](https://github.com/Hammerspoon/hammerspoon) with the following configuration:
- ```
- hs.hotkey.bind({ "cmd" }, "Right", function()
- local NextSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- NextSpace = k
- end
- end
- NextSpace = NextSpace+1
- if (NextSpace == 4) then
- NextSpace = 1
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", NextSpace))
- end)
- hs.hotkey.bind({ "cmd" }, "Left", function()
- local PrevSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- PrevSpace = k
- end
- end
- PrevSpace = PrevSpace - 1
- if (PrevSpace == 0) then
- PrevSpace = 3
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", PrevSpace))
- end)
- ```
In case one would also like to use mouse/trackpad gestures to circulate through spaces, one can use this newly defined hammerspoon shortcut in [Jitouch](https://github.com/JitouchApp/Jitouch)(this answer assumes that `cmd+number` the shortcut to go to the space of a specific number)
- One possibility is to use [Hammerspoon](https://github.com/Hammerspoon/hammerspoon) with the following configuration:
- ```
- hs.hotkey.bind({ "cmd" }, "Right", function()
- local NextSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- NextSpace = k
- end
- end
- NextSpace = NextSpace+1
- if (NextSpace == 4) then
- NextSpace = 1
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", NextSpace))
- end)
- hs.hotkey.bind({ "cmd" }, "Left", function()
- local PrevSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- PrevSpace = k
- end
- end
- PrevSpace = PrevSpace - 1
- if (PrevSpace == 0) then
- PrevSpace = 3
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", PrevSpace))
- end)
- ```
- In case one would also like to use mouse/trackpad gestures to circulate through spaces, one can use this newly defined Hammerspoon shortcut in [Jitouch](https://github.com/JitouchApp/Jitouch)
- (this answer assumes that `cmd+number` is the shortcut to go to the space of a specific number)
#4: Post edited
- One possibility is to use [Hammerspoon](https://github.com/Hammerspoon/hammerspoon) with the following configuration:
- ```
- hs.hotkey.bind({ "cmd" }, "Right", function()
- local NextSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- NextSpace = k
- end
- end
- NextSpace = NextSpace+1
- if (NextSpace == 4) then
- NextSpace = 1
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", NextSpace))
- end)
- hs.hotkey.bind({ "cmd" }, "Left", function()
- local PrevSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- PrevSpace = k
- end
- end
- PrevSpace = PrevSpace - 1
- if (PrevSpace == 0) then
- PrevSpace = 3
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", PrevSpace))
- end)
- ```
In case one would also like to use mouse/trackpad gestures to circulate through spaces, one can use this newly defined hammerspoon shortcut in [Jitouch](https://github.com/JitouchApp/Jitouch)
- One possibility is to use [Hammerspoon](https://github.com/Hammerspoon/hammerspoon) with the following configuration:
- ```
- hs.hotkey.bind({ "cmd" }, "Right", function()
- local NextSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- NextSpace = k
- end
- end
- NextSpace = NextSpace+1
- if (NextSpace == 4) then
- NextSpace = 1
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", NextSpace))
- end)
- hs.hotkey.bind({ "cmd" }, "Left", function()
- local PrevSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- PrevSpace = k
- end
- end
- PrevSpace = PrevSpace - 1
- if (PrevSpace == 0) then
- PrevSpace = 3
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", PrevSpace))
- end)
- ```
- In case one would also like to use mouse/trackpad gestures to circulate through spaces, one can use this newly defined hammerspoon shortcut in [Jitouch](https://github.com/JitouchApp/Jitouch)
- (this answer assumes that `cmd+number` the shortcut to go to the space of a specific number)
#3: Post edited
- One possibility is to use [Hammerspoon](https://github.com/Hammerspoon/hammerspoon) with the following configuration:
- ```
- hs.hotkey.bind({ "cmd" }, "Right", function()
- local NextSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- NextSpace = k
- end
- end
- NextSpace = NextSpace+1
- if (NextSpace == 4) then
- NextSpace = 1
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", NextSpace))
- end)
- hs.hotkey.bind({ "cmd" }, "Left", function()
- local PrevSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- PrevSpace = k
- end
- end
- PrevSpace = PrevSpace - 1
- if (PrevSpace == 0) then
- PrevSpace = 3
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", PrevSpace))
- end)
```
- One possibility is to use [Hammerspoon](https://github.com/Hammerspoon/hammerspoon) with the following configuration:
- ```
- hs.hotkey.bind({ "cmd" }, "Right", function()
- local NextSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- NextSpace = k
- end
- end
- NextSpace = NextSpace+1
- if (NextSpace == 4) then
- NextSpace = 1
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", NextSpace))
- end)
- hs.hotkey.bind({ "cmd" }, "Left", function()
- local PrevSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- PrevSpace = k
- end
- end
- PrevSpace = PrevSpace - 1
- if (PrevSpace == 0) then
- PrevSpace = 3
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", PrevSpace))
- end)
- ```
- In case one would also like to use mouse/trackpad gestures to circulate through spaces, one can use this newly defined hammerspoon shortcut in [Jitouch](https://github.com/JitouchApp/Jitouch)
#2: Post edited
One possibility is to use Hammerspoon with the following configuration:- ```
- hs.hotkey.bind({ "cmd" }, "Right", function()
- local NextSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- NextSpace = k
- end
- end
- NextSpace = NextSpace+1
- if (NextSpace == 4) then
- NextSpace = 1
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", NextSpace))
- end)
- hs.hotkey.bind({ "cmd" }, "Left", function()
- local PrevSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- PrevSpace = k
- end
- end
- PrevSpace = PrevSpace - 1
- if (PrevSpace == 0) then
- PrevSpace = 3
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", PrevSpace))
- end)
- ```
- One possibility is to use [Hammerspoon](https://github.com/Hammerspoon/hammerspoon) with the following configuration:
- ```
- hs.hotkey.bind({ "cmd" }, "Right", function()
- local NextSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- NextSpace = k
- end
- end
- NextSpace = NextSpace+1
- if (NextSpace == 4) then
- NextSpace = 1
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", NextSpace))
- end)
- hs.hotkey.bind({ "cmd" }, "Left", function()
- local PrevSpace = 1
- for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do
- if v == hs.spaces.focusedSpace() then
- PrevSpace = k
- end
- end
- PrevSpace = PrevSpace - 1
- if (PrevSpace == 0) then
- PrevSpace = 3
- end
- hs.eventtap.keyStroke({ "control" }, string.format("%d", PrevSpace))
- end)
- ```
#1: Initial revision
One possibility is to use Hammerspoon with the following configuration: ``` hs.hotkey.bind({ "cmd" }, "Right", function() local NextSpace = 1 for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do if v == hs.spaces.focusedSpace() then NextSpace = k end end NextSpace = NextSpace+1 if (NextSpace == 4) then NextSpace = 1 end hs.eventtap.keyStroke({ "control" }, string.format("%d", NextSpace)) end) hs.hotkey.bind({ "cmd" }, "Left", function() local PrevSpace = 1 for k, v in pairs(hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]) do if v == hs.spaces.focusedSpace() then PrevSpace = k end end PrevSpace = PrevSpace - 1 if (PrevSpace == 0) then PrevSpace = 3 end hs.eventtap.keyStroke({ "control" }, string.format("%d", PrevSpace)) end) ```