Compare commits

...

406 Commits

Author SHA1 Message Date
Tomáš Janoušek
00832bf5e6
Merge pull request #935 from xmonad/haskell-ci-update
ci: Regenerate haskell-ci
2025-05-12 18:28:30 +02:00
Tomas Janousek
410b34f074 ci/nix: Drop weird magic URLs
I don't know what these are but I hope reverting to what
cachix/install-nix-action's documentation recommends will fix the errors
we're getting with presumably old Nix on new Ubuntu GitHub Actions
runners.
2025-05-12 17:21:36 +01:00
Tony Zorman
15dd45be0e ci/nix: Switch to ubuntu-latest 2025-05-12 17:17:26 +01:00
github-actions[bot]
f7451b9378 ci: Regenerate haskell-ci 2025-05-10 03:30:43 +00:00
github-actions[bot]
849208d1b8 ci: Bump GHC patch versions in tested-with 2025-05-10 03:30:43 +00:00
github-actions[bot]
4b86621051 ci: Regenerate haskell-ci 2025-04-13 16:57:26 +01:00
github-actions[bot]
18eb8aca94 ci: Bump GHC patch versions in tested-with 2025-04-13 16:57:26 +01:00
github-actions[bot]
a84f3e8540 ci: Regenerate haskell-ci 2025-04-05 08:36:22 +01:00
Tony Zorman
bd81961a63
Merge pull request #932 from xmonad/haskell-ci-update
ci: Regenerate haskell-ci
2025-03-31 08:24:48 +00:00
github-actions[bot]
209839f3ca ci: Regenerate haskell-ci 2025-03-29 03:18:50 +00:00
Tony Zorman
50e7dd4262
Merge pull request #931 from xmonad/haskell-ci-update
ci: Regenerate haskell-ci
2025-03-22 05:40:18 +00:00
github-actions[bot]
e2cdc0cc2c ci: Regenerate haskell-ci 2025-03-22 03:22:15 +00:00
github-actions[bot]
68da8c44ba ci: Bump GHC patch versions in tested-with 2025-03-22 03:22:15 +00:00
Tony Zorman
0517c94960
Merge pull request #926 from m1mir/feat/ewmh-hidden-viewport
X.H.EwmhDesktops: Add setEwmhHiddenWorkspaceToScreenMapping function.
2025-03-18 06:38:02 +00:00
m1mir
b1bf33d6eb
X.H.IndependentScreens: Added screenOnMonitor to the export list. 2025-03-17 10:16:01 +01:00
m1mir
195a0ac3c0
X.H.EwmhDesktops: Added setEwmhHiddenWorkspaceToScreenMapping function. 2025-03-17 10:15:48 +01:00
Tony Zorman
b470de0d75
Merge pull request #930 from geekosaur/containers-0.8
support containers-0.8
2025-03-11 07:04:15 +01:00
Tony Zorman
87585a6884
Merge pull request #929 from xmonad/dependabot/github_actions/cachix/install-nix-action-31
build(deps): bump cachix/install-nix-action from 30 to 31
2025-03-11 07:03:58 +01:00
brandon s allbery kf8nh
41f1d1434c
support containers-0.8
compiled locally to test
2025-03-10 21:43:03 -04:00
dependabot[bot]
ddcce31597
build(deps): bump cachix/install-nix-action from 30 to 31
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 30 to 31.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v30...v31)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-10 16:50:50 +00:00
github-actions[bot]
4496b4f2d5 ci: Regenerate haskell-ci 2025-02-22 11:12:33 +00:00
Tony Zorman
5119626269
Merge pull request #927 from portnov/master
X.U.EZConfig: support "<Menu>" for xK_Menu key.
2025-02-10 11:06:52 +01:00
Ilya V. Portnov
27c86d0dda Update Changes.md 2025-02-10 14:51:12 +05:00
Ilya V. Portnov
58dbf59cab X.U.EZConfig: support "<Menu>" for xK_Menu key. 2025-02-10 12:30:59 +05:00
Tony Zorman
9d457a73ce
Merge pull request #924 from m1mir/feat/independentDoFocus
X.L.IndependentScreens: Add doFocus' ManageHook.
2025-02-07 07:22:05 +01:00
m1mir
f1f392cd01
X.L.IndependentScreens: Added doFocus' ManageHook. 2025-02-07 06:26:49 +01:00
Tony Zorman
6c1441d9db
Merge pull request #925 from philib/master
fix unintended window hiding
2025-01-31 06:21:15 +01:00
philib
6a6d913dee fix unintended window hiding
the refactoring that introduced `nsHideOnCondition` caused a
misbehaviour in `nsSingleScratchpadPerWorkspace`, leading to unintended
window hiding. Now, when opening a new scratchpad, only the previous
active scratchpad is hidden.
2025-01-30 12:22:18 +01:00
Tomas Janousek
4fc3642fa2 Merge remote-tracking branch 'origin/haskell-ci-update' into tmp 2025-01-26 23:00:19 +00:00
Tomas Janousek
7614f94d92 ci: Add GHC 9.8 (Stackage LTS 23) to Stack test matrix 2025-01-26 23:00:19 +00:00
Tomas Janousek
c7061b0d73 Remove last remaining derivations of Typeable
GHC 9.12 now warns about this:

    Deriving ‘Typeable’ has no effect: all types now auto-derive Typeable

and we specify -Werror so this is needed to fix CI builds with 9.12.

Related: f732082fdccb ("Remove all derivations of Typeable")
2025-01-26 23:00:19 +00:00
Tony Zorman
6df1044265
Merge pull request #923 from m1mir/feat/setEwmhSwitchDesktopAction
X.H.EwmhDesktops: Add customization for handling the _NET_CURRENT_DESKTOP requests
2025-01-25 17:54:20 +01:00
m1mir
619a347f3f X.L.IndependentScreens: Added focusWorkspace function. 2025-01-25 17:31:46 +01:00
m1mir
2b11459496 X.H.EwmhDesktops: Added customization for external desktop switching.
Added a configuration option to change the action for handling the
_NET_CURRENT_DESKTOP requests.
2025-01-25 17:31:46 +01:00
github-actions[bot]
beabe75dda ci: Regenerate haskell-ci 2025-01-25 03:08:40 +00:00
github-actions[bot]
0404372fd3 ci: Bump GHC patch versions in tested-with 2025-01-25 03:08:40 +00:00
Tony Zorman
c0a5bc5f0f workflows/stack: Add non-master resolver for lts-16 2025-01-18 18:17:07 +01:00
Tony Zorman
1f13bb2468 fixup! cabal: Drop support for GHC 8.6 2025-01-18 11:44:54 -05:00
Tony Zorman
d4473946d4 cabal: Drop support for GHC 8.6
See https://github.com/xmonad/xmonad-contrib/pull/921
2025-01-18 11:44:54 -05:00
brandon s allbery kf8nh
55e1adde4c add XF86WLAN special key 2025-01-18 11:44:54 -05:00
Tony Zorman
de01015af5
Merge pull request #918 from nilscc/feature/auto-format-to-hls
Auto-format `OnScreen` and `ScreenCorners` to HLS
2025-01-02 22:07:23 +01:00
Nils
7f0f0ad498 {X.A.OnScreen,X.H.ScreenCorners}: Reformat 2025-01-02 22:06:53 +01:00
Nils
195537e97e Update email and copyright 2025-01-02 09:25:46 -05:00
Tony Zorman
d9e54c1b96
Merge pull request #915 from sol/patch-1
docs: Don't link to re-exports from XMonad.Config.Prime
2024-12-22 19:10:50 +01:00
Simon Hengel
b570ab1a74
docs: Don't link to re-exports from XMonad.Config.Prime 2024-12-19 21:46:55 +07:00
Tony Zorman
0dc879698d
Merge pull request #914 from liskin/noborders-resetborder
X.L.NoBorders: Listen to DestroyWindowEvents and garbage collect
2024-11-24 10:51:25 +01:00
Tomas Janousek
fe826ca8db X.L.NoBorders: Listen to DestroyWindowEvents and garbage collect
Previously, it was necessary to use `borderEventHook` to make sure the
`alwaysHidden`/`neverHidden` lists are garbage collected when a window
is destroyed, but this was largely undocumented. Since xmonad v0.17.0,
the DestroyWindowEvent is broadcast to layouts, so we can just use that
instead and deprecate the event hook.
2024-11-23 14:44:29 +00:00
github-actions[bot]
d19ea051d4 ci: Regenerate haskell-ci 2024-11-16 05:44:55 +00:00
brandon s allbery kf8nh
c5032a43fb
Merge pull request #911 from liskin/rescreen
X.H.Rescreen, X.A.PhysicalScreens: Add facilities to avoid (some) workspace reshuffling
2024-10-21 06:58:57 -04:00
Tomas Janousek
61f8b4aa8e CHANGES: Document the X.H.Rescreen, X.A.PhysicalScreens additions 2024-10-17 17:52:42 +01:00
Tomas Janousek
60fc830e2e CHANGES: Inline links
Seems somewhat likely that "on the website", "this PR" and "priorities"
may be used again in a different context…
2024-10-17 17:47:06 +01:00
Tomas Janousek
f97ce867ac X.A.PhysicalScreens: Add rescreen alternative to avoid ws reshuffle
Probably a very niche use-case: I have an ultra-wide display that I
split into two using `xrandr --setmonitor`, and I want the workspaces to
stay in place when the split ratio is adjusted.

Furthermore, this fixes workspace reshuffling when a virtual monitor is
added for screensharing a portion of the screen
(https://news.ycombinator.com/item?id=41837204).

Can't think of a scenario involving just physical screens where this
would be useful. Those are mostly added/removed, so if anything, one
might wish to preserve the workspace that is currently being showed, but
that would require knowing the output name (only available via RandR,
not via Xinerama). If someone physically moves their displays around and
then invokes `xrandr` to update the layout, this might very well do the
right thing, but I don't think anyone moves their displays around often
enough to be annoyed by xmonad reshuffling the workspaces. :-)
2024-10-17 17:42:17 +01:00
Tomas Janousek
2f42d2e7b4 X.H.Rescreen: Configurable wait/delay for events to settle 2024-10-17 17:42:17 +01:00
Tomas Janousek
b454f1e0be X.H.Rescreen: Move error handling to rescreenHook
This handles errors in hooks set using `rescreenHook` as well, not just
those set using the individual adders/setters.

Fixes: 2e3254a9080c ("X.H.Rescreen: Catch exceptions in user-provided hooks in add*Hook")
2024-10-17 17:42:17 +01:00
Tomas Janousek
5680205c72 X.H.Rescreen: Allow overriding rescreen itself
The primary motivation is to fix `rescreen` messing up the
workspaces/screens order when making small changes to the layout of
multiple screens — such as resizing virtual monitors via `xrandr
--setmonitor`.
2024-10-17 17:42:17 +01:00
dependabot[bot]
1c5261d65a build(deps): bump cachix/install-nix-action from 29 to 30
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 29 to 30.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v29...v30)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-07 20:07:26 +02:00
brandon s allbery kf8nh
2c161ff670
Merge pull request #908 from xmonad/dependabot/github_actions/cachix/install-nix-action-v29
build(deps): bump cachix/install-nix-action from V28 to 29
2024-09-30 13:02:50 -04:00
dependabot[bot]
2ec4bbc833
build(deps): bump cachix/install-nix-action from V28 to 29
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from V28 to 29. This release includes the previously tagged commit.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/V28...v29)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-30 16:37:08 +00:00
dependabot[bot]
42340e0f76 build(deps): bump cachix/install-nix-action from V27 to 28
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from V27 to 28. This release includes the previously tagged commit.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/V27...V28)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-16 19:14:53 +01:00
Christina Sørensen
4350936ba5 fix: deprecated url literals
Signed-off-by: Christina Sørensen <christina@cafkafk.com>
2024-09-15 19:08:49 -04:00
Tony Zorman
2973c283ae fixup! X.L.OnHost: Query gethostname if $HOST lookup fails 2024-09-03 20:57:02 -04:00
Tony Zorman
a96a2031f6 X.L.OnHost: Query gethostname if $HOST lookup fails
Fixes: https://github.com/xmonad/xmonad-contrib/issues/899
2024-09-03 20:57:02 -04:00
Giacomo Rosin
1e5fcb1216 X.A.DynamicProjects: Update CHANGES.md 2024-09-03 20:56:29 -04:00
Giacomo Rosin
6bc6bf8abd X.A.DynamicProjects: Improve documentation
Describe how to close projects and the output of `currentProject` function.
2024-09-03 20:56:29 -04:00
Giacomo Rosin
c98715623d X.A.DynamicProjects: Don't autodelete projects
Fixes #902 by no longer deleting projects on switch, as it is more confusing than useful.
2024-09-03 20:56:29 -04:00
Tony Zorman
b3c249434d X.H.StatusBar: Make barSpawner pure
Related: https://github.com/xmonad/xmonad-contrib/pull/878
Related: https://github.com/xmonad/xmonad-contrib/issues/880
2024-08-27 08:23:19 +02:00
Tony Zorman
d0d9d42761
Merge pull request #900 from slotThe/x.a.upkeys
X.A.UpKeys: Init
2024-08-27 08:20:09 +02:00
Tony Zorman
e203096143 X.A.UpKeys: Init
Original implementation from https://stackoverflow.com/a/11308086
2024-08-22 18:35:31 +02:00
Tony Zorman
6811b9e296 cabal: Bump version to development version 2024-08-20 18:50:34 +02:00
Tony Zorman
f5f99c8abf cabal: Update DXMONAD_CONTRIB_VERSION_PATCH 2024-08-20 18:21:57 +02:00
Tony Zorman
d41f36fa5c cabal: Bump version number 2024-08-20 18:17:57 +02:00
Tony Zorman
e4e04aa017 nix.yml: Update index before building 2024-08-18 14:11:16 +02:00
brandon s allbery kf8nh
ec5c751b35
fix module name in haddock markup
This was forgotten when the module was renamed.
2024-08-06 18:53:00 -04:00
Tony Zorman
eb7268451c
Merge pull request #896 from Rogach/pr/window-navigation
X.A.WindowNavigation: better handling of floating windows and Full layout
2024-07-28 20:16:44 +02:00
github-actions[bot]
0dcecb41c5 ci: Regenerate haskell-ci 2024-07-13 06:21:31 +01:00
Tomáš Janoušek
5d285ced1f
Merge pull request #897 from xmonad/haskell-ci-update
ci: Regenerate haskell-ci
2024-07-07 15:37:27 +01:00
Tomas Janousek
91e59c3651 Add base bounds for test-suite
cabal 3.12+ is stricter in its checks. Our test suite doesn't depend on
xmonad-contrib (it compiles the modules itself with possibly different
preprocessor defines), thus it doesn't inherit its base bounds.

See https://github.com/haskell/cabal/issues/10162
2024-07-07 15:26:54 +01:00
github-actions[bot]
5f82296536 ci: Regenerate haskell-ci 2024-07-07 15:20:58 +01:00
github-actions[bot]
e8029cb51d ci: Bump GHC patch versions in tested-with 2024-07-07 15:20:58 +01:00
Tomas Janousek
1211a709dc Bump lower bound for base
We only test with GHC 8.6+ and the bounds should reflect that.

Related: 5d0013ef534d ("ci: Drop support for GHC 8.4")
Related: 046f3c3871a7 ("Bump lower bound for base")
2024-07-07 15:19:54 +01:00
Platon Pronko
66d334f4cd X.A.WindowNavigation: better handling of floating windows and Full layout
Previous version most of the time just got "stuck" on floating windows,
switching back and forth between floating window and tiled window underneath.
This was because "magic point" was left in the same position and thus next
navigation commands selected the same windows over and over again.
Now the "magic point" is moved around such that it doesn't overlap with the previously selected window,
and there are more complicated rules to make navigation between floating and tiled windows more natural.

The original behavior of navigating between tiled windows is preserved almost precisely.

Previous version also prevented switching windows using focusUp/focusDown
when in Full layout. Now there's a special case that handles such situations.
2024-07-01 19:44:56 +04:00
brandon s allbery kf8nh
55f4c4ff1b
Fix typo in comment 2024-06-16 00:38:12 -04:00
halting
bbbf5c3b44 missing dependencies in the test suite 2024-06-16 00:35:39 -04:00
halting
b3ca4362af X.A.WindowBringer: Add copyMenu 2024-06-16 00:35:39 -04:00
Tony Zorman
5325ca8902
Merge pull request #894 from sylecn/grid-select
XMonad.Actions.GridSelect: added gs_cancelOnEmptyClick field
2024-06-10 08:19:24 +02:00
Yuanle Song
0bc28ac473 X.A.GridSelect: Add gs_cancelOnEmptyClick field
In the original code, when a GridSelect is shown, user has to use
keyboard to cancel it (ESC key by default). With this field added,
when it is set to True (the default), mouse click on empty space
can cancel the GridSelect.
2024-06-10 08:12:15 +02:00
Yuanle Song
077b4ff34b XMonad.Hooks.ScreenCorners: Add support for edges
Previously only corners are supported, now support for edges are added. This
is similar to Hot Edge shell extension in GNOME.
2024-06-08 22:32:27 -04:00
Tomas Janousek
7109b0ce8f ci: Bump actions/upload-artifact to v4
v3 is deprecated:
https://github.blog/changelog/2024-04-16-deprecation-notice-v3-of-the-artifact-actions/
2024-05-21 22:44:08 +01:00
jecaro
b57212cc18 Make the width of the fst column configurable 2024-05-20 16:49:33 -04:00
jecaro
da3e4bef33 Remove the call to singleton 2024-05-20 16:49:33 -04:00
jecaro
d014d7ac84 Add a new layout Columns
This layout organizes windows in columns and allows to move/resize them
in every directions.
2024-05-20 16:49:33 -04:00
Tomas Janousek
a88b5aa58d ci: gh-workflow-keepalive no longer needs a GITHUB_TOKEN input 2024-05-20 21:13:04 +01:00
Tomáš Janoušek
58f956c29f
Merge pull request #891 from xmonad/dependabot/github_actions/cachix/install-nix-action-27
build(deps): bump cachix/install-nix-action from 26 to 27
2024-05-20 17:59:59 +01:00
dependabot[bot]
7ac0f44db4
build(deps): bump cachix/install-nix-action from 26 to 27
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 26 to 27.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v26...V27)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-20 16:37:20 +00:00
Tomáš Janoušek
d6ea38e7be
Merge pull request #890 from xmonad/haskell-ci-update
ci: Regenerate haskell-ci
2024-05-18 07:46:08 +01:00
github-actions[bot]
c8c5cc1838 ci: Regenerate haskell-ci 2024-05-18 03:12:44 +00:00
Tomáš Janoušek
7210251138
Merge pull request #889 from xmonad/haskell-ci-update
ci: Regenerate haskell-ci (add GHC 9.10)
2024-05-13 20:46:40 +01:00
github-actions[bot]
7dc39c7154 ci: Regenerate haskell-ci 2024-05-13 20:29:52 +01:00
github-actions[bot]
6fece17d3d ci: Bump GHC patch versions in tested-with 2024-05-13 20:29:52 +01:00
Tomas Janousek
8e34c2f745 X.U.Grab: Drop mkGrabs, setNumlockMask in favor of the new core exports
Now that we require xmonad 0.18.0, we can do this.

Related: https://github.com/xmonad/xmonad/pull/405
Related: 0934fe5cd758 ("X.U.Grab: Hide mkGrabs from XMonad")
2024-05-13 16:08:28 +01:00
Tomas Janousek
02f124cf4b ci: Expand stack test matrix 2024-05-13 12:28:24 +01:00
Tomas Janousek
840ede1e9e ci: Bump the oldest xmonad version we test against
Stackage LTS 22 has mtl-2.3 and unix-2.8, which xmonad 0.17 excludes in
its bounds.
2024-05-13 12:28:24 +01:00
Tony Zorman
8fb1973e05
Merge pull request #888 from andwu137/master
Add a method to re-sort keys for visualSubmap
2024-05-09 08:27:34 +02:00
Andrew Nguyen
abef527f73 X.A.Submap: Add visualSubmapSorted 2024-05-09 08:14:11 +02:00
Tomas Janousek
cbdee7db6f X.H.EwmhDesktops: Fix _NET_CURRENT_DESKTOP handling
_NET_CURRENT_DESKTOP doesn't act on a specific window and its ev_window
is set to the root window, but the root window is considered unmanaged
so this would be caught by the "not member" guard and ignored. We need
to move the guard a bit further down.

Fixes: 3839c8bce99b ("X.H.EwmhDesktops: Fix menus in Steam client")
Fixes: https://old.reddit.com/r/xmonad/comments/1cfclhh/psa_steam_fixes_merged_to_xmonadcontrib_master/l2hjwuy/
2024-05-04 09:25:38 +01:00
Tony Zorman
0622ed11ed X.P.OrgMode: Do not default the day if no time is given
Partially reverts b8d5c391cc03cfa5d7d95caa79f590d366e3c0ba
Fixes: https://github.com/liskin/xmonad-contrib/actions/runs/8869462044/job/24350171604
2024-04-30 08:30:14 +02:00
Tomáš Janoušek
700507fcd0
Merge pull request #886 from liskin/steam-fixes
Fixes/workarounds for Steam client menus/flickering
2024-04-28 19:39:21 +02:00
Tomas Janousek
ca5e70ffc4 CHANGES: Document this branch's additions/fixes 2024-04-28 19:37:56 +02:00
Tomas Janousek
67472aa307 CHANGES: Whitespace/punctuation fixes 2024-04-28 19:37:56 +02:00
Tomas Janousek
c33efbbefd X.H.FloatConfigureReq: Add fixSteamFlicker
For ease of use, provide `fixSteamFlicker` as a pre-packaged
`floatConfReqHook` that can easily be added directly to a
`handleEventHook`.

Also, for discoverability, re-export it from X.U.Hacks.
2024-04-28 19:37:56 +02:00
Tomas Janousek
2b77997259 X.H.FloatConfigureReq: New module to customize ConfigureRequest handling
Implements a replacement event handler for 'ConfigureRequestEvent' to
work around misbehaving client applications such as Steam, URxvt and
others that try to restore their absolute window positions. Primarily
motivated by the Steam client being almost completely unusable in xmonad
lately.

(I've been running this code in my xmonad.hs for other purposes for
years.)
2024-04-28 19:37:56 +02:00
Tomas Janousek
3839c8bce9 X.H.EwmhDesktops: Fix menus in Steam client
More specifically, ignore ClientMessageEvents for unmanaged windows.
Steam likes to send _NET_ACTIVE_WINDOW requests for all its windows,
including override-redirect ones, which used to result in an invocation
of `windows` with a no-op Endo—equivalent to a call to `refresh`. But
this refresh makes Steam close its menus immediately.

Fixes: https://github.com/ValveSoftware/steam-for-linux/issues/9376
Fixes: https://github.com/xmonad/xmonad/issues/451
2024-04-28 19:37:52 +02:00
Tony Zorman
8efff53a06 X.P.OrgMode: More strictly enfore +s and +d ending with a space
Fixes: https://github.com/xmonad/xmonad-contrib/actions/runs/8772077289/job/24070588575
2024-04-27 19:43:14 +02:00
Tomáš Janoušek
cab938f07b
Merge pull request #885 from xmonad/haskell-ci-update
ci: Regenerate haskell-ci
2024-04-21 12:44:26 +02:00
github-actions[bot]
f3d936ef97 ci: Regenerate haskell-ci 2024-04-21 07:50:43 +00:00
github-actions[bot]
aff212654d ci: Bump GHC patch versions in tested-with 2024-04-21 07:50:42 +00:00
Tony Zorman
6e43da8598
Merge pull request #864 from dcousens/no-xp-io
X.P: Add escape hatch for preventing X.P IO
2024-03-31 09:58:37 +02:00
Daniel Cousens
fcd2f60226 X.P: Don't read/write to history file if size is 0
This contains a breaking change for readHistory, writeHistory,
historyCompletion, and historyCompletionP to take an XPConfig, so they
are aware of this choice. While the latter two are exported, it seems
unlikely to affect many users.
2024-03-31 09:58:09 +02:00
Tony Zorman
51926854d9
Merge pull request #883 from slotThe/orgmode-time
X.P.OrgMode: Add time spans
2024-03-31 09:37:24 +02:00
Tony Zorman
0d2b68374c
Merge pull request #884 from geekosaur/time-1.14-again
time 1.14 update missed the test suite
2024-03-30 06:39:11 +01:00
brandon s allbery kf8nh
933cb57b90
missed the test suite 2024-03-30 00:46:28 -04:00
Tony Zorman
ebe1b9b036 X.P.OrgMode: Add ability to specify time spans 2024-03-29 20:47:52 +01:00
Tony Zorman
d691d25d1c X.P.OrgMode: Fallback to "today" if no day is given 2024-03-29 13:57:27 +01:00
Tony Zorman
8ac84079a2
Merge pull request #881 from geekosaur/bounds-time
update time to <1.15
2024-03-23 07:46:19 +01:00
Tony Zorman
7aa2ff6798
Merge pull request #882 from xmonad/haskell-ci-update
ci: Regenerate haskell-ci
2024-03-23 07:45:28 +01:00
github-actions[bot]
21a75bfeb4 ci: Regenerate haskell-ci 2024-03-23 03:16:36 +00:00
brandon s allbery kf8nh
78bad11578
remove extraneous ) in docstring 2024-03-20 03:29:02 -04:00
brandon s allbery kf8nh
51ee223ec3
update time to <1.15 2024-03-17 16:39:10 -04:00
Yecine Megdiche
2b079bf9fb
Merge pull request #878 from Chobbes/dynamic-status-bars-x
Update StatusBar library to use the X monad instead of IO.
2024-03-13 10:53:16 +01:00
Tony Zorman
94bccd3e16
Merge pull request #879 from xmonad/dependabot/github_actions/cachix/install-nix-action-26
build(deps): bump cachix/install-nix-action from 25 to 26
2024-03-11 20:09:50 +01:00
dependabot[bot]
35ded4259b
build(deps): bump cachix/install-nix-action from 25 to 26
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 25 to 26.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v25...v26)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-11 16:48:47 +00:00
Calvin Beck
e735339b75 Update StatusBar library to use the X monad instead of IO.
This change allows dynamic status bars to pull information out of the
X monad, which can be really useful for status bars. For instance, you
can now query the screen width in order to set the width of status
bars appropriately.

Existing configurations may need to be updated in order to lift an
`IO StatusBarConfig` to an `X StatusBarConfig`. This can be done using
either the `io` function provided by `XMonad.Core`, or `liftIO` from
`base` in `Control.Monad.IO.Class`

- https://hackage.haskell.org/package/xmonad-0.18.0/docs/XMonad-Core.html#v:io
- https://hackage.haskell.org/package/base-4.19.1.0/docs/Control-Monad-IO-Class.html#v:liftIO
2024-03-09 10:40:13 -05:00
Tomáš Janoušek
de5ef6cabd
Merge pull request #877 from ilya-bobyr/master
X.H.ManageHelpers: `isNotification` predicate
2024-03-04 12:28:38 +00:00
Illia Bobyr
da5566d59f
X.H.ManageHelpers: isNotification predicate
Very similar to `isDialog`, `isNotification` checks for the
`_NET_WM_WINDOW_TYPE_NOTIFICATION` value in the `_NET_WM_WINDOW_TYPE`
property.
2024-03-02 12:38:10 -08:00
Tony Zorman
82191700e6
Merge pull request #876 from xmonad/haskell-ci-update
ci: Regenerate haskell-ci
2024-03-02 07:53:10 +01:00
github-actions[bot]
ced5b7abfc ci: Regenerate haskell-ci 2024-03-02 03:15:25 +00:00
github-actions[bot]
ca8e9ce722 ci: Bump GHC patch versions in tested-with 2024-03-02 03:15:25 +00:00
Tony Zorman
5ce04d6664 .mailmap: Update 2024-02-28 09:07:41 +01:00
mislavzanic
bfe2f5b3f9 feat: add profiles 2024-02-16 11:05:46 -05:00
Tony Zorman
c8dff5e2dc
Merge pull request #874 from ulrikdem/ezconfig-duplicate
X.U.EZConfig: Fix checkKeymap warning that all keybindings are duplicate
2024-02-16 07:25:34 +01:00
Ulrik de Muelenaere
aec21860ba X.U.EZConfig: Fix checkKeymap warning that all keybindings are duplicate
This reverts part of 42179b8625d83b2cd3c3a35da84de6f6c0dea6d6, which
effectively changed the duplicate check from >1 to >=1.
2024-02-15 20:49:06 -05:00
Tomas Janousek
93ad0ef2ea ci: Adopt the liskin/gh-workflow-keepalive action
This avoids hardcoding the workflow filename and thus makes
refactoring/renaming less error-prone.
2024-02-15 11:02:26 +00:00
Tony Zorman
ae5949657b
Merge pull request #873 from mislavzanic/mini_refactor_hidden_layout
X.L.Hidden: use the modifyWindowSet function
2024-02-12 13:57:16 +01:00
mislavzanic
dda929dfc5 X.L.Hidden: use the modifyWindowSet function 2024-02-12 10:58:48 +01:00
Daniel Cousens
a84cec9b2d
X.*: Fix typos (#871)
* X.*: fix typos

* X.*: fix typos

* X.*: fix typos

* X.Util: fix typo

---------

Co-authored-by: Daniel Cousens <dcousens@users.noreply.github.com>
2024-02-12 07:55:20 +01:00
Tony Zorman
1d8305d515
Merge pull request #872 from gabrielsimoes/patch-1
Fix build-with-cabal.sh when XDG_CONFIG_HOME is defined
2024-02-12 07:54:46 +01:00
Gabriel Simões
e963382d62
Update CHANGES.md 2024-02-11 21:23:20 -05:00
Gabriel Simões
e6dae98c44
Fix build-with-cabal.sh when XDG_CONFIG_HOME is defined 2024-02-11 21:20:30 -05:00
Tony Zorman
7843d4dd28 Bump version to 0.18.0.9 2024-02-03 18:43:21 +01:00
Tony Zorman
9217ac18e9 cabal: Bump xmonad dependency 2024-02-03 16:06:47 +01:00
Tony Zorman
c65ea8d3ab Bump version to 0.18.0 2024-02-03 16:02:47 +01:00
Tony Zorman
d54d37e344
Merge pull request #869 from dcousens/patch-1
X.P: Fix some typos in comments
2024-01-24 14:40:44 +01:00
Daniel Cousens
903e50a65c
X.P: Fix some typos in comments 2024-01-25 00:17:18 +11:00
dependabot[bot]
f3ee6289ec build(deps): bump actions/cache from 3 to 4
Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3...v4)
2024-01-22 11:55:52 +00:00
brandon s allbery kf8nh
318ee92e61 only sink window if actually fullscreened
`EwmhFullscreen` unconditionally sinks windows in response to a
`_NET_WM_STATE` root window message removing `_NET_WM_STATE_FULLSCREEN`.
Unfortunately, at least some versions of either the Gtk or GNOME
libraries send this on startup while restoring a window's last
known state, which means a `manageHook` `doFloat` will be undone.

This change ignores the remove if the window is not fullscreen.

A followup issue, #865, has been added for the follow-on problem
that the floating state of a window is not restored on removal of
the fullscreen state.

Fixes: #820
2024-01-21 12:07:09 -05:00
Ilya V. Portnov
a5fb7e021a
X.L.DecorationEx: extensible mechanism for window decorations (#857)
* First version of DecorationEx.

* Fixed most warnings.

* Fix build error with ghc-9.8.1.

* Fix title shrinking with text decoration.

* Add convinience re-exports.

* Get rid of orphan instances.

* Fix a couple of warnings.

* Rename X.L.DecorationEx.Types -> X.L.DecorationEx.Common

* Add instance Default StandardCommand.

* Fix some typos and formatting

thanks to @geekosaur

Co-authored-by: brandon s allbery kf8nh <allbery.b@gmail.com>

* Fix reference to xmonad.hs

See also #859

Co-authored-by: brandon s allbery kf8nh <allbery.b@gmail.com>

* Fix reference to xmonad.hs

Co-authored-by: brandon s allbery kf8nh <allbery.b@gmail.com>

* Fix formatting

Co-authored-by: brandon s allbery kf8nh <allbery.b@gmail.com>

* Fix some typos and formatting

thanks to @geekosaur

Co-authored-by: brandon s allbery kf8nh <allbery.b@gmail.com>

* Remove commented code.

* Update CHANGES.md.

* calcWidgetPlace is now allowed to return rectangle with any X,

but that will be ignored.

* More generic instance for DecorationWidget GenericWidget.

* Replace explicit definition of `fi` with import from X.Prelude.

thanks to @slotThe.

* Move fetch-all pattern to the end of definition.

thanks to @slotThe.

* X.L.DecorationEx: Add screenshot

---------

Co-authored-by: brandon s allbery kf8nh <allbery.b@gmail.com>
Co-authored-by: Tony Zorman <soliditsallgood@mailbox.org>
2024-01-21 12:02:08 -05:00
Tomáš Janoušek
09e37131ca
Merge pull request #863 from xmonad/haskell-ci-update
ci: Regenerate haskell-ci
2024-01-17 11:54:01 +00:00
github-actions[bot]
39310a6695 ci: Regenerate haskell-ci 2024-01-17 11:28:14 +00:00
github-actions[bot]
14e80f2f74 ci: Bump GHC patch versions in tested-with 2024-01-17 11:28:13 +00:00
dependabot[bot]
2272691ada build(deps): bump cachix/install-nix-action from 24 to 25
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 24 to 25.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v24...v25)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-15 16:37:58 +00:00
Tomas Janousek
4bb6a2eedb X.H.EwmhDesktops: Fix haddock markup
Fixes: 2dcc3a92e70c ("X.H.EwmhDesktops: Add (un)fullscreen hooks")
2024-01-14 10:20:27 +00:00
Tony Zorman
7cb6b0f87b
Merge pull request #861 from dcousens/patch-1
XMonad.Prompt: export getCurrentCompletions (and setCurrentCompletions)
2024-01-10 08:06:04 +01:00
Daniel Cousens
385d7e9579 X.P: Export {selected,setCurrent,getCurrent}Completion[s] 2024-01-10 08:04:59 +01:00
Tony Zorman
99b24f314b
Merge pull request #860 from dcousens/patch-1
Fix Xmonad.Prompt.Input usage example
2023-12-28 16:02:38 +01:00
Daniel Cousens
9f51b2a1d6
Fix example Xmonad.Prompt.Input usage example 2023-12-28 00:54:36 +11:00
Tony Zorman
82e4260084
Merge pull request #859 from slotThe/kill-dots
`~/.xmonad/xmonad.hs` -> `xmonad.hs`
2023-12-23 08:08:43 +01:00
Tony Zorman
5ceaed8126
Merge pull request #858 from dcousens/fix-min-width
Fix minimum widths for Shrink and Expand
2023-12-23 08:07:57 +01:00
Daniel Cousens
cd32cac54b X.L.TwoPane[Persistent]: Add minimum widths for Shrink and Expand 2023-12-23 08:07:00 +01:00
Tony Zorman
b1b3c4c469 ~/.xmonad/xmonad.hs -> xmonad.hs
With XDG support so firmly ingrained now, it's about time we stop
hard-coding the configuration path in the docs.
2023-12-22 18:17:17 +01:00
Tony Zorman
c01cd3a33b
Merge pull request #848 from portnov/master
Add new module: X.L.CircleEx: advanced version of Circle layout
2023-12-21 19:58:00 +01:00
Ilya V. Portnov
4f2a5c7f43 X.L.Circle: Deprecate in favour of X.L.CircleEx 2023-12-21 19:52:20 +01:00
Ilya V. Portnov
19edf5a7a8 X.L.CircleEx: Init 2023-12-21 19:52:20 +01:00
Tony Zorman
75d67cfb1d
Merge pull request #856 from l29ah/prompt-return-normal-vim
X.Prompt: handle Return key in vim normal mode
2023-12-20 05:58:38 +01:00
Sergey Alirzaev
9609e0ef2e X.Prompt: handle Return key in vim normal mode 2023-12-20 05:57:58 +01:00
Tomas Janousek
3613d4d543 X.U.Ungrab: Avoid "Ambiguous occurrence" error in user configs 2023-12-18 10:32:03 +00:00
Tony Zorman
d54a7e21dd
Merge pull request #853 from liskin/ewmh-desktop-managehook
X.H.{EwmhDesktops,ManageHelpers}: Add _NET_WM_DESKTOP-handling ManageHook
2023-12-18 10:53:26 +01:00
Tony Zorman
0fe948feb3
Merge pull request #852 from liskin/renamed-named
X.L.Renamed: Provide "named" convenience alias
2023-12-18 10:48:19 +01:00
Tomas Janousek
3c329e0aad X.H.{EwmhDesktops,ManageHelpers}: Add _NET_WM_DESKTOP-handling ManageHook
Useful for restoring browser windows to where they were before restart
(which is something one should do several times a week as security
updates get released).
2023-12-17 21:58:57 +00:00
Tomas Janousek
92a7c030b2 X.L.Renamed: Provide "named" convenience alias
I believe this common use-case for the deprecated X.L.Named should still
be provided somewhere, rather than telling everybody to let-define this
themselves.

The other one – `nameTail` – only has about 6 uses in publicly available
configs (https://github.com/search?q=nameTail+path%3Axmonad&type=code),
so I'm not adding that one but I'm happy to be convinced to add it too.

Related: 3bf9d80c40b9 ("XMonad.Layout.Named: Deprecate")
2023-12-17 21:49:49 +00:00
Tony Zorman
e75eb16a93
Merge pull request #850 from slotThe/fix/prompt-ignores-left
X.Prompt: Execute keypress when it has an action associated to it
2023-12-17 13:39:27 +01:00
Tony Zorman
00993d46fa X.Prompt: Execute keypress when it has an action associated to it
It might be that the keypress does not have a valid stroke associated to
it, but is still bound to an action (e.g., xK_Left an friends). In this
case, we still want to execute it.

Closes: https://github.com/xmonad/xmonad-contrib/issues/845
2023-12-16 15:42:53 +01:00
Tony Zorman
5c30cadaf6
Merge pull request #843 from iogrt/ungrab
deprecate `XMonad.Util.Ungrab`
2023-12-09 08:18:51 +01:00
iogrt
22372abaab X.U.Ungrab: Deprecate 2023-12-09 07:49:49 +01:00
Tony Zorman
a34287dda6
Merge pull request #847 from xmonad/haskell-ci-update
ci: Regenerate haskell-ci
2023-12-09 07:34:19 +01:00
github-actions[bot]
34d55ede85 ci: Regenerate haskell-ci 2023-12-09 03:13:33 +00:00
dependabot[bot]
7ce7ddf9e6 build(deps): bump cachix/install-nix-action from 23 to 24
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 23 to 24.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v23...v24)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-04 16:51:51 +00:00
Tony Zorman
7464b36afa NIX.md: Add flakes semi-walkthrough 2023-12-02 16:04:49 +01:00
Tony Zorman
45dd67433c
Merge pull request #844 from xmonad/haskell-ci-update
ci: Regenerate haskell-ci
2023-11-18 08:06:46 +01:00
github-actions[bot]
ff8d4ebb94 ci: Regenerate haskell-ci 2023-11-18 03:15:29 +00:00
github-actions[bot]
f9d98e0936 ci: Bump GHC patch versions in tested-with 2023-11-18 03:15:29 +00:00
Tomáš Janoušek
ad28ae1daa
Merge pull request #842 from xmonad/haskell-ci-update
ci: Regenerate haskell-ci
2023-11-13 00:28:50 +00:00
Tomas Janousek
192c0da831 ci: Only build haddock for hackage with the latest GHC
Cabal 3.10.2.0 exposes a bug in Haddock shipped with GHC 9.0 and 9.2, so
we need to work around it by bumping the version of GHC/Haddock we use
for building/uploading docs to Hackage, and to prevent build failures we
don't ever try to build haddocks for Hackage with older versions of
GHC/Haddock.

Related: https://github.com/haskell/haddock/issues/1582#issuecomment-1611412223
Related: https://github.com/haskell/cabal/issues/8326
Related: https://github.com/haskell/cabal/issues/9060
Related: https://github.com/haskell/cabal/pull/9073
Related: https://github.com/haskell/cabal/pull/9049
2023-11-12 23:58:14 +00:00
github-actions[bot]
e38e19edc1 ci: Regenerate haskell-ci 2023-11-11 03:20:02 +00:00
Tony Zorman
8035db1bd0
Merge pull request #841 from jpolchlo/docs/unicode-prompt
Add documentation for unicode prompt
2023-11-08 10:34:40 +01:00
jpolchlo
da566d63e6 X.P.Unicode: Add docs about UnicodeData.txt
Having this file is required for the prompt to work, and how to obtain
it may not be immediately obvious.
2023-11-08 10:33:46 +01:00
Tony Zorman
c176a752de
Merge pull request #838 from xmonad/haskell-ci-update
ci: Regenerate haskell-ci
2023-10-28 12:55:13 +02:00
Tomas Janousek
532d64a0f9 ci: Disable x-partial warnings in the testsuite
Related: https://github.com/xmonad/xmonad/pull/477
2023-10-28 11:29:36 +01:00
github-actions[bot]
487b6d1677 ci: Regenerate haskell-ci 2023-10-28 11:44:37 +02:00
github-actions[bot]
a9ba19fb24 ci: Bump GHC patch versions in tested-with 2023-10-28 11:44:37 +02:00
Tony Zorman
105e529826 Fix partial uses of head
Fixes: https://github.com/xmonad/xmonad-contrib/issues/830
Related: https://github.com/xmonad/xmonad-contrib/pull/836
2023-10-28 11:41:24 +02:00
Tony Zorman
42179b8625 X.U.EZConfig: Make readKeySequence return non-empty list 2023-10-26 14:18:31 +02:00
Tony Zorman
d668e4cb10 X.Prelude: Add takeS 2023-10-26 11:52:40 +02:00
Tony Zorman
f654082c5b
Merge pull request #837 from philib/master
introduce single active scratchpad hook
2023-10-24 21:10:00 +02:00
Tony Zorman
e1dc2a3750 X.U.NamedScratchpad: Extract common parts of ns{HideOnFocusLoss,SingleScratchpadPerWorkspace} 2023-10-24 21:01:22 +02:00
philib
105cbe0362 X.U.NamedScratchpad: Add nsSingleScratchpadPerWorkspace
A logHook to allow only one active scratchpad per workspace.
2023-10-24 21:00:46 +02:00
Tony Zorman
9c4325f3ef
Merge pull request #836 from slotThe/wx-partial
Address some `-Wx-Partial` warnings
2023-10-20 08:21:59 +02:00
Tony Zorman
46a26487ba Reduce head usage 2023-10-20 08:13:24 +02:00
Tony Zorman
7680ebb93b Import X.Prelude unqualified if necessary
This gets rid of, for example,

    The import of ‘liftA2’ from module ‘XMonad.Prelude’ is redundant

-type warnings.
2023-10-20 08:13:23 +02:00
Tony Zorman
c3d16bfa99 X.L.Groups: Rewrite gen using infinite streams 2023-10-20 08:13:23 +02:00
Tony Zorman
7599c898ef X.Prelude: Add infinite stream type
Stolen from X.A.MostRecentlyUsed. This can be used in favour of lists
when we know the generated lists are definitely infinite.
2023-10-20 08:13:23 +02:00
Tony Zorman
8ee129483a X.U.Stack: Add zipperFocusedAtFirstOf 2023-10-20 08:13:02 +02:00
Tony Zorman
52a40f376c Replace tail with drop 1
Where appropriate.
2023-10-15 18:46:28 +02:00
Tony Zorman
c8c81474a2 X.A.CycleWindows: Move rot{Up,Down} to X.A.RotSlaves
Reexport them instead.
2023-10-15 11:00:35 +02:00
Tony Zorman
8c0ca8b9fe X.Prompt: Add isModifier
It seems sensible to abstract this away, if only to make the code a tad
more readable.
2023-10-11 09:43:26 +02:00
Tony Zorman
3cd1b066a2
Merge pull request #835 from slotThe/deprecate-cross
X.L.Cross: Deprecate
2023-10-10 07:35:28 +02:00
Tony Zorman
ba5011b874
Merge pull request #834 from slotThe/feat/prompt/cycle-backwards
X.Prompt: Allow for backwards cycling of completions
2023-10-09 16:36:42 +02:00
Tony Zorman
60867bdd2d X.L.Cross: Deprecate
The module has badly bitrotted, and is in such a state that it's
unlikely anyone is using it currently. Better alternatives exist, so
just deprecating seems appropriate here.

Closes: https://github.com/xmonad/xmonad-contrib/issues/793
2023-10-09 14:32:32 +02:00
Tony Zorman
8f8730b222
Merge pull request #833 from slotThe/pass-otp-type
X.P.Pass: Add passOTPTypePrompt
2023-10-06 10:03:17 +02:00
Tony Zorman
7854f7766e X.P.Pass: Properly escape backslashes 2023-10-06 09:07:11 +02:00
Tony Zorman
fde30fc073 X.P.Pass: Add passOTPTypePrompt 2023-10-06 09:07:11 +02:00
Tony Zorman
431ba22e3c X.P.Pass: Clean up code 2023-10-06 09:07:11 +02:00
Tony Zorman
570bd17a51 cabal: Bump containers dependency
Version 0.7 was confirmed to build via

    cabal build --flags=pedantic --constraint='containers >= 0.7'
2023-10-04 13:09:58 +02:00
Tony Zorman
4c0d3cac8d X.Prompt: Allow for backwards cycling of completions
+ Add a new prevCompletionKey to XPConfig, in order to cycle backwards.
  Bound to S-<Tab> by default.

+ Already handle null keystrings (times when only a modifier was
  pressed) in handleMain, such that completions aren't cleared
  prematurely.

+ Augment nextComplIndex (now computeComplIndex) with the ability to go
  in an arbitrary 1-dimensional direction. As a result, that function,
  as well as handleCompletion and handleCompletionMain now take an
  additional Direction1D argument.

Based on: https://github.com/solomon-b/xmonad-contrib/tree/feature/scrolling-prompt-completions
Fixes: https://github.com/xmonad/xmonad-contrib/issues/831

Co-authored-by: Solomon Bothwell <ssbothwell@gmail.com>
2023-10-04 09:27:53 +02:00
Christina Sørensen
a379850f50
XMonad.actions.search: Add NixOS and home-manager searchEngines (#832)
* feat(search): add nixos as searchEngine
* feat(search): add homeManager as searchEngine
* docs(CHANGES): add nixos, homeManager to searchEngine section

Signed-off-by: Christina Sørensen <christina@cafkafk.com>
2023-09-27 11:05:09 -04:00
Tony Zorman
7bb1f0b887 stack: Bump resolver to lts-21.12
This also bumps the default GHC version from 9.4.6 to 9.4.7.
2023-09-23 14:14:30 +02:00
Tony Zorman
4f6a9deaf8
Merge pull request #829 from slotThe/ghc/head
X.Prelude: Compatibility with base-4.18.0.0
2023-09-20 17:53:23 +02:00
Tony Zorman
32ff4db11c cabal: Bump bytestring dependency
Related: https://mail.haskell.org/pipermail/xmonad/2023-September/015647.html
2023-09-18 17:39:27 +02:00
Tomas Janousek
ac9265e774 ci: Replace deprecated haskell/actions/hlint-*
See https://github.com/haskell/actions/pull/301#issuecomment-1722353522
2023-09-18 15:42:25 +01:00
Tomas Janousek
c9a096ac1f ci: Replace deprecated haskell/actions/setup
See https://github.com/haskell/actions/pull/301 and
https://github.com/haskell/actions/pull/301/files
2023-09-17 23:17:05 +01:00
dependabot[bot]
51ba23b776 build(deps): bump actions/checkout from 3 to 4 (except haskell-ci workflow)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)
2023-09-17 21:22:45 +01:00
Tomas Janousek
b358c90a73 ci: Drop unnecessary cmd from "Install packdeps"
Not needed since https://github.com/haskell/actions/pull/165 (Jan 2023).
2023-09-17 21:21:18 +01:00
Tony Zorman
000cd14799 X.Prelude: Compatibility with base-4.18.0.0
Will ship with GHC 9.8.

Fixes: https://github.com/xmonad/xmonad-contrib/issues/826
2023-09-17 12:23:22 +02:00
Tony Zorman
0e2d3c159d
Merge pull request #827 from xmonad/dependabot/github_actions/cachix/install-nix-action-23
build(deps): bump cachix/install-nix-action from 22 to 23
2023-09-04 21:48:52 +02:00
dependabot[bot]
63a758243a
build(deps): bump cachix/install-nix-action from 22 to 23
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 22 to 23.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v22...v23)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-04 16:50:28 +00:00
Tony Zorman
2df26cf9f8 stack: Bump resolver to 21.6
This is the newest lts resolver for 9.4.5.
2023-08-12 14:22:26 +02:00
Tomas Janousek
6912eca829 X.A.WorkspaceNames: Use history for completion in renameWorkspace 2023-08-11 00:12:43 +01:00
Tony Zorman
348df92b89 X.U.Run: Fix definitions of >&&> and >||>
Whoops.

Fixes: 1b7fd6d8c99eee0b99261e48ed030b2ba42c88b5
2023-08-09 06:07:10 +02:00
Tony Zorman
1b7fd6d8c9 X.U.Run: Add >&&> and >||> 2023-08-08 20:08:11 +02:00
Tony Zorman
0ca3ce7a18 X.U.Run: Add toInput 2023-08-08 20:01:23 +02:00
Tony Zorman
bf41a85d9c
Merge pull request #822 from Zawaken/magnifiercxy
Add magnifiyxy combinator to XMonad.Layout.Magnifier
2023-08-06 09:35:48 +02:00
Zawaken
a0bfa8a447 X.L.Magnifier: Add magnifyxy
The combinator allows for different magnification to be used in the
horizontal and vertical direction.
2023-08-06 09:28:23 +02:00
Tony Zorman
7062b75ea9
Merge pull request #819 from slotThe/ci/bump
Bump cabal/stack CI
2023-07-18 09:35:44 +02:00
Tony Zorman
34b544b7a1 ci/cabal: Bump GHC versions 2023-07-16 17:27:16 +02:00
Tony Zorman
5b5a51787c ci/stack: Add lts-21 resolver 2023-07-16 17:26:49 +02:00
Tomáš Janoušek
4d0f3ee944
Merge pull request #818 from geekosaur/debugwindow-fix-decode
fix double decode in `debugWindow`
2023-06-26 14:56:14 +02:00
Tony Zorman
e02400b1c7 X.A.Prefix: Add orIfPrefixed
- Generalise signature of withPrefixArgument, in order to accommodate
  this.
2023-06-23 08:14:38 +02:00
brandon s allbery kf8nh
4a60866ea4
fix double decode in debugWindow
At some point `peekCString` became locale aware. This is a double
bug, since (a) `decodeString` was being applied to the result and
(b) the locale might not be UTF-8, but the string being decoded
always is.

The fix is to use `peekCAString` which bypasses the locale decode,
then continuing to do UTF-8 decode.
2023-06-22 06:25:56 -04:00
Tomáš Janoušek
4bdcab8bf6
Merge pull request #817 from xmonad/dependabot/github_actions/cachix/install-nix-action-22
build(deps): bump cachix/install-nix-action from 21 to 22
2023-06-19 22:52:20 +02:00
dependabot[bot]
f2ac181616
build(deps): bump cachix/install-nix-action from 21 to 22
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 21 to 22.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v21...v22)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-19 17:00:04 +00:00
Tomáš Janoušek
b6c0dd9cfc
Merge pull request #816 from xmonad/dependabot/github_actions/cachix/install-nix-action-21
build(deps): bump cachix/install-nix-action from 20 to 21
2023-05-29 20:15:44 +02:00
dependabot[bot]
611317f398
build(deps): bump cachix/install-nix-action from 20 to 21
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 20 to 21.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v20...v21)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-29 16:59:34 +00:00
Tony Zorman
ad48cdc2cb
Merge pull request #814 from geekosaur/808-supported-partial-struts
add `_NET_WM_STRUT_PARTIAL` to `_NET_SUPPORTED`
2023-05-14 12:28:06 +02:00
brandon s allbery kf8nh
1486d076dc
add _NET_WM_STRUT_PARTIAL to _NET_SUPPORTED
For docks that don't support `_NET_WM_STRUT` any more,
notably `xfce4-panel`.
2023-05-12 12:29:37 -04:00
brandon s allbery kf8nh
1243bbbded Fix many bugs and shortcomings in debugEventsHook
Added support for several more properties, and fixed parsing of many
others. Still doesn't handle COMPOUND_TEXT and the code in DebugWindow
is wrong. I have correct code in C++ but it will require some work to
translate to Haskell so it can be used in both places.
2023-04-26 13:24:01 -04:00
Mahdi Seyedan
cf00d2d237 Add CenterMainFluid layout 2023-04-21 10:23:13 -04:00
brandon s allbery kf8nh
87ae269b82 Put a cap on window names
It turns out qutebrowser will place an entire `data:` URL in
`_NET_WM_NAME`, up to at least 389K characters including
newlines and possibly binary characters.

Clamping window titles to the first line, and to 2K chars
because `defaultShrinker` is quadratic in the title length.
2023-04-19 12:53:33 -04:00
Tomáš Janoušek
673de11ca8
Merge pull request #768 from liskin/fullscreen-hooks
Add (un)fullscreen hooks and float-restoring toggleFullFloat action
2023-04-01 12:32:01 +02:00
Tomas Janousek
02bd9eb0c0 CHANGES: Document X.A.ToggleFullFloat and setEwmhFullscreenHooks 2023-04-01 12:06:58 +02:00
Tomas Janousek
d86f9ade22 Add X.A.ToggleFullFloat - state-remembering fullscreen hooks
Fixes: https://github.com/xmonad/xmonad-contrib/issues/456
Related: https://github.com/xmonad/xmonad-contrib/issues/394
Related: https://github.com/xmonad/xmonad-contrib/pull/626
2023-04-01 12:06:58 +02:00
Tomas Janousek
2dcc3a92e7 X.H.EwmhDesktops: Add (un)fullscreen hooks
Fairly straightforward, just add two hooks for (un)fullscreening. There
are multiple motivations for this:

* Users are calling for unfullscreened windows to revert back to their
  original location if they were floating.

* XMonad.Layout.Fullscreen uses some deprecated exports from
  XMonad.Hooks.EwmhDesktops and reimplements fullscreenEventHook.

This commit only adds the hooks. Neither of the motivations are dealt
with yet, so the docs are a bit terse still.

Related: https://github.com/xmonad/xmonad-contrib/issues/456
Related: https://github.com/xmonad/xmonad-contrib/issues/394
Related: https://github.com/xmonad/xmonad-contrib/pull/626
2023-04-01 12:06:58 +02:00
Tony Zorman
815a595b46 stack: Bump resolver to lts-20.16
We test against 9.2.7 now, so we should make our stack config reflect
that—plus, it's more convenient for users, since one is more likely to
already have the latest minor version of GHC installed.

Related: 67064ddd9264bbe39d6fa88fd8336086817dd0db
2023-03-31 07:50:09 +02:00
Tony Zorman
1d84db959c ci: Bump 9.2 and 9.4 minor versions
The stack CI already tests against 9.2.7 instead of 9.2.5 (as the cabal
file said), since we just specify the major version of the LTS resolver,
and lts-20 is up to 9.2.7 by now. Not much has changed since 9.2.5, but
update the haskell-ci workflow regardless. Likewise, 9.4 can be bumped
one minor version, so do that as well.
2023-03-31 07:48:02 +02:00
Tony Zorman
f127f71c91 X.Prompt: Alias C-m to RET in Emacs/Vim bindings
Both programs interpret C-m as RET, so the prompt should reflect this as
well.
2023-03-29 08:26:20 +02:00
Tony Zorman
fb63987ac8 X.Prompt: Factor out how to accept the current selection 2023-03-29 08:22:26 +02:00
Tony Zorman
635711e994 ci: Test against GHC 9.6.1
+ Regenerate haskell-ci and adjust relevant patches.
  - Remove haskell-ci-dependabot.patch, as it is no longer necessary.

Related: https://github.com/xmonad/xmonad-contrib/issues/805
2023-03-28 07:53:09 +02:00
Tony Zorman
4929da0eac CI: Fix build with mtl-2.3.1
Technically, contrib still does not build with stack, as it forces
xmonad-0.17.0, while only HEAD builds with newer mtl versions.  However,
until our dependencies are at least revbumped, this may be the best we
can do.

Related: https://github.com/xmonad/xmonad-contrib/issues/805
2023-03-27 08:17:36 +02:00
Tony Zorman
e60805bd45
Merge pull request #804 from xmonad/dependabot/github_actions/cachix/install-nix-action-20
build(deps): bump cachix/install-nix-action from 19 to 20
2023-03-06 18:39:48 +01:00
dependabot[bot]
49edaf37fd
build(deps): bump cachix/install-nix-action from 19 to 20
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 19 to 20.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v19...v20)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-06 17:08:28 +00:00
Tomáš Janoušek
5324f53501
Merge pull request #802 from geekosaur/801-dynamicLogString
`dynamicLogString` forces its result and recovers
2023-02-20 21:45:42 +00:00
brandon s allbery kf8nh
4a97716d59
dynamicLogString forces its result and recovers
Originally, `dynamicLogString` could have a bottom hidden in it and
thereby crash the `logHook`. Under some circumstances (see #801)
this could cause xmonad to get stuck. We now force the result, and
`dynamicLogString` catches the exception and substitutes a
message (currently "_|_"). Use `dynamicLogString'` for the old behavior.
2023-02-20 16:39:49 -05:00
Tony Zorman
6063855a3e X.P.OrgMode: Simplify refile 2023-02-18 13:23:15 +01:00
Yecine Megdiche
1bcdbc9072
Merge pull request #800 from 1in1/master
Add loggers for window classname
2023-02-13 10:49:07 +01:00
l
2dd3c614e2 add loggers for window classname 2023-02-12 11:17:32 +00:00
Leary
6b19388139
Merge pull request #784 from LSLeary/focus-tracking
Extract redundant layouts into new module: X.L.FocusTracking
2023-02-12 20:36:32 +13:00
L. S. Leary
a52e646cc1 Extract redundant layouts into new module: X.L.FocusTracking
X.L.StateFull's `FocusTracking` and the eponymous `TrackFloating` were
redundant, hence the former was slated for deprecation. However,
the latter and its host module are somewhat poorly named; the layout
modifier has little relation to floats. As such, it's renamed and
rehosted, becoming the eponymous `FocusTracking`.

The redundant offerings in the original modules are redefined in terms
of the new module where possible, and deprecated.

See: #418; comments on #253, #783.
2023-02-12 20:20:52 +13:00
brandon s allbery kf8nh
29f0e03256 Config modifiers infixl 4 so you can use (++) 2023-02-09 03:52:58 -05:00
dependabot[bot]
726e887239 build(deps): bump cachix/install-nix-action from 18 to 19
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 18 to 19.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v18...v19)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-06 20:48:12 +00:00
Tony Zorman
6fba80168d
Merge pull request #796 from slotThe/fix/named-actions/key-overwriting
X.U.NamedActions: Do not discard all keybindings in addDescrKeys
2023-01-29 08:24:47 +01:00
Tony Zorman
90f4a96f93 X.U.NamedActions: Do not discard all keybindings in addDescrKeys
Discarding keybindings may yield unintended behaviour when keybindings
are added via combinators, instead of the `keys` field.  This makes the
combinators noncommutative, which is very counterintuitive.

Related: https://old.reddit.com/r/xmonad/comments/10g1v1r/deftogglestrutskey_not_working/
2023-01-27 20:34:43 +01:00
Tony Zorman
33c1e24288
Merge pull request #794 from slotThe/ezconfig/remapkeysp
X.U.EZConfig: Add remapKeysP
2023-01-25 21:02:51 +01:00
Tony Zorman
49904ec4d3 X.U.NamedScratchpad: Fix typo in exclusive docs
Fixes: f059829f03
2023-01-25 07:49:05 +01:00
Tony Zorman
339dbbf2fd
Merge pull request #795 from TheMC47/feat/start-sbs
X.H.StatusBar: Added startAllStatusBars
2023-01-24 20:35:34 +01:00
Yecine Megdiche
6caba97b34 X.H.StatusBar: Added startAllStatusBars 2023-01-24 20:34:58 +01:00
Tony Zorman
0afbbf9129 X.U.EZConfig: Add remapKeysP 2023-01-21 07:05:08 +01:00
Tony Zorman
df1fc2d334 X.A.Search: Export noogle
Fixes: 7665b67ff4f90343324ad11618324892a902b184
2023-01-18 20:42:45 +01:00
Tony Zorman
7665b67ff4 X.A.Search: Add noogle 2023-01-18 17:56:57 +01:00
Tony Zorman
a790c816d2
Merge pull request #766 from LSLeary/repeatable
Factor X.A.Cycle* modules; Write Alt+Tab style window switching
2023-01-14 15:29:50 +01:00
L. S. Leary
b9263ad17e Write new module: X.A.MostRecentlyUsed 2023-01-12 17:53:26 +01:00
L. S. Leary
8f0912a674 Write new module: X.U.History 2023-01-12 17:52:58 +01:00
L. S. Leary
dd7855da3d Factor shared logic out of X.A.Cycle* modules
These modules were duplicating a substantial amount of low-level code.

`X.A.CycleWorkspaceByScreen` had already separated most of the
implementation details from the logic with `repeatableAction`; all that
was left was to generalise it a little further, put it in a suitable
place and express the other modules through it.
2023-01-12 17:52:18 +01:00
Tony Zorman
e85f0151b2 X.A.VisualSubmap: Fix example 2023-01-11 16:50:42 +01:00
Tony Zorman
840d740366
Merge pull request #792 from TheMC47/master
README: update badge URLs
2023-01-06 19:03:42 +01:00
Yecine Megdiche
a5bd5d96ca README: update badge URLs
See https://github.com/badges/shields/issues/8671
2023-01-06 13:44:16 +01:00
Tony Zorman
4e8857ecee
Merge pull request #791 from pbrisbin/pb/desktop-viewport
Add EWMH configuration to not set _NET_DESKTOP_VIEWPORT
2023-01-05 07:51:37 +01:00
patrick brisbin
cf13f8f9a7 X.H.EwmhDesktops: Add disableEwmhManageDesktopViewport
This combinator forces XMonad to *not* set _NET_DESKTOP_VIEWPORT.

This information is picked up by polybar's xworkspaces module and used
to re-group the workspaces by monitor. I (and others) find this super
confusing, but polybar doesn't not seem open to addressing it.

https://github.com/polybar/polybar/issues/2603

Opting in to the old behavior of not managing this property is one way
to work around it instead.
2023-01-05 07:47:16 +01:00
Tomas Janousek
e2ffa533da ci: Unpin runner in hlint workflow; bump hlint to 3.5
hlint 3.5 is built against libtinfo6 and works on Ubuntu 22.04 without
needing to install libtinfo5.

Fixes: b7afb0c0bc3f ("ci: Pin runner in hlint, nix workflows to ubuntu-20.04")
2023-01-02 20:45:19 +01:00
Tomas Janousek
6b20dbca42 Apply hlint 3.5 hints 2023-01-02 20:45:19 +01:00
Tony Zorman
6117a867d9 Update CHANGES.md
Mention f7e9c0cf0d0584be1b586041580c7ec8d8d57647
2022-12-31 13:52:32 +01:00
Tony Zorman
f7e9c0cf0d X.L.ResizableThreeColumns: Fix bottom right window not resizing
...by introducing yet another special case.  Unsurprisingly, this is
just a bandaid—the logic in this module is just wrong.  It
purposefully (not introduced with this change) computes the wrong
positions for certain extreme points such that splitVertically (which
simply goes down the list of stack windows _in order_) still works.

What we should do instead is to either

  - keep track of windows that want to change their size and compute a
    rectangle for them first, or

  - immediately when handling the resize message, compute *all* of the
    new sizes immediately (instead of only for the window getting
    resized).

The latter would force us to keep track of the size of the current stack
we operate in, but since 'handleMessage' lives in X this should not pose
a big problem.  I reckon this is the better approach.

Fixes: https://github.com/xmonad/xmonad-contrib/issues/788
2022-12-31 13:33:36 +01:00
Tony Zorman
e0be851074 X.L.ResizableThreeColumns: Change terminology
For everything, except the exported fields.  Perhaps we should change
these as well, but that's for another commit.
2022-12-31 13:33:36 +01:00
Tony Zorman
55855ccb5f
Merge pull request #785 from geekosaur/debugwindow-fix-netwm
fix EWMH titles
2022-12-28 16:43:41 +01:00
brandon s allbery kf8nh
4df2036187 remove references to baseConfig
that's from my private config and has no referent here
2022-12-12 16:16:45 -05:00
brandon s allbery kf8nh
4998e946cc
fix EWMH titles
I have no idea what I was thinking when I wrote that code.
While at it, just reused the code for ICCCM title which already
assumes the client may have broken the rules (I think we have
seen a case of `WM_NAME` being `UTF8_STRING`).
2022-12-12 13:30:42 -05:00
Tomas Janousek
04c0ddd3e0 ci: Cabal install packdeps outside of project dir
Invoking cabal in the project directory with a cabal.project file might
fail on unrelated dependencies missing, see
4f539734be

Doesn't fail in this repo, but let's keep the workflows in sync.
2022-12-03 13:15:48 +00:00
Tomas Janousek
b7afb0c0bc ci: Pin runner in hlint, nix workflows to ubuntu-20.04
Both are now broken with ubuntu-22.04. Nix:

    error: could not set permissions on '/nix/var/nix/profiles/per-user' to 755: Operation not permitted

hlint:

    /opt/hostedtoolcache/hlint/3.4.1/x64/hlint: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
2022-12-01 12:09:25 +00:00
Tomas Janousek
18eca4e8d6 ci: Drop ppa:hvr/ghc
Breaks `apt update` on the ubuntu-22.04 runner, which is what
ubuntu-latest resolves to these days.

Fixes: 7312d6f3f3f7 ("ci: Drop GHC installation via apt")
2022-12-01 12:06:17 +00:00
dependabot[bot]
797fd24112 build(deps): bump haskell/actions from 1 to 2
Bumps [haskell/actions](https://github.com/haskell/actions) from 1 to 2.
- [Release notes](https://github.com/haskell/actions/releases)
- [Commits](https://github.com/haskell/actions/compare/v1...v2)
2022-11-27 17:42:25 +00:00
Tomáš Janoušek
cf0e3531f9 ci: Configure dependabot to keep GH Actions up to date 2022-11-27 17:42:25 +00:00
Tomas Janousek
8cd09601b1 ci: Bump actions/* to v3 in haskell-ci workflow
This gets rid of the deprecation warnings about
https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
2022-11-27 17:42:25 +00:00
Tomas Janousek
0bd43c072f ci: Update to GHC 9.4.3 2022-11-27 17:42:25 +00:00
Tony Zorman
10c1a93963 X.U.NamedScratchpads: Check for "new" workspace in nsHideOnFocusLoss
When XMonad was recently restarted, it can happen that the workspace
history is empty, hence the last focused window could actually be the
currently focused one.  In that case, we don't want to go through the
machinery of looking to hide any NSPs, as there is only one window in
the current workspace (the focused one).  This may or may not be a
scratchpad, we don't care.

Fixes: https://github.com/xmonad/xmonad-contrib/issues/779
2022-11-20 17:06:35 +01:00
Tony Zorman
58e7f6d3c3
Merge pull request #778 from slotThe/drop-8.4
Drop GHC 8.4
2022-11-20 17:01:48 +01:00
Tony Zorman
502f6a0e75 X.P.OrgMode: Fix deprecation warning
Starting with time-1.10, the iso8601DateFormat function was deprecated
in favour of more sophisticated methods for showing ISO 8601 date
formats—as such, follow the libraries lead.

Sadly, the new functionality was only introduced in time-1.9, meaning
GHC 8.8 and up.  Since we still support 8.6, the introduction of some
CPP is necessary.
2022-11-20 16:53:36 +01:00
Tony Zorman
35e434ed85 stack: Bump resolver to lts-20.0 2022-11-20 16:53:36 +01:00
Tony Zorman
b96bb908db Simplify instance declarations
Many instance declarations can now be derived either by DerivingVia or
GeneralizedNewtypeDeriving.
2022-11-20 16:53:36 +01:00
Tony Zorman
5d0013ef53 ci: Drop support for GHC 8.4
Debian stable and Ubuntu 20.04 are now 8.8 and 8.6, respectively, which
was always our guide as to which GHC versions we want to support.
2022-11-20 16:53:06 +01:00
Tony Zorman
0f69215fc8 ci: Update to GHC 9.2.5
+ A new stackage LTS is out with GHC 9.2.5, so test for this.
+ Update the haskell-ci jobs accordingly from 9.2.4.
2022-11-19 09:18:35 +01:00
Tony Zorman
57b5055858 X.A.Search: Add arXiv, clojureDocs, cratesIo, rustStd, zbmath
Related: 233a05908d6953be79f02a030ab5f20272357630
         (https://github.com/xmonad/xmonad-contrib/pull/777)
2022-11-15 09:29:08 +01:00
Tony Zorman
af5fced79a X.A.Search: voidpackages -> voidpgks_x86_64{_musl}
Musl on Void is popular enough that it makes sense to provide an extra
search engine for it.

Related: https://github.com/xmonad/xmonad-contrib/pull/777/files
2022-11-13 10:16:23 +01:00
Tony Zorman
d7499d1db0 CHANGES: Reindent
Fixes: https://github.com/xmonad/xmonad-contrib/pull/777
2022-11-13 10:04:19 +01:00
Luc-Saccoccio
233a05908d Added AUR, Flora, nCatLab, ProtonDB, RosettaCode, Sourcehut, Steam, Void
Linux packages. Reorganized the list, and added wiktionary which was
forgotten in the list although it was implemented.
2022-11-12 12:43:12 -05:00
Tony Zorman
e406e27139
Merge pull request #774 from slotThe/nsp/exclusive
X.U.NamedScratchpad: Add exclusive scratchpad capabilities
2022-11-11 21:06:10 +01:00
Tony Zorman
1c6ae39fc9 X.P.OrgMode: Also parse time in HHMM format 2022-11-10 11:50:28 +01:00
Tony Zorman
b627306772 X.P.OrgMode: Include 00:xx and xx:00 in the date range 2022-11-10 11:49:46 +01:00
Tony Zorman
8b4560dc1e X.P.OrgMode: Parse dates case-insensitively 2022-11-10 11:49:46 +01:00
L. S. Leary
608a8e4b88 Fix documentation bug in X.A.GridSelect 2022-11-08 23:02:51 +13:00
Tony Zorman
6373dc41fa
Merge pull request #772 from ilya-bobyr/master
EwmhDesktops: _NET_CLIENT_LIST_STACKING: In focus order
2022-11-07 08:01:52 +01:00
Tony Zorman
8cb789af39 CI: Compatibility with mtl 2.3.1
Libraries like Control.Monad are no longer exported from
Control.Monad.Reader et.al.

Related: https://github.com/xmonad/xmonad/pull/427
         xmonad/xmonad#d170e99bc5e97db96be9a02b72149103e8d419af
2022-11-03 08:25:00 +01:00
Illia Bobyr
cf975d082e
EwmhDesktops: _NET_CLIENT_LIST_STACKING: In focus order
Order workspaces based on the visibility, before collecting windows.
`_NET_CLIENT_LIST_STACKING` is supposed to be in the focus order.
2022-11-02 11:03:08 -07:00
Tony Zorman
e0d1f177ea
Merge pull request #773 from aplaice/broken_links_doc
Fix some more broken inter-module docs links
2022-11-02 15:50:32 +01:00
Tony Zorman
bb9d6edad6 CHANGES: Re-indent newest changes
To conform with the style that all of the other changes (and the
breaking changes of the same release) have.
2022-11-02 11:17:51 +01:00
Tony Zorman
ab6299a488 X.U.ExclusiveScratchpads: Deprecate
Obsoleted by the exclusive scratchpad functionality of X.U.NSP.
2022-11-02 11:17:51 +01:00
Tony Zorman
226629977b X.U.NamedScratchpad: Add documentation about other types
With [1] and now [2], NSP has a lot more functionality that used to be
confined to other modules.  This is indicated in the TOC when viewing
the documentation, but it should perhaps be more prominently mentioned
in the introduction/usage docs.

[1]: https://github.com/xmonad/xmonad-contrib/pull/690
     533e17135e953938834551558062566a73e1ae2c
[2]: https://github.com/xmonad/xmonad-contrib/pull/774
2022-11-02 11:17:51 +01:00
Tony Zorman
f059829f03 X.U.NamedScratchpad: Add exclusive scratchpad capabilities 2022-11-02 11:17:51 +01:00
Tony Zorman
49e9570f12 X.U.NamedScratchpad: Factor out isNSP
This function can be pretty useful in a general context, so let's factor
it out.
2022-11-02 11:17:49 +01:00
Tony Zorman
48a6d34f55 X.Prelude: Add findM
Several definitions of this were scattered over a few modules, so just
re-export it from our prelude.
2022-11-02 11:17:26 +01:00
Adam Plaice
ca866229f6 Fix most remaining broken inter-module docs links
The links were broken due to:

1. Incorrect quotes (' instead of " for module links and occasionally
vice-versa).

2. Changes in the name of the "target" module not reflected in the
"source" docs.

3. Typos to begin with.

4. Use of `<foo>` in the docs is rendered as just `foo` with a link to
`/foo`.

5. Similarly for `"Foo"` if it starts with a capital letter (and hence
could be a module).

6. Markup inside `@` code blocks still being applied.

e.g. `@M-<arrow-keys>@` is rendered as `M-arrow-keys` with a spurious
hyperlink from arrow-keys to `/arrow-keys`, which is confusing.

Three links from XMonad.Util.Run have been removed outright, since
they're no longer examples of the usage of 'runProcessWithInput'.
WmiiActions has been gone since 2008, while XMonad.Prompt.Directory
and XMonad.Layout.WorkspaceDir haven't been using
'runProcessWithInput' since 2020 and 2012, respectively.

In some cases the `<foo>` were surrounded with @, especially in the
case of key definitions, for consistency.  (This wasn't done
everywhere, because it looks ugly in the source.)

MoreManageHelpers has never been in xmonad-contrib.  ManageHelpers
seems to fill the expected role.

In the case of the module description for X.H.ManageDebug the quotes
were simply removed because none of the likely options to make the
link work were successful.
2022-11-01 19:35:55 +01:00
Tony Zorman
d301affabb
Merge pull request #760 from slotThe/orgmode/refile
X.P.OrgMode: Add orgPromptRefile[To]
2022-10-31 14:38:25 +01:00
Tony Zorman
a97a1acf87 X.P.OrgMode: Remove the need for todoKeywords argument
This is (i) much simpler to use and (ii) helps us with refiling.  Emacs
will ignore todo keywords _that it knows_ when refiling, but when
started in batch-mode it doesn't know a whole lot.  One would need to
thread the `todoKeywords' through to `refile' and then set
`org-todo-keywords' or a similar variable, which does not sound like a
good experience.  Hence, falling back to showing the todo keyword to the
user when deciding upon a headline sounds acceptable.
2022-10-31 14:29:43 +01:00
Tony Zorman
bdb13e2551 X.P.OrgMode: Add orgPromptRefile[To]
Add orgPromptRefile and orgPromptRefileTo in order to refile entries
after insertion.
2022-10-31 14:29:43 +01:00
Tomáš Janoušek
3d0502f7b6
Merge pull request #775 from liskin/ci
CI maintenance (GHA deprecations, GHC 9.4)
2022-10-31 11:45:12 +00:00
Tomas Janousek
6880417911 ci: Fix docs tarball
haskell-ci by default passes --haddock-all to cabal v2-haddock, which
builds docs for all components and the …-docs.tar.gz tarball ends up
containing the docs for the last component, which happens to be tests.
We need the tarball to contain the library docs, for upload to Hackage.

Fixes: 7cee1915169d ("CI: Remove hlint from haskell-ci")
2022-10-30 23:01:41 +00:00
Tomas Janousek
c4dca3592e Appease -Werror=type-equality-requires-operators
GHC 9.4 complains:

    The use of ‘~’ without TypeOperators
    will become an error in a future GHC release.
2022-10-30 21:52:10 +00:00
Tomas Janousek
4242fa02a0 ci: Add GHC 9.4 to tested-with matrix (haskell-ci workflow)
(Also bump 9.2 to 9.2.4)
2022-10-30 21:37:23 +00:00
Tomas Janousek
f81b9fb725 ci: Bump cachix/install-nix-action to v18
This gets rid of the deprecation warnings about
https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
2022-10-30 21:24:46 +00:00
Tomas Janousek
b0b8e4fb2c ci: Bump actions/{checkout,cache} to v3
This gets rid of the deprecation warnings about
https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
2022-10-30 21:20:21 +00:00
Tomas Janousek
7312d6f3f3 ci: Drop GHC installation via apt
The apt repo hosting these packages has been unmaintained for quite a
while, and we've excluded ~/.stack/programs from the cache long time
ago, so we can just let stack handle the installation. It's not much
slower than installing via apt, and even if it was, some matrix jobs
need to use the slow path anyway.

Related: 9fce3805fcf2 ("ci: Use system GHC in Stack to not waste GH Actions cache space")
Related: 7d10e470d71d ("ci: Avoid caching GHC")
2022-10-30 21:19:16 +00:00
Tomas Janousek
b75ed7295c ci: Replace deprecated GHA set-output command
See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
2022-10-30 21:11:20 +00:00
Tony Zorman
c27a1f0791
Merge pull request #770 from slotThe/bikeshed/dynamicproperty
New module: XMonad.Hooks.OnPropertyChange
2022-10-29 14:48:43 +02:00
Tony Zorman
eaab5bfbba New module: XMonad.Hooks.OnPropertyChange
This is the same module as X.H.DynamicProperty, just with (hopefully)
more discoverable names.

Closes: https://github.com/xmonad/xmonad-contrib/issues/588

Co-authored-by: Tomas Janousek <tomi@nomi.cz>
2022-10-29 14:42:48 +02:00
Tony Zorman
fce5558b62
Merge pull request #769 from aplaice/spawnonce_doc_link
Fix broken link in doc for XMonad.Util.SpawnOnce
2022-10-27 07:45:48 +02:00
Adam Plaice
2ab520eeda Fix inter-module link (use " instead of ')
Otherwise, haddock tries to link to a (non-existent) function in
"XMonad.Util", which gives a "page not found".

See:

https://haskell-haddock.readthedocs.io/en/latest/markup.html#
linking-to-modules
2022-10-26 21:19:29 +02:00
Tony Zorman
cd95bf9c28 X.P.OrgMode: Return "exitCode" mkOrgPrompt
More formally, return whether the user cancelled the prompt or not.
This is useful in case we want to do things only after a "successful"
input.
2022-10-26 20:25:53 +02:00
Tony Zorman
b9c8294045 X.P.OrgMode: Add mkOrgCfg
This ensures that we always immediately expand the file path upon
constructing an `OrgMode' record.  We thus do not have to do this in
`mkOrgPrompt' anymore.
2022-10-26 20:25:53 +02:00
Tony Zorman
2ffc5de6cf X.U.Run: Don't use elispFun in progn
This is already taken care of by execute and eval, so forcing it in
progn only hampers composability.
2022-10-26 20:25:53 +02:00
Tony Zorman
08071706ba X.U.Run: Add list, saveExcursion 2022-10-26 20:25:53 +02:00
Tony Zorman
f55502f723
Merge pull request #765 from slotThe/hlint-workflow
Create HLint workflow
2022-10-25 08:55:14 +02:00
Tony Zorman
7cee191516 CI: Remove hlint from haskell-ci
As we have a proper hlint action now, this is no longer needed.
2022-10-25 08:49:23 +02:00
Tony Zorman
dd26fcc3f1 CI: Add hlint workflow
Closes: https://github.com/xmonad/xmonad-contrib/issues/669
2022-10-25 08:49:23 +02:00
Tony Zorman
571d017b82
Merge pull request #763 from slotThe/extending->tutorial
A Potpourri of Small Changes
2022-10-21 09:24:46 +02:00
Tony Zorman
570eb8ccb8 X.A.Navigation2D: Add sideNavigation as to default tiled navigation
Add sideNavigation as a fallback if needed.  This should not have any
user-facing behaviour change when not using gaps or spacing, as line
navigation is preferred.  However, users who do use spacing or gaps
should now potentially not have to change the default strategy in order
to have a usable module.
2022-10-21 09:18:06 +02:00
Tony Zorman
cca2ccfc71 X.A.Navigation2D: More prominently document strategies
Also, add a note that users who use gaps or spacing may need to look
into these strategies a bit more deeply.

Fixes: https://github.com/xmonad/xmonad-contrib/issues/627
2022-10-21 09:18:06 +02:00
Tony Zorman
41d6ac96d5 X.H.InsertPosition: Add combinator
Users may not see the warning that insertPosition definitely needs to be
inserted at the leftmost position, which can cause undesired behaviour.
Having a combinator that handles this automatically seems like a sane
idea.

Fixes: https://github.com/xmonad/xmonad-contrib/issues/709

       (Note that `docs` wasn't changed since it already inserts itself
       rightmost.)
2022-10-21 09:18:06 +02:00
Tony Zorman
4c8edd3bfb X.A.FloatKeys: Add direction{Move,Resize}Window
These are simpler, more easily understood, alternatives to the existing
functions.

Fixes: https://github.com/xmonad/xmonad-contrib/issues/712
2022-10-21 09:18:04 +02:00
Tony Zorman
3d65a6bf72 Refer to the tutorial instead of X.D.Extending more often
Essentially, whenever the tutorial actually has decent material on the
subject matter.  The replacement is roughly done as follows:

  - logHook → tutorial
  - keybindings → tutorial, as this is thoroughly covered
  - manageHook → tutorial + X.D.Extending, as the manageHook stuff the
    tutorial talks about is a little bit of an afterthought.
  - X.D.Extending (on its own) → tutorial + X.D.Extending
  - layoutHook → tutorial + X.D.Extending, as the tutorial, while
    talking about layouts, doesn't necessarily have a huge focus there.
  - mouse bindings → leave this alone, as the tutorial does not at all
    talk about them.
2022-10-21 09:17:43 +02:00
Tony Zorman
05c4c776af
Merge pull request #759 from slotThe/parser/feature-parity
X.U.Parser: Achieve feature parity with ReadP
2022-10-17 17:23:44 +02:00
Tony Zorman
2b1a15c9e5 X.P.OrgMode: Remove pLast
Use the more aptly named `option` instead.
2022-10-17 14:04:43 +02:00
Tony Zorman
0bef428f8f X.U.Parser: Inline definitions
Most of these definitions are probably small enough to be inlined on
their own, but tell GHC to try really hard regardless.  This is commonly
done by other parser libraries as well; e.g., [1], so it shouldn't cause
any issues either way.

[1]: https://hackage.haskell.org/package/parsers-0.12.11
2022-10-17 14:04:43 +02:00
Tony Zorman
4d7ae81f7a X.U.Parser: Feature parity with ReadP
While not many of these more exotic combinators are used right now, it's
still nice to have feature parity (i.e., everything that one could want
from a basic parser) such that people don't have to add their own
combinators, in case they want to use one that's not already
implemented.
2022-10-17 14:04:43 +02:00
Tony Zorman
7d4f0aaece
Merge pull request #761 from exorcist365/master
X.H.Modal: Remove `Keys` type alias
2022-10-14 07:24:02 +02:00
exorcist365
4734551c76 X.H.Modal: Remove Keys type alias
This was only used in three places throughout the module and is sort of
non-standard terminology, hence it might confuse users.  Talking about
functions of type

    XConfig Layout -> M.Map (ButtonMask, KeySym) (X ())

is relatively standard in other modules as well, so it's probably best
to remove the type alias for it.
2022-10-14 07:20:42 +02:00
Tony Zorman
865c63a361 X.U.Run: Add executeNoQuote 2022-10-11 19:22:40 +02:00
Tomas Janousek
c3ea62c972 CHANGES: Fix thinko in module name 2022-10-05 22:21:23 +01:00
Tomas Janousek
005951535b CHANGES: Fix whitespace and misplaced underscores 2022-10-05 22:17:57 +01:00
Tony Zorman
ecd052b7fd
Merge pull request #410 from slotThe/remove-deprecations
Remove (more) Deprecations, Properly Deprecate Modules
2022-10-04 07:10:18 +02:00
Tony Zorman
e15f2d17e5
Merge pull request #758 from alexandersokolow/master
expose more messages in MouseResizableTile layout
2022-09-30 11:38:38 +02:00
alexandersokolow
9e55ae9184 expose more messages in MouseResizableTile layout 2022-09-29 19:43:28 +02:00
L. S. Leary
b9794e6a13 Fix documentation bug in X.U.NSP
The Usage section made reference to a non-existent
`namedScratchpadSpawnAction` function. It has been replaced with
`namedScratchpadAction` in accordance with the documented bindings
below.
2022-09-23 19:21:48 +12:00
slotThe
1e3b49f064 CHANGES: Mention deprecations and removals
This reflects the changes made in the following previous commits:

  - f02b3a98691d4c51bd8ea2171d6a7ce9a94064a3
  - 3bf9d80c40b9ec8f2900fe9fffa4fc17627b5b0d
  - 4a8bd762afd5c25df716d1e66201490761bddb70
  - d28c0a242517e12eb6958d3ed27e5c2d94bbb16f
  - 6f49a9394f542a54fc70c82c0705df68bf5ed5eb
  - 287b8bf95f0400b382a238b07e37c414d564a7c4
  - d8a23d47bfbcb88678e7fe8b5d7af708aecf6024
  - 16701c2df2990f92a9ffbb13e8532ce7e3f4d9e1
  - 6ab4d9c0bc1256f8d4892afcee97cce3b1b76890
2022-09-22 07:59:14 +02:00
slotThe
f02b3a9869 XMonad.Actions.SinkAll: Deprecate 2022-09-22 07:51:52 +02:00
slotThe
3bf9d80c40 XMonad.Layout.Named: Deprecate 2022-09-22 07:51:52 +02:00
slotThe
4a8bd762af XMonad.Hooks.RestoreMinimized: Remove 2022-09-22 07:39:54 +02:00
slotThe
d28c0a2425 XMonad.Layout.LayoutBuilderP: Remove 2022-09-22 07:39:54 +02:00
slotThe
6f49a9394f XMonad.Hooks.ICCCMFocus: Remove 2022-09-22 07:39:54 +02:00
slotThe
287b8bf95f XMonad.Layout.Navigation2D: Remove deprecations 2022-09-22 07:39:54 +02:00
slotThe
d8a23d47bf XMonad.Layout.Spacing: Remove deprecations 2022-09-22 07:39:54 +02:00
slotThe
16701c2df2 XMonad.Actions.MessageFeedback: Remove deprecations 2022-09-22 07:39:54 +02:00
slotThe
6ab4d9c0bc XMonad.Prompt.Window: Remove deprecations 2022-09-22 07:39:54 +02:00
Tony Zorman
24f11362c7 docs: Add additional external blog posts
This may seem a bit self-indulgent, but both of these features are
either quite new or so old that no one remembers them anymore, so not a
lot of up-to-date content exists for them.
2022-09-22 07:37:28 +02:00
Tony Zorman
a267fed24f
Merge pull request #757 from slotThe/deprecate-sp
X.U.Scratchpad: Deprecate
2022-09-20 11:54:32 +02:00
Tony Zorman
a44df170f4 X.U.Run: Add findFile 2022-09-19 09:43:42 +02:00
Tony Zorman
2ebbe57bc2 X.U.Run: Quote string in execute and eval
Ordinarily, this should already be the case.  If for some reason it is
not, definitely make sure to quote the input string that we want to
execute.
2022-09-19 09:43:42 +02:00
Tony Zorman
ea16598a78 X.U.Scratchpad: Deprecate
This is i) broken and ii) just the functionality of X.U.NamedScratchpad
rewrapped (and not necessarily improved upon) at this point.

With recent changes to the way named scratchpads work[1], we would have
to export internals of X.U.NamedScratchpad in order to restore
X.U.Scratchpad to its full functionality.  This does not seem worth it,
as the latter does not bring anything substantially new to the table.

Closes: https://github.com/xmonad/xmonad-contrib/issues/756
Related: https://github.com/xmonad/xmonad-contrib/issues/591
[1]: 3fc830aa09368dca04df24bf7ec4ac817f2de479
2022-09-18 17:29:26 +02:00
Tony Zorman
4a3f8eb032 X.U.Font: Add a fallback font to initXMF
In case a font could not be opened, simply fall back to "xft:monospace"
and open that.  The initCoreFont and initUtf8Font functions already have
mechanisms like this, is was just missing from initXMF.

Closes: https://github.com/xmonad/xmonad-contrib/issues/723
2022-09-15 19:02:26 +02:00
Tony Zorman
b0fc55499d
Merge pull request #754 from Quoteme/master
made borderresize take a parameter
2022-09-10 16:30:15 +02:00
Luca Leon Happel
ae652b40f4 X.L.BorderResize: Add borderResizeNear
TODO
The parameter is how many pixels near the border of a window resizing
will be possible
2022-09-10 16:20:35 +02:00
Tony Zorman
8a6542f6b3
Merge pull request #751 from slotThe/x.d.extending/round-two
X.D.Extending: Round Two
2022-09-08 13:10:31 +02:00
Tony Zorman
5378e93e15 X.D.Extending: Remove keyAddDel and logHook
+ $keyAddDel can just be a side note in $keyDel, it does not need its
  own section.

+ $logHook is covered in more detail in the tutorial and does not serve
  a real purpose anymore.  One could rewrite it to be more in-depth
  about the inner workings of X.H.StatusBar, but for the time removing
  it seems like the best option.

Closes: https://github.com/xmonad/xmonad-contrib/issues/645
2022-09-08 13:09:55 +02:00
Tony Zorman
cedb8d7c78 X.D.Extending: Rewrite keyDel
Nowadays, removing keys is mostly done via removeKeys and removeKeysP,
so the documentation should reflect that fact.  This part is less
step-by-step instructive than the section about adding keys, but read in
succession it presents a way to deepen the newly acquired knowledge.
2022-09-08 13:09:55 +02:00
Tony Zorman
9809b2013f X.D.Extending: Update hooks
+ Refer to X.H.StatusBar whenever possible at the start.
+ Fix some small typos throughout the module.

Related: https://github.com/xmonad/xmonad-contrib/issues/645
2022-09-08 13:09:55 +02:00
Tony Zorman
9b6bef7e9d X.D.Extending: Add links to headings
This is more ergonomic to use than the old-style headings; plus, the
generated Haddock is easier to read than just stating
"XMonad.Doc.Extending".
2022-09-06 20:16:21 +02:00
Tony Zorman
fd5970fb34 NIX.md: Suggest a recent revision of GHC 9.2
Lest anyone run into https://github.com/xmonad/xmonad/issues/389.
2022-09-05 19:05:27 +02:00
Tony Zorman
b0ca330d08
Merge pull request #750 from LSLeary/nixflake
Fixes and Workarounds in flake.nix, Documentation in NIX.md
2022-09-05 17:50:56 +02:00
L. S. Leary
edf8e2526d flake.nix:
* Support comp.nix.
  * Re-order overlays and modules dependency-last for sanity.
  * Re-export `xmonad.modernise`.
NIX.md:
  * Document comp.nix.
  * Simplify example system flake, removing direct dependency on the
    xmonad flake.
  * Advise sane module ordering.
  * Include and document `modernise` workaround.
  * Clarify user-substituted `<foo>` values.
.gitignore:
  * Include nix 'result' symlink.
2022-09-05 20:57:17 +12:00
Tomas Janousek
d0d222e974 Bump version to 0.17.1.9 and prepare CHANGES.md sections 2022-09-03 16:25:12 +01:00
Tony Zorman
c688975625 CHANGES: Fix date for 0.17.1 release
Derp.
2022-09-03 16:50:41 +02:00
301 changed files with 9516 additions and 2871 deletions

6
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

View File

@ -37,33 +37,43 @@ set in GitHub repository secrets.
jobs: jobs:
linux: linux:
name: Haskell-CI - Linux - ${{ matrix.compiler }} name: Haskell-CI - Linux - ${{ matrix.compiler }}
@@ -31,6 +38,7 @@ @@ -33,6 +40,7 @@
compilerVersion: 9.0.2 compilerVersion: 9.8.4
setup-method: ghcup setup-method: ghcup
allow-failure: false allow-failure: false
+ upload: true + upload: true
- compiler: ghc-8.10.7 - compiler: ghc-9.6.7
compilerKind: ghc compilerKind: ghc
compilerVersion: 8.10.7 compilerVersion: 9.6.7
@@ -209,8 +217,80 @@ @@ -257,6 +265,10 @@
${CABAL} -vnormal check
- name: haddock - name: haddock
run: | run: |
- $CABAL v2-haddock $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all $CABAL v2-haddock --disable-documentation $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all
+ - name: haddock for hackage
+ if: matrix.upload
+ run: |
+ $CABAL v2-haddock $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH --haddock-for-hackage --builddir $GITHUB_WORKSPACE/haddock all + $CABAL v2-haddock $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH --haddock-for-hackage --builddir $GITHUB_WORKSPACE/haddock all
- name: unconstrained build - name: unconstrained build
run: | run: |
rm -f cabal.project.local rm -f cabal.project.local
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all @@ -267,3 +279,80 @@
+ - name: upload artifacts (sdist) with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
path: ~/.cabal/store
+ # must be separate artifacts because GitHub Actions are still broken:
+ # https://github.com/actions/upload-artifact/issues/441
+ # https://github.com/actions/upload-artifact/issues/457
+ - name: upload artifact (sdist)
+ if: matrix.upload + if: matrix.upload
+ uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4
+ with: + with:
+ name: sdist
+ path: ${{ github.workspace }}/sdist/*.tar.gz + path: ${{ github.workspace }}/sdist/*.tar.gz
+ - name: upload artifacts (haddock) + - name: upload artifact (haddock)
+ if: matrix.upload + if: matrix.upload
+ uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4
+ with: + with:
+ name: haddock
+ path: ${{ github.workspace }}/haddock/*-docs.tar.gz + path: ${{ github.workspace }}/haddock/*-docs.tar.gz
+ - name: hackage upload (candidate) + - name: hackage upload (candidate)
+ if: matrix.upload && github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' + if: matrix.upload && github.event_name == 'workflow_dispatch' && github.event.inputs.version != ''

View File

@ -8,9 +8,9 @@
# #
# For more information, see https://github.com/haskell-CI/haskell-ci # For more information, see https://github.com/haskell-CI/haskell-ci
# #
# version: 0.14.3 # version: 0.19.20250506
# #
# REGENDATA ("0.14.3",["github","cabal.project"]) # REGENDATA ("0.19.20250506",["github","cabal.project"])
# #
name: Haskell-CI name: Haskell-CI
on: on:
@ -26,18 +26,44 @@ on:
jobs: jobs:
linux: linux:
name: Haskell-CI - Linux - ${{ matrix.compiler }} name: Haskell-CI - Linux - ${{ matrix.compiler }}
runs-on: ubuntu-18.04 runs-on: ubuntu-24.04
timeout-minutes: timeout-minutes:
60 60
container: container:
image: buildpack-deps:bionic image: buildpack-deps:jammy
continue-on-error: ${{ matrix.allow-failure }} continue-on-error: ${{ matrix.allow-failure }}
strategy: strategy:
matrix: matrix:
include: include:
- compiler: ghc-9.2.2 - compiler: ghc-9.12.2
compilerKind: ghc compilerKind: ghc
compilerVersion: 9.2.2 compilerVersion: 9.12.2
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.10.2
compilerKind: ghc
compilerVersion: 9.10.2
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.8.4
compilerKind: ghc
compilerVersion: 9.8.4
setup-method: ghcup
allow-failure: false
upload: true
- compiler: ghc-9.6.7
compilerKind: ghc
compilerVersion: 9.6.7
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.4.8
compilerKind: ghc
compilerVersion: 9.4.8
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.2.8
compilerKind: ghc
compilerVersion: 9.2.8
setup-method: ghcup setup-method: ghcup
allow-failure: false allow-failure: false
- compiler: ghc-9.0.2 - compiler: ghc-9.0.2
@ -45,7 +71,6 @@ jobs:
compilerVersion: 9.0.2 compilerVersion: 9.0.2
setup-method: ghcup setup-method: ghcup
allow-failure: false allow-failure: false
upload: true
- compiler: ghc-8.10.7 - compiler: ghc-8.10.7
compilerKind: ghc compilerKind: ghc
compilerVersion: 8.10.7 compilerVersion: 8.10.7
@ -54,41 +79,34 @@ jobs:
- compiler: ghc-8.8.4 - compiler: ghc-8.8.4
compilerKind: ghc compilerKind: ghc
compilerVersion: 8.8.4 compilerVersion: 8.8.4
setup-method: hvr-ppa setup-method: ghcup
allow-failure: false
- compiler: ghc-8.6.5
compilerKind: ghc
compilerVersion: 8.6.5
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.4.4
compilerKind: ghc
compilerVersion: 8.4.4
setup-method: hvr-ppa
allow-failure: false allow-failure: false
fail-fast: false fail-fast: false
steps: steps:
- name: apt - name: apt-get install
run: | run: |
apt-get update apt-get update
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
if [ "${{ matrix.setup-method }}" = ghcup ]; then apt-get install -y libx11-dev libxext-dev libxft-dev libxinerama-dev libxrandr-dev libxss-dev
mkdir -p "$HOME/.ghcup/bin" - name: Install GHCup
curl -sL https://downloads.haskell.org/ghcup/0.1.17.5/x86_64-linux-ghcup-0.1.17.5 > "$HOME/.ghcup/bin/ghcup" run: |
chmod a+x "$HOME/.ghcup/bin/ghcup" mkdir -p "$HOME/.ghcup/bin"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" curl -sL https://downloads.haskell.org/ghcup/0.1.50.1/x86_64-linux-ghcup-0.1.50.1 > "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0 chmod a+x "$HOME/.ghcup/bin/ghcup"
apt-get update - name: Install cabal-install
apt-get install -y libx11-dev libxext-dev libxft-dev libxinerama-dev libxrandr-dev libxss-dev run: |
else "$HOME/.ghcup/bin/ghcup" install cabal 3.14.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
apt-add-repository -y 'ppa:hvr/ghc' echo "CABAL=$HOME/.ghcup/bin/cabal-3.14.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
apt-get update - name: Install GHC (GHCup)
apt-get install -y "$HCNAME" libx11-dev libxext-dev libxft-dev libxinerama-dev libxrandr-dev libxss-dev if: matrix.setup-method == 'ghcup'
mkdir -p "$HOME/.ghcup/bin" run: |
curl -sL https://downloads.haskell.org/ghcup/0.1.17.5/x86_64-linux-ghcup-0.1.17.5 > "$HOME/.ghcup/bin/ghcup" "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
chmod a+x "$HOME/.ghcup/bin/ghcup" HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0 HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
fi HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
env: env:
HCKIND: ${{ matrix.compilerKind }} HCKIND: ${{ matrix.compilerKind }}
HCNAME: ${{ matrix.compiler }} HCNAME: ${{ matrix.compiler }}
@ -99,28 +117,12 @@ jobs:
echo "LANG=C.UTF-8" >> "$GITHUB_ENV" echo "LANG=C.UTF-8" >> "$GITHUB_ENV"
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV" echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV" echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
HCDIR=/opt/$HCKIND/$HCVER
if [ "${{ matrix.setup-method }}" = ghcup ]; then
HC=$HOME/.ghcup/bin/$HCKIND-$HCVER
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV"
echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
else
HC=$HCDIR/bin/$HCKIND
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV"
echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
fi
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))') HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV" echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV" echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV" echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV"
echo "HEADHACKAGE=false" >> "$GITHUB_ENV" echo "HEADHACKAGE=false" >> "$GITHUB_ENV"
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV" echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
echo "GHCJSARITH=0" >> "$GITHUB_ENV"
env: env:
HCKIND: ${{ matrix.compilerKind }} HCKIND: ${{ matrix.compilerKind }}
HCNAME: ${{ matrix.compiler }} HCNAME: ${{ matrix.compiler }}
@ -160,28 +162,17 @@ jobs:
- name: update cabal index - name: update cabal index
run: | run: |
$CABAL v2-update -v $CABAL v2-update -v
- name: cache (tools)
uses: actions/cache@v2
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-tools-c0dbbd39
path: ~/.haskell-ci-tools
- name: install cabal-plan - name: install cabal-plan
run: | run: |
mkdir -p $HOME/.cabal/bin mkdir -p $HOME/.cabal/bin
curl -sL https://github.com/haskell-hvr/cabal-plan/releases/download/v0.6.2.0/cabal-plan-0.6.2.0-x86_64-linux.xz > cabal-plan.xz curl -sL https://github.com/haskell-hvr/cabal-plan/releases/download/v0.7.3.0/cabal-plan-0.7.3.0-x86_64-linux.xz > cabal-plan.xz
echo 'de73600b1836d3f55e32d80385acc055fd97f60eaa0ab68a755302685f5d81bc cabal-plan.xz' | sha256sum -c - echo 'f62ccb2971567a5f638f2005ad3173dba14693a45154c1508645c52289714cb2 cabal-plan.xz' | sha256sum -c -
xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan
rm -f cabal-plan.xz rm -f cabal-plan.xz
chmod a+x $HOME/.cabal/bin/cabal-plan chmod a+x $HOME/.cabal/bin/cabal-plan
cabal-plan --version cabal-plan --version
- name: install hlint
run: |
if [ $((HCNUMVER >= 90000 && HCNUMVER < 90200)) -ne 0 ] ; then HLINTVER=$(cd /tmp && (${CABAL} v2-install -v $ARG_COMPILER --dry-run hlint --constraint='hlint >=3.4 && <3.5' | perl -ne 'if (/\bhlint-(\d+(\.\d+)*)\b/) { print "$1"; last; }')); echo "HLint version $HLINTVER" ; fi
if [ $((HCNUMVER >= 90000 && HCNUMVER < 90200)) -ne 0 ] ; then if [ ! -e $HOME/.haskell-ci-tools/hlint-$HLINTVER/hlint ]; then echo "Downloading HLint version $HLINTVER"; mkdir -p $HOME/.haskell-ci-tools; curl --write-out 'Status Code: %{http_code} Redirects: %{num_redirects} Total time: %{time_total} Total Dsize: %{size_download}\n' --silent --location --output $HOME/.haskell-ci-tools/hlint-$HLINTVER.tar.gz "https://github.com/ndmitchell/hlint/releases/download/v$HLINTVER/hlint-$HLINTVER-x86_64-linux.tar.gz"; tar -xzv -f $HOME/.haskell-ci-tools/hlint-$HLINTVER.tar.gz -C $HOME/.haskell-ci-tools; fi ; fi
if [ $((HCNUMVER >= 90000 && HCNUMVER < 90200)) -ne 0 ] ; then mkdir -p $CABAL_DIR/bin && ln -sf "$HOME/.haskell-ci-tools/hlint-$HLINTVER/hlint" $CABAL_DIR/bin/hlint ; fi
if [ $((HCNUMVER >= 90000 && HCNUMVER < 90200)) -ne 0 ] ; then hlint --version ; fi
- name: checkout - name: checkout
uses: actions/checkout@v2 uses: actions/checkout@v4
with: with:
path: source path: source
- name: initial cabal.project for sdist - name: initial cabal.project for sdist
@ -219,15 +210,15 @@ jobs:
flags: +pedantic flags: +pedantic
ghc-options: -j ghc-options: -j
EOF EOF
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(xmonad-contrib)$/; }' >> cabal.project.local $HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(xmonad-contrib)$/; }' >> cabal.project.local
cat cabal.project cat cabal.project
cat cabal.project.local cat cabal.project.local
- name: dump install plan - name: dump install plan
run: | run: |
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
cabal-plan cabal-plan
- name: cache - name: restore cache
uses: actions/cache@v2 uses: actions/cache/restore@v4
with: with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
path: ~/.cabal/store path: ~/.cabal/store
@ -245,29 +236,41 @@ jobs:
- name: tests - name: tests
run: | run: |
$CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct $CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct
- name: hlint
run: |
if [ $((HCNUMVER >= 90000 && HCNUMVER < 90200)) -ne 0 ] ; then (cd ${PKGDIR_xmonad_contrib} && hlint -h ${GITHUB_WORKSPACE}/source/.hlint.yaml -XHaskell2010 .) ; fi
- name: cabal check - name: cabal check
run: | run: |
cd ${PKGDIR_xmonad_contrib} || false cd ${PKGDIR_xmonad_contrib} || false
${CABAL} -vnormal check ${CABAL} -vnormal check
- name: haddock - name: haddock
run: |
$CABAL v2-haddock --disable-documentation $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all
- name: haddock for hackage
if: matrix.upload
run: | run: |
$CABAL v2-haddock $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH --haddock-for-hackage --builddir $GITHUB_WORKSPACE/haddock all $CABAL v2-haddock $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH --haddock-for-hackage --builddir $GITHUB_WORKSPACE/haddock all
- name: unconstrained build - name: unconstrained build
run: | run: |
rm -f cabal.project.local rm -f cabal.project.local
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
- name: upload artifacts (sdist) - name: save cache
if: matrix.upload if: always()
uses: actions/upload-artifact@v2 uses: actions/cache/save@v4
with: with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
path: ~/.cabal/store
# must be separate artifacts because GitHub Actions are still broken:
# https://github.com/actions/upload-artifact/issues/441
# https://github.com/actions/upload-artifact/issues/457
- name: upload artifact (sdist)
if: matrix.upload
uses: actions/upload-artifact@v4
with:
name: sdist
path: ${{ github.workspace }}/sdist/*.tar.gz path: ${{ github.workspace }}/sdist/*.tar.gz
- name: upload artifacts (haddock) - name: upload artifact (haddock)
if: matrix.upload if: matrix.upload
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v4
with: with:
name: haddock
path: ${{ github.workspace }}/haddock/*-docs.tar.gz path: ${{ github.workspace }}/haddock/*-docs.tar.gz
- name: hackage upload (candidate) - name: hackage upload (candidate)
if: matrix.upload && github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' if: matrix.upload && github.event_name == 'workflow_dispatch' && github.event.inputs.version != ''

22
.github/workflows/hlint.yaml vendored Normal file
View File

@ -0,0 +1,22 @@
name: hlint
on:
push:
pull_request:
jobs:
hlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 'Set up HLint'
uses: haskell-actions/hlint-setup@v2
with:
version: '3.5'
- name: 'Run HLint'
uses: haskell-actions/hlint-run@v2
with:
path: '["XMonad/", "tests/", "scripts/"]'
fail-on: status

View File

@ -12,17 +12,15 @@ jobs:
contents: read contents: read
steps: steps:
- name: Install Nix - name: Install Nix
uses: cachix/install-nix-action@v13 uses: cachix/install-nix-action@v31
with: with:
install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install github_access_token: ${{ secrets.GITHUB_TOKEN }}
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
extra_nix_config: |
experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Clone project - name: Clone project
uses: actions/checkout@v2 uses: actions/checkout@v4
- name: Build - name: Build
# "nix build" builds with full optimization and includes a profiling # "nix build" builds with full optimization and includes a profiling
# build, so just the build of xmonad-contrib itself takes 3 minutes. # build, so just the build of xmonad-contrib itself takes 3 minutes.
# As a workaround, we invoke cabal manually here. # As a workaround, we invoke cabal manually here.
run: nix develop -c cabal v2-build -O0 -j run: |
nix develop -c cabal v2-update -O0 -j
nix develop -c cabal v2-build -O0 -j

View File

@ -13,16 +13,16 @@ jobs:
steps: steps:
- name: Clone project - name: Clone project
uses: actions/checkout@v2 uses: actions/checkout@v4
- name: Setup Haskell - name: Setup Haskell
uses: haskell/actions/setup@v1 uses: haskell-actions/setup@v2
with: with:
# packdeps doesn't build with newer as of 2021-10 # packdeps doesn't build with newer as of 2021-10
ghc-version: '8.8' ghc-version: '8.8'
- name: Install packdeps - name: Install packdeps
run: | run: |
set -ex set -ex
echo "$HOME/.cabal/bin" >> $GITHUB_PATH cd # go somewhere without a cabal.project
cabal install packdeps cabal install packdeps
- name: Check package bounds (all) - name: Check package bounds (all)
continue-on-error: true continue-on-error: true
@ -42,10 +42,9 @@ jobs:
*.cabal *.cabal
workflow-keepalive: workflow-keepalive:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
actions: write
steps: steps:
- name: Re-enable workflow - uses: liskin/gh-workflow-keepalive@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api -X PUT repos/${{ github.repository }}/actions/workflows/packdeps.yml/enable

View File

@ -12,41 +12,33 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- resolver: lts-12 - resolver: lts-16 # GHC 8.8
ghc: 8.4.4
yaml: stack.yaml yaml: stack.yaml
- resolver: lts-12 - resolver: lts-16 # GHC 8.8
ghc: 8.4.4
yaml: stack-master.yaml yaml: stack-master.yaml
- resolver: lts-14 - resolver: lts-18 # GHC 8.10
ghc: 8.6.5
yaml: stack-master.yaml yaml: stack-master.yaml
- resolver: lts-16 - resolver: lts-19 # GHC 9.0
ghc: 8.8.4
yaml: stack-master.yaml yaml: stack-master.yaml
- resolver: lts-18 - resolver: lts-20 # GHC 9.2
ghc: 8.10.7
yaml: stack-master.yaml yaml: stack-master.yaml
- resolver: lts-19 - resolver: lts-21 # GHC 9.4
ghc: 9.0.2 yaml: stack-master.yaml
- resolver: lts-22 # GHC 9.6
yaml: stack-master.yaml
- resolver: lts-23 # GHC 9.8
yaml: stack.yaml yaml: stack.yaml
- resolver: lts-19 - resolver: lts-23 # GHC 9.8
ghc: 9.0.2
yaml: stack-master.yaml yaml: stack-master.yaml
steps: steps:
- name: Clone project - name: Clone project
uses: actions/checkout@v2 uses: actions/checkout@v4
- name: Prepare apt sources
run: |
set -ex
sudo add-apt-repository -y ppa:hvr/ghc
sudo apt update -y
- name: Install C dependencies - name: Install C dependencies
run: | run: |
set -ex set -ex
sudo apt update -y
sudo apt install -y \ sudo apt install -y \
libx11-dev \ libx11-dev \
libxext-dev \ libxext-dev \
@ -56,14 +48,6 @@ jobs:
libxss-dev \ libxss-dev \
# #
- name: Install GHC
# use system ghc (if available) in stack, don't waste GH Actions cache space
continue-on-error: true
run: |
set -ex
sudo apt install -y ghc-${{ matrix.ghc }}
echo /opt/ghc/${{ matrix.ghc }}/bin >> $GITHUB_PATH
- name: Refresh caches once a month - name: Refresh caches once a month
id: cache-date id: cache-date
# GHA writes caches on the first miss and then never updates them again; # GHA writes caches on the first miss and then never updates them again;
@ -71,16 +55,16 @@ jobs:
# date is prefixed with an epoch number to let us manually refresh the # date is prefixed with an epoch number to let us manually refresh the
# cache when needed. This is a workaround for https://github.com/actions/cache/issues/2 # cache when needed. This is a workaround for https://github.com/actions/cache/issues/2
run: | run: |
echo "::set-output name=date::1-$(date +%Y-%m)" date +date=1-%Y-%m >> $GITHUB_OUTPUT
- name: Cache Haskell package metadata - name: Cache Haskell package metadata
uses: actions/cache@v2 uses: actions/cache@v4
with: with:
path: ~/.stack/pantry path: ~/.stack/pantry
key: stack-pantry-${{ runner.os }}-${{ steps.cache-date.outputs.date }} key: stack-pantry-${{ runner.os }}-${{ steps.cache-date.outputs.date }}
- name: Cache Haskell dependencies - name: Cache Haskell dependencies
uses: actions/cache@v2 uses: actions/cache@v4
with: with:
path: | path: |
~/.stack/* ~/.stack/*

2
.gitignore vendored
View File

@ -27,4 +27,6 @@ tags
stack.yaml.lock stack.yaml.lock
# nix artifacts
result
flake.lock flake.lock

View File

@ -103,6 +103,7 @@ hexago.nl <xmonad-contrib@hexago.nl>
lithis <xmonad@selg.hethrael.org> lithis <xmonad@selg.hethrael.org>
lithis <xmonad@selg.hethrael.org> <xmonad@s001.hethrael.com> lithis <xmonad@selg.hethrael.org> <xmonad@s001.hethrael.com>
sam-barr <mail@samf.bar> <samfbarr@outlook.com> sam-barr <mail@samf.bar> <samfbarr@outlook.com>
slotThe <soliditsallgood@mailbox.org> <50166980+slotThe@users.noreply.github.com> Tony Zorman <soliditsallgood@mailbox.org> <50166980+slotThe@users.noreply.github.com>
slotThe <soliditsallgood@mailbox.org> <soliditsallgood@tuta.io> Tony Zorman <soliditsallgood@mailbox.org> <soliditsallgood@tuta.io>
Tony Zorman <soliditsallgood@mailbox.org>
spoonm <spoonm@spoonm.org> spoonm <spoonm@spoonm.org>

View File

@ -1,6 +1,473 @@
# Change Log / Release Notes # Change Log / Release Notes
## 0.17.1 (September 3, 2021) ## _unreleased_
### Breaking Changes
* Drop support for GHC 8.6
### Bug Fixes and Minor Changes
* `XMonad.Util.EZConfig`
- Added `XF86WLAN` and `Menu` to the list of supported special keys.
* `XMonad.Actions.DynamicProjects`
- No longer autodelete projects when `switchProject` is called from
an empty workspace. This also fixes a bug where static workspaces
would be deleted when switching to a dynamic project.
- Improved documentation on how to close a project.
* `XMonad.Hooks.Rescreen`
- Allow overriding the `rescreen` operation itself. Additionally, the
`XMonad.Actions.PhysicalScreens` module now provides an alternative
implementation of `rescreen` that avoids reshuffling the workspaces if
the number of screens doesn't change and only their locations do (which
is especially common if one uses `xrandr --setmonitor` to split an
ultra-wide display in two).
- Added an optional delay when waiting for events to settle. This may be
used to avoid flicker and unnecessary workspace reshuffling if multiple
`xrandr` commands are used to reconfigure the display layout.
* `XMonad.Layout.NoBorders`
- It's no longer necessary to use `borderEventHook` to garbage collect
`alwaysHidden`/`neverHidden` lists. The layout listens to
`DestroyWindowEvent` messages instead, which are broadcast to layouts
since xmonad v0.17.0.
* `XMonad.Hooks.EwmhDesktops`
- Added a customization option for the action that gets executed when
a client sends a **_NET_CURRENT_DESKTOP** request. It is now possible
to change it using the `setEwmhSwitchDesktopHook`.
- Added a customization option for mapping hidden workspaces to screens
when setting the **_NET_DESKTOP_VIEWPORT**. This can be done using
the `setEwmhHiddenWorkspaceToScreenMapping`.
* `XMonad.Layout.IndependentScreens`
- Added `focusWorkspace` for focusing workspaces on the screen that they
belong to.
- Added `doFocus'` hook as an alternative for `doFocus` when using
IndependentScreens.
- Added `screenOnMonitor` for getting the active screen for a monitor.
* `XMonad.Util.NamedScratchPad`
- Fix unintended window hiding in `nsSingleScratchpadPerWorkspace`.
Only hide the previously active scratchpad.
## 0.18.1 (August 20, 2024)
### Breaking Changes
* `XMonad.Hooks.StatusBars`
- Move status bar functions from the `IO` to the `X` monad to
allow them to look up information from `X`, like the screen
width. Existing configurations may need to use `io` from
`XMonad.Core` or `liftIO` from `Control.Monad.IO.Class` in
order to lift any existing `IO StatusBarConfig` values into
`X StatusBarConfig` values.
* `XMonad.Prompt`
- Added an additional `XPConfig` argument to `historyCompletion` and
`historyCompletionP`. Calls along the lines of `historyCompletionP
myFunc` should be changed to `historyCompletionP myConf myFunc`.
If not `myConf` is lying around, `def` can be used instead.
* `XMonad.Actions.GridSelect`
- Added the `gs_cancelOnEmptyClick` field to `GSConfig`, which makes
mouse clicks into "empty space" cancel the current grid-select.
Users explicitly defining their own `GSConfig` record will have to
add this to their definitions. Additionally, the field defaults to
`True`—to retain the old behaviour, set it to `False`.
### New Modules
* `XMonad.Actions.Profiles`
- Group workspaces by similarity. Useful when one has lots
of workspaces and uses only a couple per unit of work.
* `XMonad.Hooks.FloatConfigureReq`
- Customize handling of floating windows' move/resize/restack requests
(ConfigureRequest). Useful as a workaround for some misbehaving client
applications (Steam, rxvt-unicode, anything that tries to restore
absolute position of floats).
* `XMonad.Layout.Columns`
- Organize windows in columns. This layout allows to move/resize windows in
every directions.
* `XMonad.Prompt.WindowBringer`
- Added `copyMenu`, a convenient way to copy a window to the current workspace.
### Bug Fixes and Minor Changes
* Fix build-with-cabal.sh when XDG_CONFIG_HOME is defined.
* `XMonad.Util.EZConfig`
- Fixed `checkKeymap` warning that all keybindings are duplicates.
* `XMonad.Hooks.ManageHelpers`
- Added `isNotification` predicate to check for windows with
`_NET_WM_WINDOW_TYPE` property of `_NET_WM_WINDOW_TYPE_NOTIFICATION`.
* `XMonad.Prompt.OrgMode`
- Added `HH:MM-HH:MM` and `HH:MM+HH` syntax to specify time spans.
* `XMonad.Prompt`
- The history file is not extraneously read and written anymore if
the `historySize` is set to 0.
* `XMonad.Hooks.EwmhDesktops`
- Requests for unmanaged windows no longer cause a refresh. This avoids
flicker and also fixes disappearing menus in the Steam client and
possibly a few other client applications.
(See also `XMonad.Hooks.FloatConfigureReq` and/or `XMonad.Util.Hacks`
for additional Steam client workarounds.)
* `XMonad.Actions.Submap`
- Added `visualSubmapSorted` to enable sorting of the keymap
descriptions.
* `XMonad.Hooks.ScreenCorners`
- Added screen edge support with `SCTop`, `SCBottom`, `SCLeft` and
`SCRight`. Now both corners and edges are supported.
* `XMonad.Actions.WindowNavigation`
- Improve navigation in presence of floating windows.
- Handle window switching when in `Full` layout.
### Other changes
## 0.18.0 (February 3, 2024)
### Breaking Changes
* Deprecated `XMonad.Layout.Cross` due to bitrot; refer to
`XMonad.Layout.Circle` and `XMonad.Layout.ThreeColumns` for
alternatives.
* Deprecated the `XMonad.Layout.StateFull` module and
`XMonad.Layout.TrackFloating.(t|T)rackFloating` in favour of
`XMonad.Layout.FocusTracking`.
* Dropped support for GHC 8.4.
* `XMonad.Util.ExclusiveScratchpads`
- Deprecated the module in favour of the (new) exclusive scratchpad
functionality of `XMonad.Util.NamedScratchpad`.
* `XMonad.Actions.CycleWorkspaceByScreen`
- The type of `repeatableAction` has changed, and it's deprecated in
favour of `X.A.Repeatable.repeatable`.
* `XMonad.Hooks.DynamicProperty`
- Deprecated the module in favour of the more aptly named
`XMonad.Hooks.OnPropertyChange`.
* `XMonad.Util.Scratchpad`:
- Deprecated the module; use `XMonad.Util.NamedScratchpad` instead.
* `XMonad.Actions.Navigation2D`
- Removed deprecated function `hybridNavigation`.
* `XMonad.Layout.Spacing`
- Removed deprecated functions `SpacingWithEdge`, `SmartSpacing`,
`SmartSpacingWithEdge`, `ModifySpacing`, `setSpacing`, and
`incSpacing`.
* `XMonad.Actions.MessageFeedback`
- Removed deprecated functions `send`, `sendSM`, `sendSM_`,
`tryInOrder`, `tryInOrder_`, `tryMessage`, and `tryMessage_`.
* `XMonad.Prompt.Window`
- Removed deprecated functions `windowPromptGoto`,
`windowPromptBring`, and `windowPromptBringCopy`.
* `XMonad.Hooks.ICCCMFocus`
- Removed deprecated module. This was merged into xmonad.
* `XMonad.Layout.LayoutBuilderP`
- Removed deprecated module; use `XMonad.Layout.LayoutBuilder`
instead.
* `XMonad.Hooks.RestoreMinimized`
- Removed deprecated module; use `XMonad.Hooks.Minimize` instead.
* `XMonad.Layout.Named`
- Deprecated the entire module, use `XMonad.Layout.Renamed` (which newly
provides `named` for convenience) instead.
* `XMonad.Actions.SinkAll`
- Deprecated the entire module, use `XMonad.Actions.WithAll`
instead.
* `XMonad.Layout.Circle`:
- Deprecated the entire module, use the `circle` function from
`XMonad.Layout.CircleEx` instead.
* `XMonad.Hooks.EwmhDesktops`
- `_NET_CLIENT_LIST_STACKING` puts windows in the current workspace at the
top in bottom-to-top order, followed by visible workspaces, followed by
invisible workspaces. Within visible and invisible groups, workspaces are
ordered lexicographically, as before. Currently focused window will
always be the topmost, meaning the last in the list.
* `XMonad.Util.NamedScratchpad`
- Added `nsSingleScratchpadPerWorkspace`—a logHook to allow only one
active scratchpad per workspace.
* `XMonad.Util.EZConfig`
- The function `readKeySequence` now returns a non-empty list if it
succeeded.
* Deprecate `XMonad.Util.Ungrab`; it was moved to `XMonad.Operations`
in core.
### New Modules
* `XMonad.Layout.CenterMainFluid`
- A three column layout with main column in the center and two stack
column surrounding it. Master window will be on center column and
spaces on the sides are reserved.
* `XMonad.Layout.FocusTracking`.
- Replaces `X.L.StateFull` and half of `X.L.TrackFloating`.
* `XMonad.Actions.MostRecentlyUsed`
- Tab through windows by recency of use. Based on the Alt+Tab behaviour
common outside of xmonad.
* `XMonad.Util.History`
- Track history in *O(log n)* time. Provides `History`, a variation on a
LIFO stack with a uniqueness property. In order to achieve the desired
asymptotics, the data type is implemented as an ordered Map.
* `XMonad.Actions.Repeatable`
- Actions you'd like to repeat. Factors out the shared logic of
`X.A.CycleRecentWS`, `X.A.CycleWorkspaceByScreen` and `X.A.CycleWindows`.
* `XMonad.Hooks.OnPropertyChange`:
- A new module replicating the functionality of
`XMonad.Hooks.DynamicProperty`, but with more discoverable names.
* `XMonad.Actions.ToggleFullFloat`:
- Fullscreen (float) a window while remembering its original state.
There's both an action to be bound to a key, and hooks that plug into
`XMonad.Hooks.EwmhDesktops`.
* `XMonad.Layout.CircleEx`:
- A new window layout, similar to X.L.Circle, but with more
possibilities for customisation.
* `XMonad.Layout.DecorationEx`:
- A new, more extensible, mechanism for window decorations, and some
standard types of decorations, including usual bar on top of window,
tabbed decorations and dwm-like decorations.
### Bug Fixes and Minor Changes
* `XMonad.Layout.Magnifier`
- Added `magnifyxy` to allow for different magnification in the
horizontal and vertical directions. Added `magnifierxy`,
`magnifierxy'`, `magnifierxyOff`, and `magnifierxyOff'` as
particular combinators.
* `XMonad.Util.Loggers`
- Added `logClassname`, `logClassnames`, `logClassnames'`,
`logClassnameOnScreen`, `logClassnamesOnScreen`, `logClassnamesOnScreen'`,
and `ClassnamesFormat`. These are all equivalents of their `Title`
counterparts, allowing logging the window classname instead.
* `XMonad.Hooks.StatusBar.PP`
- `dynamicLogString` now forces its result and produces an error string if
it throws an exception. Use `dynamicLogString'` if for some reason you
need the old behavior.
* `XMonad.Util.EZConfig`
- Added `remapKeysP`, which remaps keybindings from one binding to
another.
- Made `additionalKeys{,P}`, `removeKeys{,P}`, `remapKeysP`, and
`{additional,remove}MouseBindings` `infixl 4` so they can more easily
be concatenated with `(++)`.
* `XMonad.Util.NamedScratchpad`
- Added `addExclusives`, `resetFocusedNSP`, `setNoexclusive`,
`resizeNoexclusive`, and `floatMoveNoexclusive` in order to augment
named scratchpads with the exclusive scratchpad functionality of
`XMonad.Util.ExclusiveScratchpads`.
* `XMonad.Layout.BorderResize`
- Added `borderResizeNear` as a variant of `borderResize` that can
control how many pixels near a border resizing still works.
* `XMonad.Util.Run`
- It is now ensured that all arguments of `execute` and `eval` are
quoted. Likewise, `executeNoQuote` is added as a version of
`execute` that does not do that.
- Added `findFile` as a shorthand to call `find-file`.
- Added `list` and `saveExcursion` to the list of Emacs commands.
- Added `toList` to easily lift a `String` to an `X Input`.
- Added `>&&>` and `>||>` to glue together different inputs.
* `XMonad.Util.Parser`
- Added the `gather`, `count`, `between`, `option`, `optionally`,
`skipMany`, `skipMany1`, `chainr`, `chainr1`, `chainl`, `chainl1`,
and `manyTill` functions, in order to achieve feature parity with
`Text.ParserCombinators.ReadP`.
* `XMonad.Actions.FloatKeys`
- Added `directionMoveWindow` and `directionMoveWindow` as more
alternatives to the existing functions.
* `XMonad.Hooks.InsertPosition`
- Added `setupInsertPosition` as a combinator alternative to
`insertPosition`.
* `XMonad.Actions.Navigation2D`
- Added `sideNavigation` as a fallback to the default tiling strategy,
in case `lineNavigation` can't find a window. This benefits
especially users who use `XMonad.Layout.Spacing`.
* `XMonad.Prompt.OrgMode`
- Added `orgPromptRefile` and `orgPromptRefileTo` for interactive
and targeted refiling of the entered note into some existing tree
of headings, respectively.
- Allowed the time specification in `HHMM` format.
* `XMonad.Actions.Search`
- Added `aur`, `flora`, `ncatlab`, `protondb`, `rosettacode`, `sourcehut`,
`steam`, `voidpgks_x86_64`, `voidpgks_x86_64_musl`, `arXiv`,
`clojureDocs`, `cratesIo`, `rustStd`, `noogle`, `nixos`, `homeManager`,
and `zbmath` search engines.
* `XMonad.Layout.ResizableThreeColumns`
- Fixed an issue where the bottom right window would not respond to
`MirrorShrink` and `MirrorExpand` messages.
* `XMonad.Hooks.EwmhDesktops`
- Added `disableEwmhManageDesktopViewport` to avoid setting the
`_NET_DESKTOP_VIEWPORT` property, as it can lead to issues with
some status bars (see this
[polybar issue](https://github.com/polybar/polybar/issues/2603)).
- Added `setEwmhFullscreenHooks` to override the default fullfloat/sink
behaviour of `_NET_WM_STATE_FULLSCREEN` requests. See also
`XMonad.Actions.ToggleFullFloat` for a float-restoring implementation of
fullscreening.
- Added `ewmhDesktops(Maybe)ManageHook` that places windows in their
preferred workspaces. This is useful when restoring a browser session
after a restart.
* `XMonad.Hooks.StatusBar`
- Added `startAllStatusBars` to start the configured status bars.
* `XMonad.Util.NamedActions`
- Changed `addDescrKeys` and `addDescrKeys'` to not discard the
keybindings in the current config.
* `XMonad.Prompt`
- The `emacsLikeXPKeymap` and `vimLikeXPKeymap` keymaps now treat
`C-m` the same as `Return`.
- Added `prevCompletionKey` to `XPConfig`, facilitating the ability
to cycle through the completions backwards. This is bound to
`S-<TAB>` by default.
- The `vimLikeXPKeymap` now accepts the prompt upon pressing enter
in normal mode.
* `XMonad.Actions.Prefix`
- Added `orIfPrefixed`, a combinator to decide upon an action based
on whether any prefix argument was given.
* `XMonad.Actions.WorkspaceNames`
- Enabled prompt completion (from history) in `renameWorkspace`.
* `XMonad.Prompt.Pass`
- Added `passOTPTypePrompt` to type out one-time-passwords via
`xdotool`.
* `XMonad.Util.Stack`
- Added `zipperFocusedAtFirstOf` to differentiate two lists into a
zipper.
## 0.17.1 (September 3, 2022)
### Breaking Changes ### Breaking Changes
@ -13,9 +480,10 @@
* `XMonad.Config.{Arossato,Dmwit,Droundy,Monad,Prime,Saegesser,Sjanssen}` * `XMonad.Config.{Arossato,Dmwit,Droundy,Monad,Prime,Saegesser,Sjanssen}`
- Deprecated all of these modules. The user-specific configuration - Deprecated all of these modules. The user-specific configuration
modules may still be found [on the website]. modules may still be found [on the
website](https://xmonad.org/configurations.html)
* `XMonad.Util.NamedScratchpad` * `XMonad.Util.NamedScratchpad`
- Scratchpads are now only based on the argument given to - Scratchpads are now only based on the argument given to
`namedScratchpadManageHook`; all other scratchpad arguments are, `namedScratchpadManageHook`; all other scratchpad arguments are,
@ -34,8 +502,6 @@
- Deprecated `urgencyConfig`; use `def` from the new `Default` - Deprecated `urgencyConfig`; use `def` from the new `Default`
instance of `UrgencyConfig` instead. instance of `UrgencyConfig` instead.
[on the website]: https://xmonad.org/configurations.html
### New Modules ### New Modules
* `XMonad.Actions.PerLayoutKeys` * `XMonad.Actions.PerLayoutKeys`
@ -79,7 +545,7 @@
A module for adding a keybinding to repeat the last action, similar A module for adding a keybinding to repeat the last action, similar
to Vim's `.` or Emacs's `dot-mode`. to Vim's `.` or Emacs's `dot-mode`.
* `XMonad.Util.Grab` * `XMonad.Util.Grab`
Utilities for making grabbing and ungrabbing keys more convenient. Utilities for making grabbing and ungrabbing keys more convenient.
@ -110,7 +576,8 @@
`todo +d 12 02 2024` work. `todo +d 12 02 2024` work.
- Added the ability to specify alphabetic (`#A`, `#B`, and `#C`) - Added the ability to specify alphabetic (`#A`, `#B`, and `#C`)
[priorities] at the end of the input note. [priorities](https://orgmode.org/manual/Priorities.html) at the end of
the input note.
* `XMonad.Prompt.Unicode` * `XMonad.Prompt.Unicode`
@ -204,7 +671,8 @@
- Modified `mkAbsolutePath` to support a leading environment variable, so - Modified `mkAbsolutePath` to support a leading environment variable, so
things like `$HOME/NOTES` work. If you want more general environment things like `$HOME/NOTES` work. If you want more general environment
variable support, comment on [this PR]. variable support, comment on [this
PR](https://github.com/xmonad/xmonad-contrib/pull/744)
* `XMonad.Util.XUtils` * `XMonad.Util.XUtils`
@ -243,9 +711,6 @@
- Added a `Default` instance for `UrgencyConfig` and `DzenUrgencyHook`. - Added a `Default` instance for `UrgencyConfig` and `DzenUrgencyHook`.
[this PR]: https://github.com/xmonad/xmonad-contrib/pull/744
[priorities]: https://orgmode.org/manual/Priorities.html
### Other changes ### Other changes
* Migrated the sample build scripts from the deprecated `xmonad-testing` repo to * Migrated the sample build scripts from the deprecated `xmonad-testing` repo to
@ -1771,8 +2236,8 @@
* `XMonad.Prompt.Pass` * `XMonad.Prompt.Pass`
This module provides 3 `XMonad.Prompt`s to ease passwords This module provides 3 `XMonad.Prompt`s to ease passwords manipulation
manipulation (generate, read, remove) via [pass][]. (generate, read, remove) via [pass](http://www.passwordstore.org/).
* `XMonad.Util.RemoteWindows` * `XMonad.Util.RemoteWindows`
@ -1848,5 +2313,3 @@
## See Also ## See Also
<https://wiki.haskell.org/Xmonad/Notable_changes_since_0.8> <https://wiki.haskell.org/Xmonad/Notable_changes_since_0.8>
[pass]: http://www.passwordstore.org/

57
NIX.md
View File

@ -16,6 +16,24 @@ pkgs: devInputs: devInputs // {
} }
``` ```
## Selecting a Compiler
A `comp.nix` file can be used to set the compiler used for `nix build` etc. E.g.
```nix
{ compiler = "ghc924"; }
```
Note that you must `git add comp.nix`, or it will be invisible to the flake.
There is also a `prefix` option (see documentation below) but it doesn't really
work in this context, since the xmonad flakes don't see the effects of your
system overlays. Instead try the `--override-input` flag, e.g.
```sh
$ nix develop . --override-input nixpkgs 'github:NixOS/nixpkgs/nixos-unstable'
```
## NixOS Modules ## NixOS Modules
The core and contrib flakes provide NixOS configuration modules. The core and contrib flakes provide NixOS configuration modules.
@ -25,24 +43,42 @@ You can bring them into your system flake like so:
{ {
inputs = { inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-<version>; nixpkgs.url = github:NixOS/nixpkgs/nixos-<version>;
xmonad.url = github:xmonad/xmonad; # The xmonad-contrib flake depends upon and re-exports from the xmonad
# flake. As such, you don't need to use the latter directly. If you wish to
# use /only/ the xmonad flake, you should beware that the version of
# contrib you get from nixpkgs might not build against it.
xmonad-contrib.url = github:xmonad/xmonad-contrib; xmonad-contrib.url = github:xmonad/xmonad-contrib;
}; };
outputs = { self, nixpkgs, xmonad, xmonad-contrib }: { outputs = { self, nixpkgs, xmonad-contrib }: {
nixosConfigurations.<hostname> = nixpkgs.lib.nixosSystem rec { nixosConfigurations.<hostname> = nixpkgs.lib.nixosSystem rec {
system = <arch>; system = <system>;
# NixOS module composition is /not/ commutative; order matters.
# To avoid issues, add `xmonad-contrib.nixosModules` after your standard
# configuration, but before `modernise` or any module overlaying in a
# "prefix".
modules = [ modules = [
./configuration.nix ./configuration.nix
xmonad.nixosModule ./hardware-configuration.nix
xmonad-contrib.nixosModule <myMiscConfigModule>
] ++ xmonad-contrib.nixosModules ++ [
# `modernise` replaces the standard xmonad module and wrapper script
# with those from unstable. This is currently a necessary workaround to
# make Mod-q recompilation work.
xmonad-contrib.modernise.${system}
<myPrefixModule>
]; ];
}; };
}; };
} }
``` ```
Then you can set the provided options in your `configuration.nix` under `flake`: Note that `<thing>` should be replaced with a user-supplied `thing`.
`<version>`, `<hostname>` and `<system>` are necessary, while
` <myMiscConfigModule>` and `<myPrefixModule>` are entirely optional.
Having brought in `xmonad-contrib.nixosModules`, you can then set the provided
options in your `configuration.nix` under `flake`:
```nix ```nix
services.xserver.windowManager.xmonad = { services.xserver.windowManager.xmonad = {
@ -51,7 +87,7 @@ Then you can set the provided options in your `configuration.nix` under `flake`:
flake = { flake = {
enable = true; enable = true;
# prefix = "unstable"; # prefix = "unstable";
compiler = "ghc921"; compiler = "ghc924";
}; };
}; };
``` ```
@ -59,11 +95,12 @@ Then you can set the provided options in your `configuration.nix` under `flake`:
This will use core and contrib from git for your system xmonad, building your This will use core and contrib from git for your system xmonad, building your
config with the compiler of your choice. config with the compiler of your choice.
With the flake enabled, the `xmonad.haskellPackages` option is not used directly, With the flake enabled, the `xmonad.haskellPackages` option is not used
and is instead set by the `flake.compiler` option. When `compiler` is unset, directly, and is instead set by the `flake.compiler` option. When `compiler` is
the default `pkgs.haskellPackages` is used. unset, the default `pkgs.haskellPackages` is used.
The `prefix` option is used if you wish to select your haskell packages from The `prefix` option is used if you wish to select your haskell packages from
within, e.g., unstable overlaid into `pkgs` as `pkgs.unstable`. within, e.g., unstable overlaid into `pkgs` as `pkgs.unstable`.
See the flakes themselves and nix flake documentation for full detail. See the flakes themselves and nix flake documentation for full detail.
Additionally, a semi-walkthrough is available [here](https://tony-zorman.com/posts/xmonad-on-nixos.html).

View File

@ -6,9 +6,9 @@
<a href="https://github.com/xmonad/xmonad-contrib/blob/readme/LICENSE"><img alt="License" src="https://img.shields.io/github/license/xmonad/xmonad-contrib"></a> <a href="https://github.com/xmonad/xmonad-contrib/blob/readme/LICENSE"><img alt="License" src="https://img.shields.io/github/license/xmonad/xmonad-contrib"></a>
<a href="https://haskell.org/"><img alt="Made in Haskell" src="https://img.shields.io/badge/Made%20in-Haskell-%235e5086?logo=haskell"></a> <a href="https://haskell.org/"><img alt="Made in Haskell" src="https://img.shields.io/badge/Made%20in-Haskell-%235e5086?logo=haskell"></a>
<br> <br>
<a href="https://github.com/xmonad/xmonad-contrib/actions/workflows/stack.yml"><img alt="Stack" src="https://img.shields.io/github/workflow/status/xmonad/xmonad-contrib/Stack?label=Stack&logo=githubactions&logoColor=white"></a> <a href="https://github.com/xmonad/xmonad-contrib/actions/workflows/stack.yml"><img alt="Stack" src="https://img.shields.io/github/actions/workflow/status/xmonad/xmonad-contrib/stack.yml?label=Stack&logo=githubactions&logoColor=white"></a>
<a href="https://github.com/xmonad/xmonad-contrib/actions/workflows/haskell-ci.yml"><img alt="Cabal" src="https://img.shields.io/github/workflow/status/xmonad/xmonad-contrib/Haskell-CI?label=Cabal&logo=githubactions&logoColor=white"></a> <a href="https://github.com/xmonad/xmonad-contrib/actions/workflows/haskell-ci.yml"><img alt="Cabal" src="https://img.shields.io/github/actions/workflow/status/xmonad/xmonad-contrib/haskell-ci.yml?label=Cabal&logo=githubactions&logoColor=white"></a>
<a href="https://github.com/xmonad/xmonad-contrib/actions/workflows/nix.yml"><img alt="Nix" src="https://img.shields.io/github/workflow/status/xmonad/xmonad-contrib/Nix?label=Nix&logo=githubactions&logoColor=white"></a> <a href="https://github.com/xmonad/xmonad-contrib/actions/workflows/nix.yml"><img alt="Nix" src="https://img.shields.io/github/actions/workflow/status/xmonad/xmonad-contrib/nix.yml?label=Nix&logo=githubactions&logoColor=white"></a>
<br> <br>
<a href="https://github.com/sponsors/xmonad"><img alt="GitHub Sponsors" src="https://img.shields.io/github/sponsors/xmonad?label=GitHub%20Sponsors&logo=githubsponsors"></a> <a href="https://github.com/sponsors/xmonad"><img alt="GitHub Sponsors" src="https://img.shields.io/github/sponsors/xmonad?label=GitHub%20Sponsors&logo=githubsponsors"></a>
<a href="https://opencollective.com/xmonad"><img alt="Open Collective" src="https://img.shields.io/opencollective/all/xmonad?label=Open%20Collective&logo=opencollective"></a> <a href="https://opencollective.com/xmonad"><img alt="Open Collective" src="https://img.shields.io/opencollective/all/xmonad?label=Open%20Collective&logo=opencollective"></a>

View File

@ -24,7 +24,7 @@ import XMonad
import Data.Time (NominalDiffTime, diffUTCTime, getCurrentTime) import Data.Time (NominalDiffTime, diffUTCTime, getCurrentTime)
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.AfterDrag -- > import XMonad.Actions.AfterDrag
-- --

View File

@ -29,7 +29,7 @@ import System.Exit
-- $usage -- $usage
-- --
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Hooks.ServerMode -- > import XMonad.Hooks.ServerMode
-- > import XMonad.Actions.BluetileCommands -- > import XMonad.Actions.BluetileCommands

View File

@ -37,7 +37,7 @@ import XMonad.Prelude
-- $usage -- $usage
-- --
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.Commands -- > import XMonad.Actions.Commands
-- --
@ -57,7 +57,7 @@ import XMonad.Prelude
-- bindings!) -- bindings!)
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- | Create a 'Data.Map.Map' from @String@s to xmonad actions from a -- | Create a 'Data.Map.Map' from @String@s to xmonad actions from a
-- list of pairs. -- list of pairs.

View File

@ -26,7 +26,7 @@ import XMonad
-- $usage -- $usage
-- --
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import qualified XMonad.Actions.ConstrainedResize as Sqr -- > import qualified XMonad.Actions.ConstrainedResize as Sqr
-- --

View File

@ -37,7 +37,7 @@ import qualified XMonad.StackSet as W
-- $usage -- $usage
-- --
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@ file: -- You can use this module with the following in your @xmonad.hs@ file:
-- --
-- > import XMonad.Actions.CopyWindow -- > import XMonad.Actions.CopyWindow
-- --
@ -77,7 +77,7 @@ import qualified XMonad.StackSet as W
-- > , ((modm .|. shiftMask, xK_v ), killAllOtherCopies) -- @@ Toggle window state back -- > , ((modm .|. shiftMask, xK_v ), killAllOtherCopies) -- @@ Toggle window state back
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- $logHook -- $logHook
-- --

View File

@ -1,6 +1,7 @@
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE PatternGuards #-} {-# LANGUAGE PatternGuards #-}
{-# LANGUAGE MultiWayIf #-}
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- | -- |
-- Module : XMonad.Actions.CycleRecentWS -- Module : XMonad.Actions.CycleRecentWS
@ -35,21 +36,25 @@ module XMonad.Actions.CycleRecentWS (
#endif #endif
) where ) where
import XMonad.Actions.Repeatable (repeatableSt)
import XMonad hiding (workspaces) import XMonad hiding (workspaces)
import XMonad.StackSet hiding (filter) import XMonad.Prelude (void, when)
import XMonad.StackSet hiding (filter, modify)
import Control.Arrow ((&&&)) import Control.Arrow ((&&&))
import Data.Function (on) import Data.Function (on)
import Control.Monad.State (lift)
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@ file: -- You can use this module with the following in your @xmonad.hs@ file:
-- --
-- > import XMonad.Actions.CycleRecentWS -- > import XMonad.Actions.CycleRecentWS
-- > -- >
-- > , ((modm, xK_Tab), cycleRecentWS [xK_Alt_L] xK_Tab xK_grave) -- > , ((modm, xK_Tab), cycleRecentWS [xK_Alt_L] xK_Tab xK_grave)
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- | Cycle through most recent workspaces with repeated presses of a key, while -- | Cycle through most recent workspaces with repeated presses of a key, while
-- a modifier key is held down. The recency of workspaces previewed while browsing -- a modifier key is held down. The recency of workspaces previewed while browsing
@ -111,25 +116,15 @@ cycleWindowSets :: (WindowSet -> [WorkspaceId]) -- ^ A function used to create a
-> X () -> X ()
cycleWindowSets genOptions mods keyNext keyPrev = do cycleWindowSets genOptions mods keyNext keyPrev = do
(options, unView') <- gets $ (genOptions &&& unView) . windowset (options, unView') <- gets $ (genOptions &&& unView) . windowset
XConf {theRoot = root, display = d} <- ask let
let event = allocaXEvent $ \p -> do preview = do
maskEvent d (keyPressMask .|. keyReleaseMask) p i <- get
KeyEvent {ev_event_type = t, ev_keycode = c} <- getEvent p lift $ windows (view (options !! (i `mod` n)) . unView')
s <- keycodeToKeysym d c 0 where n = length options
return (t, s) void . repeatableSt (-1) mods keyNext $ \t s -> when (t == keyPress) $ if
let setOption n = do windows $ view (options `cycref` n) . unView' | s == keyNext -> modify succ >> preview
(t, s) <- io event | s == keyPrev -> modify pred >> preview
case () of | otherwise -> pure ()
() | t == keyPress && s == keyNext -> setOption (n+1)
| t == keyPress && s == keyPrev -> setOption (n-1)
| t == keyRelease && s `elem` mods -> return ()
| otherwise -> setOption n
io $ grabKeyboard d root False grabModeAsync grabModeAsync currentTime
setOption 0
io $ ungrabKeyboard d currentTime
where
cycref :: [a] -> Int -> a
cycref l i = l !! (i `mod` length l)
-- | Given an old and a new 'WindowSet', which is __exactly__ one -- | Given an old and a new 'WindowSet', which is __exactly__ one
-- 'view' away from the old one, restore the workspace order of the -- 'view' away from the old one, restore the workspace order of the

View File

@ -23,7 +23,7 @@ import XMonad.Prelude (elemIndex, fromMaybe)
import qualified XMonad.StackSet as S import qualified XMonad.StackSet as S
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad -- > import XMonad
-- > import XMonad.Actions.CycleSelectedLayouts -- > import XMonad.Actions.CycleSelectedLayouts
@ -39,8 +39,9 @@ cycleToNext lst a = do
-- | If the current layout is in the list, cycle to the next layout. Otherwise, -- | If the current layout is in the list, cycle to the next layout. Otherwise,
-- apply the first layout from list. -- apply the first layout from list.
cycleThroughLayouts :: [String] -> X () cycleThroughLayouts :: [String] -> X ()
cycleThroughLayouts lst = do cycleThroughLayouts [] = pure ()
cycleThroughLayouts lst@(x: _) = do
winset <- gets windowset winset <- gets windowset
let ld = description . S.layout . S.workspace . S.current $ winset let ld = description . S.layout . S.workspace . S.current $ winset
let newld = fromMaybe (head lst) (cycleToNext lst ld) let newld = fromMaybe x (cycleToNext lst ld)
sendMessage $ JumpToLayout newld sendMessage $ JumpToLayout newld

View File

@ -92,7 +92,7 @@ import XMonad.Util.Types
import XMonad.Util.WorkspaceCompare import XMonad.Util.WorkspaceCompare
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@ file: -- You can use this module with the following in your @xmonad.hs@ file:
-- --
-- > import XMonad.Actions.CycleWS -- > import XMonad.Actions.CycleWS
-- > -- >
@ -122,7 +122,7 @@ import XMonad.Util.WorkspaceCompare
-- > windows . view $ t ) -- > windows . view $ t )
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- --
-- When using the toggle functions, in order to ensure that the workspace -- When using the toggle functions, in order to ensure that the workspace
-- to which you switch is the previously viewed workspace, use the -- to which you switch is the previously viewed workspace, use the

View File

@ -1,4 +1,4 @@
{-# LANGUAGE ViewPatterns #-} {-# LANGUAGE ViewPatterns, MultiWayIf #-}
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | -- |
@ -50,7 +50,6 @@ module XMonad.Actions.CycleWindows (
-- $pointer -- $pointer
-- * Generic list rotations -- * Generic list rotations
-- $generic
rotUp, rotDown rotUp, rotDown
) where ) where
@ -59,11 +58,13 @@ import XMonad.Prelude
import qualified XMonad.StackSet as W import qualified XMonad.StackSet as W
import qualified Data.List.NonEmpty as NE import qualified Data.List.NonEmpty as NE
import XMonad.Actions.RotSlaves import XMonad.Actions.RotSlaves
import XMonad.Actions.Repeatable (repeatableSt)
import Control.Arrow (second) import Control.Arrow (second)
import Control.Monad.Trans (lift)
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@ file: -- You can use this module with the following in your @xmonad.hs@ file:
-- --
-- > import XMonad.Actions.CycleWindows -- > import XMonad.Actions.CycleWindows
-- > -- config -- > -- config
@ -79,7 +80,7 @@ import Control.Arrow (second)
-- --
-- Also, if you use focus follows mouse, you will want to read the section -- Also, if you use focus follows mouse, you will want to read the section
-- on updating the mouse pointer below. For detailed instructions on -- on updating the mouse pointer below. For detailed instructions on
-- editing your key bindings, see "XMonad.Doc.Extending#Editing_key_bindings". -- editing your key bindings, see <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
{- $pointer {- $pointer
With FocusFollowsMouse == True, the focus is updated after binding With FocusFollowsMouse == True, the focus is updated after binding
actions, possibly focusing a window you didn't intend to focus. Most actions, possibly focusing a window you didn't intend to focus. Most
@ -139,27 +140,19 @@ cycleStacks' :: (W.Stack Window -> [W.Stack Window]) -- ^ A function to a finite
-> KeySym -- ^ Key used to select a \"previous\" stack. -> KeySym -- ^ Key used to select a \"previous\" stack.
-> X () -> X ()
cycleStacks' filteredPerms mods keyNext keyPrev = do cycleStacks' filteredPerms mods keyNext keyPrev = do
XConf {theRoot = root, display = d} <- ask stacks <- gets $ maybe [] filteredPerms
stacks <- gets $ maybe [] filteredPerms . W.stack . W.workspace . W.current . windowset . W.stack . W.workspace . W.current . windowset
let
let evt = allocaXEvent $ preview = do
\p -> do maskEvent d (keyPressMask .|. keyReleaseMask) p i <- get
KeyEvent {ev_event_type = t, ev_keycode = c} <- getEvent p lift . windows . W.modify' . const $ stacks !! (i `mod` n)
s <- keycodeToKeysym d c 0 where n = length stacks
return (t, s) void $ repeatableSt 0 mods keyNext $ \t s -> if
choose n (t, s) | t == keyPress && s == keyNext -> modify succ
| t == keyPress && s == keyNext = io evt >>= choose (n+1) | t == keyPress && s == keyPrev -> modify pred
| t == keyPress && s == keyPrev = io evt >>= choose (n-1) | t == keyPress && s `elem` [xK_0..xK_9] -> put (numKeyToN s)
| t == keyPress && s `elem` [xK_0..xK_9] = io evt >>= choose (numKeyToN s) | otherwise -> preview
| t == keyRelease && s `elem` mods = return () where numKeyToN = subtract 48 . read . show
| otherwise = doStack n >> io evt >>= choose n
doStack n = windows . W.modify' . const $ stacks `cycref` n
io $ grabKeyboard d root False grabModeAsync grabModeAsync currentTime
io evt >>= choose 1
io $ ungrabKeyboard d currentTime
where cycref l i = l !! (i `mod` length l) -- modify' ensures l is never [], but must also be finite
numKeyToN = subtract 48 . read . show
-- | Given a stack element and a stack, shift or insert the element (window) -- | Given a stack element and a stack, shift or insert the element (window)
-- at the currently focused position. -- at the currently focused position.
@ -229,12 +222,3 @@ rotUnfocused' f s@(W.Stack _ [] _ ) = rotSlaves' f s -- Master h
rotUnfocused' f (W.Stack t ls rs) = W.Stack t (reverse revls') rs' -- otherwise rotUnfocused' f (W.Stack t ls rs) = W.Stack t (reverse revls') rs' -- otherwise
where (master :| revls) = NE.reverse (let l:ll = ls in l :| ll) where (master :| revls) = NE.reverse (let l:ll = ls in l :| ll)
(revls',rs') = splitAt (length ls) (f $ master:revls ++ rs) (revls',rs') = splitAt (length ls) (f $ master:revls ++ rs)
-- $generic
-- Generic list rotations such that @rotUp [1..4]@ is equivalent to
-- @[2,3,4,1]@ and @rotDown [1..4]@ to @[4,1,2,3]@. They both are
-- @id@ for null or singleton lists.
rotUp :: [a] -> [a]
rotUp l = drop 1 l ++ take 1 l
rotDown :: [a] -> [a]
rotDown = reverse . rotUp . reverse

View File

@ -25,11 +25,10 @@ module XMonad.Actions.CycleWorkspaceByScreen (
import Data.IORef import Data.IORef
import Graphics.X11.Xlib.Extras
import XMonad import XMonad
import XMonad.Prelude import XMonad.Prelude
import XMonad.Hooks.WorkspaceHistory import XMonad.Hooks.WorkspaceHistory
import XMonad.Actions.Repeatable (repeatable)
import qualified XMonad.StackSet as W import qualified XMonad.StackSet as W
-- $usage -- $usage
@ -53,22 +52,9 @@ import qualified XMonad.StackSet as W
-- --
-- > , ((mod4Mask, xK_slash), cycleWorkspaceOnCurrentScreen [xK_Super_L] xK_slash xK_p) -- > , ((mod4Mask, xK_slash), cycleWorkspaceOnCurrentScreen [xK_Super_L] xK_slash xK_p)
repeatableAction :: [KeySym] -> (EventType -> KeySym -> X ()) -> X () {-# DEPRECATED repeatableAction "Use XMonad.Actions.Repeatable.repeatable" #-}
repeatableAction mods pressHandler = do repeatableAction :: [KeySym] -> KeySym -> (EventType -> KeySym -> X ()) -> X ()
XConf {theRoot = root, display = d} <- ask repeatableAction = repeatable
let getNextEvent = io $ allocaXEvent $ \p ->
do
maskEvent d (keyPressMask .|. keyReleaseMask) p
KeyEvent {ev_event_type = t, ev_keycode = c} <- getEvent p
s <- io $ keycodeToKeysym d c 0
return (t, s)
handleEvent (t, s)
| t == keyRelease && s `elem` mods = return ()
| otherwise = pressHandler t s >> getNextEvent >>= handleEvent
io $ grabKeyboard d root False grabModeAsync grabModeAsync currentTime
getNextEvent >>= handleEvent
io $ ungrabKeyboard d currentTime
handleKeyEvent :: EventType handleKeyEvent :: EventType
-> KeySym -> KeySym
@ -109,8 +95,7 @@ cycleWorkspaceOnScreen screenId mods nextKey prevKey = workspaceHistoryTransacti
return $ cycleWorkspaces !! current return $ cycleWorkspaces !! current
focusIncrement i = io (getAndIncrementWS i) >>= (windows . W.greedyView) focusIncrement i = io (getAndIncrementWS i) >>= (windows . W.greedyView)
focusIncrement 1 -- Do the first workspace cycle repeatable mods nextKey $
repeatableAction mods $
runFirst runFirst
[ handleKeyEvent keyPress nextKey $ focusIncrement 1 [ handleKeyEvent keyPress nextKey $ focusIncrement 1
, handleKeyEvent keyPress prevKey $ focusIncrement (-1) , handleKeyEvent keyPress prevKey $ focusIncrement (-1)

View File

@ -39,7 +39,7 @@ import qualified XMonad.StackSet as W
import XMonad import XMonad
-- $usage -- $usage
-- To use demanage, add this import to your @~\/.xmonad\/xmonad.hs@: -- To use demanage, add this import to your @xmonad.hs@:
-- --
-- > import XMonad.Actions.DeManage -- > import XMonad.Actions.DeManage
-- --
@ -48,7 +48,7 @@ import XMonad
-- > , ((modm, xK_d ), withFocused demanage) -- > , ((modm, xK_d ), withFocused demanage)
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- | Stop managing the currently focused window. -- | Stop managing the currently focused window.
demanage :: Window -> X () demanage :: Window -> X ()

View File

@ -31,7 +31,7 @@ import qualified Data.List.NonEmpty as NE
-- $usage -- $usage
-- --
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.DwmPromote -- > import XMonad.Actions.DwmPromote
-- --
@ -40,7 +40,7 @@ import qualified Data.List.NonEmpty as NE
-- > , ((modm, xK_Return), dwmpromote) -- > , ((modm, xK_Return), dwmpromote)
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- | Swap the focused window with the master window. If focus is in -- | Swap the focused window with the master window. If focus is in
-- the master, swap it with the next window in the stack. Focus -- the master, swap it with the next window in the stack. Focus

View File

@ -69,7 +69,9 @@ import qualified XMonad.Util.ExtensibleState as XS
-- the working directory to the one configured for the matching -- the working directory to the one configured for the matching
-- project. If the workspace doesn't have any windows, the project's -- project. If the workspace doesn't have any windows, the project's
-- start-up hook is executed. This allows you to launch applications -- start-up hook is executed. This allows you to launch applications
-- or further configure the workspace/project. -- or further configure the workspace/project. To close a project,
-- you can use the functions provided by "XMonad.Actions.DynamicWorkspaces",
-- such as @removeWorkspace@ or @removeWorkspaceByTag@.
-- --
-- When using the @switchProjectPrompt@ function, workspaces are -- When using the @switchProjectPrompt@ function, workspaces are
-- created as needed. This means you can create new project spaces -- created as needed. This means you can create new project spaces
@ -113,7 +115,7 @@ import qualified XMonad.Util.ExtensibleState as XS
-- > , ((modm, xK_slash), shiftToProjectPrompt def) -- > , ((modm, xK_slash), shiftToProjectPrompt def)
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
type ProjectName = String type ProjectName = String
@ -230,7 +232,9 @@ lookupProject name = Map.lookup name <$> XS.gets projects
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Fetch the current project (the one being used for the currently -- | Fetch the current project (the one being used for the currently
-- active workspace). -- active workspace). If the workspace doesn't have a project, a
-- default project is returned, using the workspace name as the
-- project name.
currentProject :: X Project currentProject :: X Project
currentProject = do currentProject = do
name <- gets (W.tag . W.workspace . W.current . windowset) name <- gets (W.tag . W.workspace . W.current . windowset)
@ -255,20 +259,7 @@ modifyProject f = do
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Switch to the given project. -- | Switch to the given project.
switchProject :: Project -> X () switchProject :: Project -> X ()
switchProject p = do switchProject p = appendWorkspace (projectName p)
oldws <- gets (W.workspace . W.current . windowset)
oldp <- currentProject
let name = W.tag oldws
ws = W.integrate' (W.stack oldws)
-- If the project we are switching away from has no windows, and
-- it's a dynamic project, remove it from the configuration.
when (null ws && isNothing (projectStartHook oldp)) $ do
removeWorkspaceByTag name -- also remove the old workspace
XS.modify (\s -> s {projects = Map.delete name $ projects s})
appendWorkspace (projectName p)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Prompt for a project name and then switch to it. Automatically -- | Prompt for a project name and then switch to it. Automatically

View File

@ -51,7 +51,7 @@ import qualified XMonad.Util.ExtensibleState as XS
import XMonad.Actions.TopicSpace import XMonad.Actions.TopicSpace
-- $usage -- $usage
-- You can use this module by importing it into your ~\/.xmonad\/xmonad.hs file: -- You can use this module by importing it into your @xmonad.hs@ file:
-- --
-- > import XMonad.Actions.DynamicWorkspaceGroups -- > import XMonad.Actions.DynamicWorkspaceGroups
-- --

View File

@ -49,7 +49,7 @@ import XMonad.Prelude (fromJust, fromMaybe)
import Data.Ord (comparing) import Data.Ord (comparing)
-- $usage -- $usage
-- You can use this module by importing it into your ~\/.xmonad\/xmonad.hs file: -- You can use this module by importing it into your @xmonad.hs@ file:
-- --
-- > import qualified XMonad.Actions.DynamicWorkspaceOrder as DO -- > import qualified XMonad.Actions.DynamicWorkspaceOrder as DO
-- --

View File

@ -44,7 +44,7 @@ import qualified Data.Map.Strict as Map
import qualified XMonad.Util.ExtensibleState as XS import qualified XMonad.Util.ExtensibleState as XS
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@ file: -- You can use this module with the following in your @xmonad.hs@ file:
-- --
-- > import XMonad.Actions.DynamicWorkspaces -- > import XMonad.Actions.DynamicWorkspaces
-- > import XMonad.Actions.CopyWindow(copy) -- > import XMonad.Actions.CopyWindow(copy)
@ -75,7 +75,7 @@ import qualified XMonad.Util.ExtensibleState as XS
-- > zip (zip (repeat (modm .|. controlMask)) [xK_1..xK_9]) (map (setWorkspaceIndex) [1..]) -- > zip (zip (repeat (modm .|. controlMask)) [xK_1..xK_9]) (map (setWorkspaceIndex) [1..])
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". See also the documentation for -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>. See also the documentation for
-- "XMonad.Actions.CopyWindow", 'windows', 'shift', and 'XPConfig'. -- "XMonad.Actions.CopyWindow", 'windows', 'shift', and 'XPConfig'.
type WorkspaceTag = String type WorkspaceTag = String

View File

@ -51,7 +51,7 @@ import qualified Data.Map.Strict as M (Map, elems, map, mapWithKey)
-- $usage -- $usage
-- --
-- You can use this module's basic functionality with the following in your -- You can use this module's basic functionality with the following in your
-- @~\/.xmonad\/xmonad.hs@: -- @xmonad.hs@:
-- --
-- > import XMonad.Actions.EasyMotion (selectWindow) -- > import XMonad.Actions.EasyMotion (selectWindow)
-- --
@ -387,5 +387,5 @@ handleKeyboard dpy drawFn cancel selected deselected = do
_ -> handleKeyboard dpy drawFn cancel (trim fg) (clear bg) >>= retryBackspace _ -> handleKeyboard dpy drawFn cancel (trim fg) (clear bg) >>= retryBackspace
where where
(fg, bg) = partition ((== Just keySym) . listToMaybe . chord) selected (fg, bg) = partition ((== Just keySym) . listToMaybe . chord) selected
trim = map (\o -> o { chord = tail $ chord o }) trim = map (\o -> o { chord = drop 1 $ chord o })
clear = map (\o -> o { chord = [] }) clear = map (\o -> o { chord = [] })

View File

@ -25,7 +25,7 @@ import XMonad.StackSet
-- $usage -- $usage
-- --
-- To use, import this module into your @~\/.xmonad\/xmonad.hs@: -- To use, import this module into your @xmonad.hs@:
-- --
-- > import XMonad.Actions.FindEmptyWorkspace -- > import XMonad.Actions.FindEmptyWorkspace
-- --
@ -38,7 +38,7 @@ import XMonad.StackSet
-- will tag the current window to an empty workspace and view it. -- will tag the current window to an empty workspace and view it.
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- | Find the first hidden empty workspace in a StackSet. Returns -- | Find the first hidden empty workspace in a StackSet. Returns
-- Nothing if all workspaces are in use. Function searches currently -- Nothing if all workspaces are in use. Function searches currently

View File

@ -29,7 +29,7 @@ import qualified Prelude as P
import Prelude (Double, Integer, Ord (..), const, fromIntegral, fst, id, otherwise, round, snd, uncurry, ($)) import Prelude (Double, Integer, Ord (..), const, fromIntegral, fst, id, otherwise, round, snd, uncurry, ($))
-- $usage -- $usage
-- First, add this import to your @~\/.xmonad\/xmonad.hs@: -- First, add this import to your @xmonad.hs@:
-- --
-- > import qualified XMonad.Actions.FlexibleManipulate as Flex -- > import qualified XMonad.Actions.FlexibleManipulate as Flex
-- --

View File

@ -25,7 +25,7 @@ import XMonad.Prelude (fi)
import Foreign.C.Types import Foreign.C.Types
-- $usage -- $usage
-- To use, first import this module into your @~\/.xmonad\/xmonad.hs@ file: -- To use, first import this module into your @xmonad.hs@ file:
-- --
-- > import qualified XMonad.Actions.FlexibleResize as Flex -- > import qualified XMonad.Actions.FlexibleResize as Flex
-- --

View File

@ -19,14 +19,18 @@ module XMonad.Actions.FloatKeys (
keysMoveWindowTo, keysMoveWindowTo,
keysResizeWindow, keysResizeWindow,
keysAbsResizeWindow, keysAbsResizeWindow,
directionMoveWindow,
directionResizeWindow,
Direction2D(..),
P, G, ChangeDim P, G, ChangeDim
) where ) where
import XMonad import XMonad
import XMonad.Prelude (fi) import XMonad.Prelude (fi)
import XMonad.Util.Types
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.FloatKeys -- > import XMonad.Actions.FloatKeys
-- --
@ -38,8 +42,36 @@ import XMonad.Prelude (fi)
-- > , ((modm .|. shiftMask, xK_s ), withFocused (keysAbsResizeWindow (10,10) (1024,752))) -- > , ((modm .|. shiftMask, xK_s ), withFocused (keysAbsResizeWindow (10,10) (1024,752)))
-- > , ((modm, xK_a ), withFocused (keysMoveWindowTo (512,384) (1%2,1%2))) -- > , ((modm, xK_a ), withFocused (keysMoveWindowTo (512,384) (1%2,1%2)))
-- --
-- Using "XMonad.Util.EZConfig" syntax, we can easily build keybindings
-- where @M-\<arrow-keys\>@ moves the currently focused window and
-- @M-S-\<arrow-keys\>@ resizes it using 'directionMoveWindow' and
-- 'directionResizeWindow':
--
-- > [ ("M-" <> m <> k, withFocused $ f i)
-- > | (i, k) <- zip [U, D, R, L] ["<Up>", "<Down>", "<Right>", "<Left>"]
-- > , (f, m) <- [(directionMoveWindow 10, ""), (directionResizeWindow 10, "S-")]
-- > ]
--
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- | @directionMoveWindow delta dir win@ moves the window @win@ by
-- @delta@ pixels in direction @dir@.
directionMoveWindow :: Int -> Direction2D -> Window -> X ()
directionMoveWindow delta dir win = case dir of
U -> keysMoveWindow (0, -delta) win
D -> keysMoveWindow (0, delta) win
R -> keysMoveWindow (delta, 0) win
L -> keysMoveWindow (-delta, 0) win
-- | @directionResizeWindow delta dir win@ resizes the window @win@ by
-- @delta@ pixels in direction @dir@.
directionResizeWindow :: Int -> Direction2D -> Window -> X ()
directionResizeWindow delta dir win = case dir of
U -> keysResizeWindow (0, -delta) (0, 0) win
D -> keysResizeWindow (0, delta) (0, 0) win
R -> keysResizeWindow (delta, 0) (0, 0) win
L -> keysResizeWindow (-delta, 0) (0, 0) win
-- | @keysMoveWindow (dx, dy)@ moves the window by @dx@ pixels to the -- | @keysMoveWindow (dx, dy)@ moves the window by @dx@ pixels to the
-- right and @dy@ pixels down. -- right and @dy@ pixels down.

View File

@ -37,7 +37,7 @@ import XMonad.Util.Types (Direction2D(..))
import XMonad.Actions.AfterDrag import XMonad.Actions.AfterDrag
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.FloatSnap -- > import XMonad.Actions.FloatSnap
-- --
@ -53,7 +53,7 @@ import XMonad.Actions.AfterDrag
-- > , ((modm .|. shiftMask, xK_Down), withFocused $ snapGrow D Nothing) -- > , ((modm .|. shiftMask, xK_Down), withFocused $ snapGrow D Nothing)
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- --
-- And possibly add appropriate mouse bindings, for example: -- And possibly add appropriate mouse bindings, for example:
-- --

View File

@ -25,7 +25,7 @@ import XMonad.Prelude
import XMonad.StackSet import XMonad.StackSet
-- $usage -- $usage
-- Add the import to your @~\/.xmonad\/xmonad.hs@: -- Add the import to your @xmonad.hs@:
-- --
-- > import XMonad.Actions.FocusNth -- > import XMonad.Actions.FocusNth
-- --
@ -36,7 +36,7 @@ import XMonad.StackSet
-- > | (i, k) <- zip [0 .. 8] [xK_1 ..]] -- > | (i, k) <- zip [0 .. 8] [xK_1 ..]]
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- | Give focus to the nth window of the current workspace. -- | Give focus to the nth window of the current workspace.
focusNth :: Int -> X () focusNth :: Int -> X ()

View File

@ -97,10 +97,11 @@ import XMonad.Actions.WindowBringer (bringWindow)
import Text.Printf import Text.Printf
import System.Random (mkStdGen, randomR) import System.Random (mkStdGen, randomR)
import Data.Word (Word8) import Data.Word (Word8)
import qualified Data.List.NonEmpty as NE
-- $usage -- $usage
-- --
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.GridSelect -- > import XMonad.Actions.GridSelect
-- --
@ -142,8 +143,8 @@ import Data.Word (Word8)
-- --
-- Then you can bind to: -- Then you can bind to:
-- --
-- > ,((modm, xK_g), goToSelected $ gsconfig2 myWinColorizer) -- > ,((modm, xK_g), goToSelected $ gsconfig2 myWinColorizer)
-- > ,((modm, xK_p), spawnSelected $ spawnSelected defaultColorizer) -- > ,((modm, xK_p), spawnSelected (gsconfig2 defaultColorizer) ["xterm","gvim"])
-- $keybindings -- $keybindings
-- --
@ -202,10 +203,13 @@ data GSConfig a = GSConfig {
gs_colorizer :: a -> Bool -> X (String, String), gs_colorizer :: a -> Bool -> X (String, String),
gs_font :: String, gs_font :: String,
gs_navigate :: TwoD a (Maybe a), gs_navigate :: TwoD a (Maybe a),
-- ^ Customize key bindings for a GridSelect
gs_rearranger :: Rearranger a, gs_rearranger :: Rearranger a,
gs_originFractX :: Double, gs_originFractX :: Double,
gs_originFractY :: Double, gs_originFractY :: Double,
gs_bordercolor :: String gs_bordercolor :: String,
gs_cancelOnEmptyClick :: Bool
-- ^ When True, click on empty space will cancel GridSelect
} }
-- | That is 'fromClassName' if you are selecting a 'Window', or -- | That is 'fromClassName' if you are selecting a 'Window', or
@ -302,14 +306,14 @@ diamondLayer n =
r = tr ++ map (\(x,y) -> (y,-x)) tr r = tr ++ map (\(x,y) -> (y,-x)) tr
in r ++ map (negate *** negate) r in r ++ map (negate *** negate) r
diamond :: (Enum a, Num a, Eq a) => [(a, a)] diamond :: (Enum a, Num a, Eq a) => Stream (a, a)
diamond = concatMap diamondLayer [0..] diamond = fromList $ concatMap diamondLayer [0..]
diamondRestrict :: Integer -> Integer -> Integer -> Integer -> [(Integer, Integer)] diamondRestrict :: Integer -> Integer -> Integer -> Integer -> [(Integer, Integer)]
diamondRestrict x y originX originY = diamondRestrict x y originX originY =
L.filter (\(x',y') -> abs x' <= x && abs y' <= y) . L.filter (\(x',y') -> abs x' <= x && abs y' <= y) .
map (\(x', y') -> (x' + fromInteger originX, y' + fromInteger originY)) . map (\(x', y') -> (x' + fromInteger originX, y' + fromInteger originY)) .
take 1000 $ diamond takeS 1000 $ diamond
findInElementMap :: (Eq a) => a -> [(a, b)] -> Maybe (a, b) findInElementMap :: (Eq a) => a -> [(a, b)] -> Maybe (a, b)
findInElementMap pos = find ((== pos) . fst) findInElementMap pos = find ((== pos) . fst)
@ -385,13 +389,20 @@ updateElementsWithColorizer colorizer elementmap = do
stdHandle :: Event -> TwoD a (Maybe a) -> TwoD a (Maybe a) stdHandle :: Event -> TwoD a (Maybe a) -> TwoD a (Maybe a)
stdHandle ButtonEvent{ ev_event_type = t, ev_x = x, ev_y = y } contEventloop stdHandle ButtonEvent{ ev_event_type = t, ev_x = x, ev_y = y } contEventloop
| t == buttonRelease = do | t == buttonRelease = do
s@TwoDState { td_paneX = px, td_paneY = py, s@TwoDState{ td_paneX = px
td_gsconfig = (GSConfig ch cw _ _ _ _ _ _ _ _) } <- get , td_paneY = py
, td_gsconfig = GSConfig{ gs_cellheight = ch
, gs_cellwidth = cw
, gs_cancelOnEmptyClick = cancelOnEmptyClick
}
} <- get
let gridX = (fi x - (px - cw) `div` 2) `div` cw let gridX = (fi x - (px - cw) `div` 2) `div` cw
gridY = (fi y - (py - ch) `div` 2) `div` ch gridY = (fi y - (py - ch) `div` 2) `div` ch
case lookup (gridX,gridY) (td_elementmap s) of case lookup (gridX,gridY) (td_elementmap s) of
Just (_,el) -> return (Just el) Just (_,el) -> return (Just el)
Nothing -> contEventloop Nothing -> if cancelOnEmptyClick
then return Nothing
else contEventloop
| otherwise = contEventloop | otherwise = contEventloop
stdHandle ExposeEvent{} contEventloop = updateAllElements >> contEventloop stdHandle ExposeEvent{} contEventloop = updateAllElements >> contEventloop
@ -647,7 +658,7 @@ gridselect gsconfig elements =
liftIO $ mapWindow dpy win liftIO $ mapWindow dpy win
liftIO $ selectInput dpy win (exposureMask .|. keyPressMask .|. buttonReleaseMask) liftIO $ selectInput dpy win (exposureMask .|. keyPressMask .|. buttonReleaseMask)
status <- io $ grabKeyboard dpy win True grabModeAsync grabModeAsync currentTime status <- io $ grabKeyboard dpy win True grabModeAsync grabModeAsync currentTime
io $ grabPointer dpy win True buttonReleaseMask grabModeAsync grabModeAsync none none currentTime void $ io $ grabPointer dpy win True buttonReleaseMask grabModeAsync grabModeAsync none none currentTime
font <- initXMF (gs_font gsconfig) font <- initXMF (gs_font gsconfig)
let screenWidth = toInteger $ rect_width scr let screenWidth = toInteger $ rect_width scr
screenHeight = toInteger $ rect_height scr screenHeight = toInteger $ rect_height scr
@ -658,7 +669,7 @@ gridselect gsconfig elements =
originPosX = floor $ (gs_originFractX gsconfig - (1/2)) * 2 * fromIntegral restrictX originPosX = floor $ (gs_originFractX gsconfig - (1/2)) * 2 * fromIntegral restrictX
originPosY = floor $ (gs_originFractY gsconfig - (1/2)) * 2 * fromIntegral restrictY originPosY = floor $ (gs_originFractY gsconfig - (1/2)) * 2 * fromIntegral restrictY
coords = diamondRestrict restrictX restrictY originPosX originPosY coords = diamondRestrict restrictX restrictY originPosX originPosY
s = TwoDState { td_curpos = head coords, s = TwoDState { td_curpos = NE.head (notEmpty coords),
td_availSlots = coords, td_availSlots = coords,
td_elements = elements, td_elements = elements,
td_gsconfig = gsconfig, td_gsconfig = gsconfig,
@ -705,7 +716,7 @@ decorateName' w = do
-- | Builds a default gs config from a colorizer function. -- | Builds a default gs config from a colorizer function.
buildDefaultGSConfig :: (a -> Bool -> X (String,String)) -> GSConfig a buildDefaultGSConfig :: (a -> Bool -> X (String,String)) -> GSConfig a
buildDefaultGSConfig col = GSConfig 50 130 10 col "xft:Sans-8" defaultNavigation noRearranger (1/2) (1/2) "white" buildDefaultGSConfig col = GSConfig 50 130 10 col "xft:Sans-8" defaultNavigation noRearranger (1/2) (1/2) "white" True
-- | Brings selected window to the current workspace. -- | Brings selected window to the current workspace.
bringSelected :: GSConfig Window -> X () bringSelected :: GSConfig Window -> X ()

View File

@ -33,8 +33,8 @@ module XMonad.Actions.GroupNavigation ( -- * Usage
, isOnAnyVisibleWS , isOnAnyVisibleWS
) where ) where
import Control.Monad.Reader import Control.Monad.Reader (ask, asks)
import Control.Monad.State import Control.Monad.State (gets)
import Control.DeepSeq import Control.DeepSeq
import Data.Map ((!)) import Data.Map ((!))
import qualified Data.Map as Map import qualified Data.Map as Map
@ -47,13 +47,13 @@ import Prelude hiding (drop, elem, filter, null, reverse)
import XMonad.Core import XMonad.Core
import XMonad.ManageHook import XMonad.ManageHook
import XMonad.Operations (windows, withFocused) import XMonad.Operations (windows, withFocused)
import XMonad.Prelude (elem, foldl') import XMonad.Prelude (elem, foldl', (>=>))
import qualified XMonad.StackSet as SS import qualified XMonad.StackSet as SS
import qualified XMonad.Util.ExtensibleState as XS import qualified XMonad.Util.ExtensibleState as XS
{- $usage {- $usage
Import the module into your @~\/.xmonad\/xmonad.hs@: Import the module into your @xmonad.hs@:
> import XMonad.Actions.GroupNavigation > import XMonad.Actions.GroupNavigation
@ -129,7 +129,7 @@ focusNextMatchOrDo qry act = findM (runQuery qry)
>=> maybe act (windows . SS.focusWindow) >=> maybe act (windows . SS.focusWindow)
-- Returns the list of windows ordered by workspace as specified in -- Returns the list of windows ordered by workspace as specified in
-- ~/.xmonad/xmonad.hs -- @xmonad.hs@.
orderedWindowList :: Direction -> X (Seq Window) orderedWindowList :: Direction -> X (Seq Window)
orderedWindowList History = fmap (\(HistoryDB w ws) -> maybe ws (ws |>) w) XS.get orderedWindowList History = fmap (\(HistoryDB w ws) -> maybe ws (ws |>) w) XS.get
orderedWindowList dir = withWindowSet $ \ss -> do orderedWindowList dir = withWindowSet $ \ss -> do
@ -145,7 +145,7 @@ orderedWindowList dir = withWindowSet $ \ss -> do
dirfun _ = id dirfun _ = id
rotfun wins x = rotate $ rotateTo (== x) wins rotfun wins x = rotate $ rotateTo (== x) wins
-- Returns the ordered workspace list as specified in ~/.xmonad/xmonad.hs -- Returns the ordered workspace list as specified in @xmonad.hs@.
orderedWorkspaceList :: WindowSet -> Seq String -> Seq WindowSpace orderedWorkspaceList :: WindowSet -> Seq String -> Seq WindowSpace
orderedWorkspaceList ss wsids = rotateTo isCurWS wspcs' orderedWorkspaceList ss wsids = rotateTo isCurWS wspcs'
where where

View File

@ -36,7 +36,7 @@ import qualified Data.Map as M
( insert, delete, Map, lookup, empty, filter ) ( insert, delete, Map, lookup, empty, filter )
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@ file: -- You can use this module with the following in your @xmonad.hs@ file:
-- --
-- > import XMonad.Actions.LinkWorkspaces -- > import XMonad.Actions.LinkWorkspaces
-- --
@ -58,7 +58,7 @@ import qualified Data.Map as M
-- > , (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]] -- > , (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]]
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
data MessageConfig = MessageConfig { messageFunction :: ScreenId -> [Char] -> [Char] -> [Char] -> X() data MessageConfig = MessageConfig { messageFunction :: ScreenId -> [Char] -> [Char] -> [Char] -> X()
, foreground :: [Char] , foreground :: [Char]

View File

@ -42,24 +42,18 @@ module XMonad.Actions.MessageFeedback
-- ** Aliases -- ** Aliases
, sm , sm
-- * Backwards Compatibility
-- $backwardsCompatibility
, send, sendSM, sendSM_
, tryInOrder, tryInOrder_
, tryMessage, tryMessage_
) where ) where
import XMonad ( Window ) import XMonad ( Window )
import XMonad.Core ( X(), Message, SomeMessage(..), LayoutClass(..), windowset, catchX, WorkspaceId, Layout, whenJust ) import XMonad.Core ( X(), Message, SomeMessage(..), LayoutClass(..), windowset, catchX, WorkspaceId, Layout, whenJust )
import XMonad.Operations ( updateLayout, windowBracket, modifyWindowSet ) import XMonad.Operations ( updateLayout, windowBracket, modifyWindowSet )
import XMonad.Prelude ( isJust, liftA2, void ) import XMonad.Prelude
import XMonad.StackSet ( Workspace, current, workspace, layout, tag ) import XMonad.StackSet ( Workspace, current, workspace, layout, tag )
import Control.Monad.State ( gets ) import Control.Monad.State ( gets )
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.MessageFeedback -- > import XMonad.Actions.MessageFeedback
-- --
@ -230,46 +224,3 @@ tryMessageWithNoRefreshToCurrent m = void . tryMessageWithNoRefreshToCurrentB m
-- | Convenience shorthand for 'SomeMessage'. -- | Convenience shorthand for 'SomeMessage'.
sm :: Message a => a -> SomeMessage sm :: Message a => a -> SomeMessage
sm = SomeMessage sm = SomeMessage
--------------------------------------------------------------------------------
-- Backwards Compatibility:
--------------------------------------------------------------------------------
{-# DEPRECATED send "Use sendMessageB instead." #-}
{-# DEPRECATED sendSM "Use sendSomeMessageB instead." #-}
{-# DEPRECATED sendSM_ "Use sendSomeMessage instead." #-}
{-# DEPRECATED tryInOrder "Use tryInOrderWithNoRefreshToCurrentB instead." #-}
{-# DEPRECATED tryInOrder_ "Use tryInOrderWithNoRefreshToCurrent instead." #-}
{-# DEPRECATED tryMessage "Use tryMessageWithNoRefreshToCurrentB instead." #-}
{-# DEPRECATED tryMessage_ "Use tryMessageWithNoRefreshToCurrent instead." #-}
-- $backwardsCompatibility
-- The following functions exist solely for compatibility with pre-0.14
-- releases.
-- | See 'sendMessageWithNoRefreshToCurrentB'.
send :: Message a => a -> X Bool
send = sendMessageWithNoRefreshToCurrentB
-- | See 'sendSomeMessageWithNoRefreshToCurrentB'.
sendSM :: SomeMessage -> X Bool
sendSM = sendSomeMessageWithNoRefreshToCurrentB
-- | See 'sendSomeMessageWithNoRefreshToCurrent'.
sendSM_ :: SomeMessage -> X ()
sendSM_ = sendSomeMessageWithNoRefreshToCurrent
-- | See 'tryInOrderWithNoRefreshToCurrentB'.
tryInOrder :: [SomeMessage] -> X Bool
tryInOrder = tryInOrderWithNoRefreshToCurrentB
-- | See 'tryInOrderWithNoRefreshToCurrent'.
tryInOrder_ :: [SomeMessage] -> X ()
tryInOrder_ = tryInOrderWithNoRefreshToCurrent
-- | See 'tryMessageWithNoRefreshToCurrentB'.
tryMessage :: (Message a, Message b) => a -> b -> X Bool
tryMessage = tryMessageWithNoRefreshToCurrentB
-- | See 'tryMessageWithNoRefreshToCurrent'.
tryMessage_ :: (Message a, Message b) => a -> b -> X ()
tryMessage_ = tryMessageWithNoRefreshToCurrent

View File

@ -12,7 +12,7 @@
-- Adds actions for minimizing and maximizing windows -- Adds actions for minimizing and maximizing windows
-- --
-- This module should be used with "XMonad.Layout.Minimize". Add 'minimize' to your -- This module should be used with "XMonad.Layout.Minimize". Add 'minimize' to your
-- layout modifiers as described in "XMonad.Layout.Minimized" and use actions from -- layout modifiers as described in "XMonad.Layout.Minimize" and use actions from
-- this module -- this module
-- --
-- Possible keybindings: -- Possible keybindings:

View File

@ -0,0 +1,205 @@
{-# LANGUAGE NamedFieldPuns, GeneralizedNewtypeDeriving #-}
-----------------------------------------------------------------------------
-- |
-- Module : XMonad.Actions.MostRecentlyUsed
-- Description : Tab through windows by recency of use.
-- Copyright : (c) 2022 L. S. Leary
-- License : BSD3-style (see LICENSE)
--
-- Maintainer : @LSLeary (on github)
-- Stability : unstable
-- Portability : unportable
--
-- Based on the Alt+Tab behaviour common outside of xmonad.
--
-----------------------------------------------------------------------------
-- --< Imports & Exports >-- {{{
module XMonad.Actions.MostRecentlyUsed (
-- * Usage
-- $usage
-- * Interface
configureMRU,
mostRecentlyUsed,
withMostRecentlyUsed,
Location(..),
) where
-- base
import Data.List.NonEmpty (nonEmpty)
import Data.IORef (newIORef, readIORef, writeIORef, modifyIORef)
import Control.Monad.IO.Class (MonadIO)
-- mtl
import Control.Monad.Trans (lift)
import Control.Monad.State (get, put, gets)
-- containers
import qualified Data.Map.Strict as M
-- xmonad
import XMonad
( Window, KeySym, keyPress, io
, Event (DestroyWindowEvent, UnmapEvent, ev_send_event, ev_window)
)
import XMonad.Core
( X, XConfig(..), windowset, WorkspaceId, ScreenId
, ExtensionClass(..), StateExtension(..)
, waitingUnmap
)
import XMonad.Operations (screenWorkspace)
import qualified XMonad.StackSet as W
-- xmonad-contrib
import qualified XMonad.Util.ExtensibleConf as XC
import qualified XMonad.Util.ExtensibleState as XS
import XMonad.Util.PureX
(handlingRefresh, curScreenId, curTag, greedyView, view, peek, focusWindow)
import XMonad.Util.History (History, origin, event, erase, ledger)
import XMonad.Actions.Repeatable (repeatableSt)
import XMonad.Prelude
-- }}}
-- --< Core Data Types: WindowHistory & Location >-- {{{
data WindowHistory = WinHist
{ busy :: !Bool
, hist :: !(History Window Location)
} deriving (Show, Read)
instance ExtensionClass WindowHistory where
initialValue = WinHist
{ busy = False
, hist = origin
}
extensionType = PersistentExtension
data Location = Location
{ workspace :: !WorkspaceId
, screen :: !ScreenId
} deriving (Show, Read, Eq, Ord)
-- }}}
-- --< Interface >-- {{{
-- $usage
--
-- 'configureMRU' must be applied to your config in order for 'mostRecentlyUsed'
-- to work.
--
-- > main :: IO ()
-- > main = xmonad . configureMRU . ... $ def
-- > { ...
-- > }
--
-- Once that's done, it can be used normally in keybinds:
--
-- > , ((mod1Mask, xK_Tab), mostRecentlyUsed [xK_Alt_L, xK_Alt_R] xK_Tab)
--
-- N.B.: This example assumes that 'mod1Mask' corresponds to alt, which is not
-- always the case, depending on how your system is configured.
-- | Configure xmonad to support 'mostRecentlyUsed'.
configureMRU :: XConfig l -> XConfig l
configureMRU = XC.once f (MRU ()) where
f cnf = cnf
{ logHook = logHook cnf <> logWinHist
, handleEventHook = handleEventHook cnf <> winHistEH
}
newtype MRU = MRU () deriving Semigroup
-- | An action to browse through the history of focused windows, taking
-- another step back with each tap of the key.
mostRecentlyUsed
:: [KeySym] -- ^ The 'KeySym's corresponding to the modifier to which the
-- action is bound.
-> KeySym -- ^ The 'KeySym' corresponding to the key to which the action
-- is bound.
-> X ()
mostRecentlyUsed mods key = do
(toUndo, undo) <- undoer
let undoably curThing withThing thing = curThing >>= \cur ->
when (cur /= thing) $ withThing thing >> toUndo (withThing cur)
withMostRecentlyUsed mods key $ \win Location{workspace,screen} ->
handlingRefresh $ do
undo
undoably curScreenId viewScreen screen
undoably curTag greedyView workspace
mi <- gets (W.findTag win . windowset)
for_ mi $ \i -> do
undoably curTag greedyView i
mfw <- peek
for_ mfw $ \fw -> do
undoably (pure fw) focusWindow win
where
undoer :: (MonadIO m, Monoid a) => m (m a -> m (), m a)
undoer = do
ref <- io . newIORef $ pure mempty
let toUndo = io . modifyIORef ref . liftA2 (<>)
undo = join (io $ readIORef ref)
<* io (writeIORef ref $ pure mempty)
pure (toUndo, undo)
viewScreen :: ScreenId -> X Any
viewScreen scr = screenWorkspace scr >>= foldMap view
-- | A version of 'mostRecentlyUsed' that allows you to customise exactly what
-- is done with each window you tab through (the default being to visit its
-- previous 'Location' and give it focus).
withMostRecentlyUsed
:: [KeySym] -- ^ The 'KeySym's corresponding to the
-- modifier to which the action is bound.
-> KeySym -- ^ The 'KeySym' corresponding to the key to
-- which the action is bound.
-> (Window -> Location -> X ()) -- ^ The function applied to each window.
-> X ()
withMostRecentlyUsed mods tab preview = do
wh@WinHist{busy,hist} <- XS.get
unless busy $ do
XS.put wh{ busy = True }
for_ (nonEmpty $ ledger hist) $ \ne -> do
mfw <- gets (W.peek . windowset)
let iSt = case cycleS ne of
(w, _) :~ s | mfw == Just w -> s
s -> s
repeatableSt iSt mods tab $ \t s ->
when (t == keyPress && s == tab) (pop >>= lift . uncurry preview)
XS.modify $ \ws@WinHist{} -> ws{ busy = False }
logWinHist
where
pop = do
h :~ t <- get
put t $> h
-- }}}
-- --< Raw Config >-- {{{
logWinHist :: X ()
logWinHist = do
wh@WinHist{busy,hist} <- XS.get
unless busy $ do
cs <- gets (W.current . windowset)
let cws = W.workspace cs
for_ (W.stack cws) $ \st -> do
let location = Location{ workspace = W.tag cws, screen = W.screen cs }
XS.put wh{ hist = event (W.focus st) location hist }
winHistEH :: Event -> X All
winHistEH ev = All True <$ case ev of
UnmapEvent{ ev_send_event = synth, ev_window = w } -> do
e <- gets (fromMaybe 0 . M.lookup w . waitingUnmap)
when (synth || e == 0) (collect w)
DestroyWindowEvent{ ev_window = w } -> collect w
_ -> pure ()
where collect w = XS.modify $ \wh@WinHist{hist} -> wh{ hist = erase w hist }
-- }}}

View File

@ -32,7 +32,7 @@ import Data.Map (Map)
-- $usage -- $usage
-- --
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.MouseGestures -- > import XMonad.Actions.MouseGestures
-- > import qualified XMonad.StackSet as W -- > import qualified XMonad.StackSet as W

View File

@ -37,7 +37,7 @@ import XMonad.Util.XUtils
-- "XMonad.Layout.SimpleFloat" or "XMonad.Layout.DecorationMadness". -- "XMonad.Layout.SimpleFloat" or "XMonad.Layout.DecorationMadness".
-- --
-- You can use this module with the following in your -- You can use this module with the following in your
-- @~\/.xmonad\/xmonad.hs@: -- @xmonad.hs@:
-- --
-- > import XMonad.Actions.MouseResize -- > import XMonad.Actions.MouseResize
-- > import XMonad.Layout.WindowArranger -- > import XMonad.Layout.WindowArranger
@ -50,9 +50,9 @@ import XMonad.Util.XUtils
-- --
-- > main = xmonad def { layoutHook = myLayout } -- > main = xmonad def { layoutHook = myLayout }
-- --
-- For more detailed instructions on editing the layoutHook see: -- For more detailed instructions on editing the layoutHook see
-- -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial> and
-- "XMonad.Doc.Extending#Editing_the_layout_hook" -- "XMonad.Doc.Extending#Editing_the_layout_hook".
mouseResize :: l a -> ModifiedLayout MouseResize l a mouseResize :: l a -> ModifiedLayout MouseResize l a
mouseResize = ModifiedLayout (MR []) mouseResize = ModifiedLayout (MR [])

View File

@ -46,7 +46,6 @@ module XMonad.Actions.Navigation2D ( -- * Usage
, sideNavigation , sideNavigation
, sideNavigationWithBias , sideNavigationWithBias
, hybridOf , hybridOf
, hybridNavigation
, fullScreenRect , fullScreenRect
, singleWindowRect , singleWindowRect
, switchLayer , switchLayer
@ -67,6 +66,7 @@ import qualified XMonad.StackSet as W
import qualified XMonad.Util.ExtensibleState as XS import qualified XMonad.Util.ExtensibleState as XS
import XMonad.Util.EZConfig (additionalKeys, additionalKeysP) import XMonad.Util.EZConfig (additionalKeys, additionalKeysP)
import XMonad.Util.Types import XMonad.Util.Types
import qualified Data.List.NonEmpty as NE
-- $usage -- $usage
-- #Usage# -- #Usage#
@ -85,7 +85,7 @@ import XMonad.Util.Types
-- layers and allows customization of the navigation strategy for the tiled -- layers and allows customization of the navigation strategy for the tiled
-- layer based on the layout currently in effect. -- layer based on the layout currently in effect.
-- --
-- You can use this module with (a subset of) the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with (a subset of) the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.Navigation2D -- > import XMonad.Actions.Navigation2D
-- --
@ -98,7 +98,15 @@ import XMonad.Util.Types
-- > False -- > False
-- > $ def -- > $ def
-- --
-- Alternatively, you can use navigation2DP: -- /NOTE/: the @def@ argument to 'navigation2D' contains the strategy
-- that decides which windows actually get selected. While the default
-- behaviour tries to keep them into account, if you use modules that
-- influence tiling in some way, like "XMonad.Layout.Spacing" or
-- "XMonad.Layout.Gaps", you should think about using a different
-- strategy, if you find the default behaviour to be unnatural. Check
-- out the [finer points](#g:Finer_Points) below for more information.
--
-- Alternatively to 'navigation2D', you can use 'navigation2DP':
-- --
-- > main = xmonad $ navigation2DP def -- > main = xmonad $ navigation2DP def
-- > ("<Up>", "<Left>", "<Down>", "<Right>") -- > ("<Up>", "<Left>", "<Down>", "<Right>")
@ -108,7 +116,7 @@ import XMonad.Util.Types
-- > $ def -- > $ def
-- --
-- That's it. If instead you'd like more control, you can combine -- That's it. If instead you'd like more control, you can combine
-- withNavigation2DConfig and additionalNav2DKeys or additionalNav2DKeysP: -- 'withNavigation2DConfig' and 'additionalNav2DKeys' or 'additionalNav2DKeysP':
-- --
-- > main = xmonad $ withNavigation2DConfig def -- > main = xmonad $ withNavigation2DConfig def
-- > $ additionalNav2DKeys (xK_Up, xK_Left, xK_Down, xK_Right) -- > $ additionalNav2DKeys (xK_Up, xK_Left, xK_Down, xK_Right)
@ -162,7 +170,7 @@ import XMonad.Util.Types
-- --
-- For detailed instruction on editing the key binding see: -- For detailed instruction on editing the key binding see:
-- --
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- $finer_points -- $finer_points
-- #Finer_Points# -- #Finer_Points#
@ -179,9 +187,19 @@ import XMonad.Util.Types
-- values in the above example to 'True'. You could also decide you want -- values in the above example to 'True'. You could also decide you want
-- wrapping only for a subset of the operations and no wrapping for others. -- wrapping only for a subset of the operations and no wrapping for others.
-- --
-- By default, all layouts use the 'defaultTiledNavigation' strategy specified -- By default, all layouts use the 'defaultTiledNavigation' strategy
-- in the 'Navigation2DConfig' (by default, line navigation is used). To -- specified in the 'Navigation2DConfig' (by default, line navigation is
-- override this behaviour for some layouts, add a pair (\"layout name\", -- used). Many more navigation strategies are available; some may feel
-- more natural, depending on the layout and user:
--
-- * 'lineNavigation'
-- * 'centerNavigation'
-- * 'sideNavigation'
-- * 'sideNavigationWithBias'
--
-- There is also the ability to combine two strategies with 'hybridOf'.
--
-- To override the default behaviour for some layouts, add a pair (\"layout name\",
-- navigation strategy) to the 'layoutNavigation' list in the -- navigation strategy) to the 'layoutNavigation' list in the
-- 'Navigation2DConfig', where \"layout name\" is the string reported by the -- 'Navigation2DConfig', where \"layout name\" is the string reported by the
-- layout's description method (normally what is shown as the layout name in -- layout's description method (normally what is shown as the layout name in
@ -327,7 +345,7 @@ centerNavigation = N 2 doCenterNavigation
-- and push it to the right until it intersects with at least one other window. -- and push it to the right until it intersects with at least one other window.
-- Of those windows, one with a point that is the closest to the centre of the -- Of those windows, one with a point that is the closest to the centre of the
-- line (+1) is selected. This is probably the most intuitive strategy for the -- line (+1) is selected. This is probably the most intuitive strategy for the
-- tiled layer when using XMonad.Layout.Spacing. -- tiled layer when using "XMonad.Layout.Spacing".
sideNavigation :: Navigation2D sideNavigation :: Navigation2D
sideNavigation = N 1 (doSideNavigationWithBias 1) sideNavigation = N 1 (doSideNavigationWithBias 1)
@ -359,10 +377,6 @@ hybridOf (N g1 s1) (N g2 s2) = N (max g1 g2) $ applyToBoth s1 s2
where where
applyToBoth f g a b c = f a b c <|> g a b c applyToBoth f g a b c = f a b c <|> g a b c
{-# DEPRECATED hybridNavigation "Use hybridOf with lineNavigation and centerNavigation as arguments." #-}
hybridNavigation :: Navigation2D
hybridNavigation = hybridOf lineNavigation centerNavigation
-- | Stores the configuration of directional navigation. The 'Default' instance -- | Stores the configuration of directional navigation. The 'Default' instance
-- uses line navigation for the tiled layer and for navigation between screens, -- uses line navigation for the tiled layer and for navigation between screens,
-- and center navigation for the float layer. No custom navigation strategies -- and center navigation for the float layer. No custom navigation strategies
@ -451,7 +465,7 @@ withNavigation2DConfig conf2d xconf = xconf { startupHook = startupHook xconf
} }
instance Default Navigation2DConfig where instance Default Navigation2DConfig where
def = Navigation2DConfig { defaultTiledNavigation = lineNavigation def = Navigation2DConfig { defaultTiledNavigation = hybridOf lineNavigation sideNavigation
, floatNavigation = centerNavigation , floatNavigation = centerNavigation
, screenNavigation = lineNavigation , screenNavigation = lineNavigation
, layoutNavigation = [] , layoutNavigation = []
@ -770,8 +784,7 @@ doCenterNavigation dir (cur, rect) winrects
-- All the points that coincide with the current center and succeed it -- All the points that coincide with the current center and succeed it
-- in the (appropriately ordered) window stack. -- in the (appropriately ordered) window stack.
onCtr' = L.tail $ L.dropWhile ((cur /=) . fst) onCtr onCtr' = L.drop 1 $ L.dropWhile ((cur /=) . fst) onCtr
-- tail should be safe here because cur should be in onCtr
-- All the points that do not coincide with the current center and which -- All the points that do not coincide with the current center and which
-- lie in the (rotated) right cone. -- lie in the (rotated) right cone.
@ -871,8 +884,8 @@ swap win winset = W.focusWindow cur
-- Reconstruct the workspaces' window stacks to reflect the swap. -- Reconstruct the workspaces' window stacks to reflect the swap.
newvisws = zipWith (\ws wns -> ws { W.stack = W.differentiate wns }) visws newwins newvisws = zipWith (\ws wns -> ws { W.stack = W.differentiate wns }) visws newwins
newscrs = zipWith (\scr ws -> scr { W.workspace = ws }) scrs newvisws newscrs = zipWith (\scr ws -> scr { W.workspace = ws }) scrs newvisws
newwinset = winset { W.current = head newscrs newwinset = winset { W.current = NE.head (notEmpty newscrs) -- Always at least one screen.
, W.visible = tail newscrs , W.visible = drop 1 newscrs
} }
-- | Calculates the center of a rectangle -- | Calculates the center of a rectangle

View File

@ -1,155 +1,187 @@
-----------------------------------------------------------------------------
-- | -- |
-- Module : XMonad.Actions.OnScreen -- Module : XMonad.Actions.OnScreen
-- Description : Control workspaces on different screens (in xinerama mode). -- Description : Control workspaces on different screens (in xinerama mode).
-- Copyright : (c) 2009 Nils Schweinsberg -- Copyright : (c) 2009-2025 Nils Schweinsberg
-- License : BSD3-style (see LICENSE) -- License : BSD3-style (see LICENSE)
-- --
-- Maintainer : Nils Schweinsberg <mail@n-sch.de> -- Maintainer : Nils Schweinsberg <mail@nils.cc>
-- Stability : unstable -- Stability : unstable
-- Portability : unportable -- Portability : unportable
-- --
-- Control workspaces on different screens (in xinerama mode). -- Control workspaces on different screens (in xinerama mode).
-- module XMonad.Actions.OnScreen
----------------------------------------------------------------------------- ( -- * Usage
module XMonad.Actions.OnScreen (
-- * Usage
-- $usage -- $usage
onScreen onScreen,
, onScreen' onScreen',
, Focus(..) Focus (..),
, viewOnScreen viewOnScreen,
, greedyViewOnScreen greedyViewOnScreen,
, onlyOnScreen onlyOnScreen,
, toggleOnScreen toggleOnScreen,
, toggleGreedyOnScreen toggleGreedyOnScreen,
) where )
where
import XMonad import XMonad
import XMonad.Prelude (fromMaybe, guard) import XMonad.Prelude (empty, fromMaybe, guard)
import XMonad.StackSet hiding (new) import XMonad.StackSet hiding (new)
-- | Focus data definitions -- | Focus data definitions
data Focus = FocusNew -- ^ always focus the new screen data Focus
| FocusCurrent -- ^ always keep the focus on the current screen = -- | always focus the new screen
| FocusTag WorkspaceId -- ^ always focus tag i on the new stack FocusNew
| FocusTagVisible WorkspaceId -- ^ focus tag i only if workspace with tag i is visible on the old stack | -- | always keep the focus on the current screen
FocusCurrent
| -- | always focus tag i on the new stack
FocusTag WorkspaceId
| -- | focus tag i only if workspace with tag i is visible on the old stack
FocusTagVisible WorkspaceId
-- | Run any function that modifies the stack on a given screen. This function -- | Run any function that modifies the stack on a given screen. This function
-- will also need to know which Screen to focus after the function has been -- will also need to know which Screen to focus after the function has been
-- run. -- run.
onScreen :: (WindowSet -> WindowSet) -- ^ function to run onScreen ::
-> Focus -- ^ what to do with the focus -- | function to run
-> ScreenId -- ^ screen id (WindowSet -> WindowSet) ->
-> WindowSet -- ^ current stack -- | what to do with the focus
-> WindowSet Focus ->
-- | screen id
ScreenId ->
-- | current stack
WindowSet ->
WindowSet
onScreen f foc sc st = fromMaybe st $ do onScreen f foc sc st = fromMaybe st $ do
ws <- lookupWorkspace sc st ws <- lookupWorkspace sc st
let fStack = f $ view ws st let fStack = f $ view ws st
return $ setFocus foc st fStack
return $ setFocus foc st fStack
-- set focus for new stack -- set focus for new stack
setFocus :: Focus setFocus ::
-> WindowSet -- ^ old stack Focus ->
-> WindowSet -- ^ new stack -- | old stack
-> WindowSet WindowSet ->
setFocus FocusNew _ new = new -- | new stack
setFocus FocusCurrent old new = WindowSet ->
case lookupWorkspace (screen $ current old) new of WindowSet
Nothing -> new setFocus FocusNew _ new = new
Just i -> view i new setFocus FocusCurrent old new =
setFocus (FocusTag i) _ new = view i new case lookupWorkspace (screen $ current old) new of
Nothing -> new
Just i -> view i new
setFocus (FocusTag i) _ new = view i new
setFocus (FocusTagVisible i) old new = setFocus (FocusTagVisible i) old new =
if i `elem` map (tag . workspace) (visible old) if i `elem` map (tag . workspace) (visible old)
then setFocus (FocusTag i) old new then setFocus (FocusTag i) old new
else setFocus FocusCurrent old new else setFocus FocusCurrent old new
-- | A variation of @onScreen@ which will take any @X ()@ function and run it -- | A variation of @onScreen@ which will take any @X ()@ function and run it
-- on the given screen. -- on the given screen.
-- Warning: This function will change focus even if the function it's supposed -- Warning: This function will change focus even if the function it's supposed
-- to run doesn't succeed. -- to run doesn't succeed.
onScreen' :: X () -- ^ X function to run onScreen' ::
-> Focus -- ^ focus -- | X function to run
-> ScreenId -- ^ screen id X () ->
-> X () -- | focus
Focus ->
-- | screen id
ScreenId ->
X ()
onScreen' x foc sc = do onScreen' x foc sc = do
st <- gets windowset st <- gets windowset
case lookupWorkspace sc st of case lookupWorkspace sc st of
Nothing -> return () Nothing -> return ()
Just ws -> do Just ws -> do
windows $ view ws windows $ view ws
x x
windows $ setFocus foc st windows $ setFocus foc st
-- | Switch to workspace @i@ on screen @sc@. If @i@ is visible use @view@ to -- | Switch to workspace @i@ on screen @sc@. If @i@ is visible use @view@ to
-- switch focus to the workspace @i@. -- switch focus to the workspace @i@.
viewOnScreen :: ScreenId -- ^ screen id viewOnScreen ::
-> WorkspaceId -- ^ index of the workspace -- | screen id
-> WindowSet -- ^ current stack ScreenId ->
-> WindowSet -- | index of the workspace
WorkspaceId ->
-- | current stack
WindowSet ->
WindowSet
viewOnScreen sid i = viewOnScreen sid i =
onScreen (view i) (FocusTag i) sid onScreen (view i) (FocusTag i) sid
-- | Switch to workspace @i@ on screen @sc@. If @i@ is visible use @greedyView@ -- | Switch to workspace @i@ on screen @sc@. If @i@ is visible use @greedyView@
-- to switch the current workspace with workspace @i@. -- to switch the current workspace with workspace @i@.
greedyViewOnScreen :: ScreenId -- ^ screen id greedyViewOnScreen ::
-> WorkspaceId -- ^ index of the workspace -- | screen id
-> WindowSet -- ^ current stack ScreenId ->
-> WindowSet -- | index of the workspace
WorkspaceId ->
-- | current stack
WindowSet ->
WindowSet
greedyViewOnScreen sid i = greedyViewOnScreen sid i =
onScreen (greedyView i) (FocusTagVisible i) sid onScreen (greedyView i) (FocusTagVisible i) sid
-- | Switch to workspace @i@ on screen @sc@. If @i@ is visible do nothing. -- | Switch to workspace @i@ on screen @sc@. If @i@ is visible do nothing.
onlyOnScreen :: ScreenId -- ^ screen id onlyOnScreen ::
-> WorkspaceId -- ^ index of the workspace -- | screen id
-> WindowSet -- ^ current stack ScreenId ->
-> WindowSet -- | index of the workspace
WorkspaceId ->
-- | current stack
WindowSet ->
WindowSet
onlyOnScreen sid i = onlyOnScreen sid i =
onScreen (view i) FocusCurrent sid onScreen (view i) FocusCurrent sid
-- | @toggleOrView@ as in "XMonad.Actions.CycleWS" for @onScreen@ with view -- | @toggleOrView@ as in "XMonad.Actions.CycleWS" for @onScreen@ with view
toggleOnScreen :: ScreenId -- ^ screen id toggleOnScreen ::
-> WorkspaceId -- ^ index of the workspace -- | screen id
-> WindowSet -- ^ current stack ScreenId ->
-> WindowSet -- | index of the workspace
WorkspaceId ->
-- | current stack
WindowSet ->
WindowSet
toggleOnScreen sid i = toggleOnScreen sid i =
onScreen (toggleOrView' view i) FocusCurrent sid onScreen (toggleOrView' view i) FocusCurrent sid
-- | @toggleOrView@ from "XMonad.Actions.CycleWS" for @onScreen@ with greedyView -- | @toggleOrView@ from "XMonad.Actions.CycleWS" for @onScreen@ with greedyView
toggleGreedyOnScreen :: ScreenId -- ^ screen id toggleGreedyOnScreen ::
-> WorkspaceId -- ^ index of the workspace -- | screen id
-> WindowSet -- ^ current stack ScreenId ->
-> WindowSet -- | index of the workspace
WorkspaceId ->
-- | current stack
WindowSet ->
WindowSet
toggleGreedyOnScreen sid i = toggleGreedyOnScreen sid i =
onScreen (toggleOrView' greedyView i) FocusCurrent sid onScreen (toggleOrView' greedyView i) FocusCurrent sid
-- a \"pure\" version of X.A.CycleWS.toggleOrDoSkip -- a \"pure\" version of X.A.CycleWS.toggleOrDoSkip
toggleOrView' :: (WorkspaceId -> WindowSet -> WindowSet) -- ^ function to run toggleOrView' ::
-> WorkspaceId -- ^ tag to look for -- | function to run
-> WindowSet -- ^ current stackset (WorkspaceId -> WindowSet -> WindowSet) ->
-> WindowSet -- | tag to look for
WorkspaceId ->
-- | current stackset
WindowSet ->
WindowSet
toggleOrView' f i st = fromMaybe (f i st) $ do toggleOrView' f i st = fromMaybe (f i st) $ do
let st' = hidden st let st' = hidden st
-- make sure we actually have to do something -- make sure we actually have to do something
guard $ i == (tag . workspace $ current st) guard $ i == (tag . workspace $ current st)
guard $ not (null st') case st' of
-- finally, toggle! [] -> empty
return $ f (tag . head $ st') st (h : _) -> return $ f (tag h) st -- finally, toggle!
-- $usage -- $usage
-- --
-- This module provides an easy way to control, what you see on other screens in -- This module provides an easy way to control, what you see on other screens in
-- xinerama mode without having to focus them. Put this into your -- xinerama mode without having to focus them. Put this into your
-- @~\/.xmonad\/xmonad.hs@: -- @xmonad.hs@:
-- --
-- > import XMonad.Actions.OnScreen -- > import XMonad.Actions.OnScreen
-- --
@ -183,4 +215,4 @@ toggleOrView' f i st = fromMaybe (f i st) $ do
-- where 0 is the first screen and \"1\" the workspace with the tag \"1\". -- where 0 is the first screen and \"1\" the workspace with the tag \"1\".
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.

View File

@ -25,14 +25,14 @@ import XMonad.StackSet as S
-- $usage -- $usage
-- --
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.PerLayoutKeys -- > import XMonad.Actions.PerLayoutKeys
-- --
-- > ,((0, xK_F2), bindByLayout [("Tall", spawn "rxvt"), ("Mirror Tall", spawn "xeyes"), ("", spawn "xmessage hello")]) -- > ,((0, xK_F2), bindByLayout [("Tall", spawn "rxvt"), ("Mirror Tall", spawn "xeyes"), ("", spawn "xmessage hello")])
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- | Uses supplied function to decide which action to run depending on current layout name. -- | Uses supplied function to decide which action to run depending on current layout name.
chooseActionByLayout :: (String->X()) -> X() chooseActionByLayout :: (String->X()) -> X()

View File

@ -24,7 +24,7 @@ import XMonad
-- $usage -- $usage
-- --
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.PerWindowKeys -- > import XMonad.Actions.PerWindowKeys
-- --
@ -41,7 +41,7 @@ import XMonad
-- doThisIfTheOthersFail)]@. -- doThisIfTheOthersFail)]@.
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- | Run an action if a Query holds true. Doesn't stop at the first one that -- | Run an action if a Query holds true. Doesn't stop at the first one that
-- does, however, and could potentially run all actions. -- does, however, and could potentially run all actions.

View File

@ -25,14 +25,14 @@ import XMonad.StackSet as S
-- $usage -- $usage
-- --
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.PerWorkspaceKeys -- > import XMonad.Actions.PerWorkspaceKeys
-- --
-- > ,((0, xK_F2), bindOn [("1", spawn "rxvt"), ("2", spawn "xeyes"), ("", spawn "xmessage hello")]) -- > ,((0, xK_F2), bindOn [("1", spawn "rxvt"), ("2", spawn "xeyes"), ("", spawn "xmessage hello")])
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- | Uses supplied function to decide which action to run depending on current workspace name. -- | Uses supplied function to decide which action to run depending on current workspace name.
chooseAction :: (String->X()) -> X() chooseAction :: (String->X()) -> X()

View File

@ -1,4 +1,6 @@
{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ParallelListComp #-}
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- | -- |
-- Module : XMonad.Actions.PhysicalScreens -- Module : XMonad.Actions.PhysicalScreens
@ -28,10 +30,13 @@ module XMonad.Actions.PhysicalScreens (
, getScreenIdAndRectangle , getScreenIdAndRectangle
, screenComparatorById , screenComparatorById
, screenComparatorByRectangle , screenComparatorByRectangle
, rescreen
) where ) where
import XMonad import Data.List.NonEmpty (nonEmpty)
import XMonad.Prelude (elemIndex, fromMaybe, on, sortBy) import XMonad hiding (rescreen)
import XMonad.Prelude (elemIndex, fromMaybe, on, sortBy, NonEmpty((:|)))
import qualified Data.List.NonEmpty as NE
import qualified XMonad.StackSet as W import qualified XMonad.StackSet as W
{- $usage {- $usage
@ -46,7 +51,7 @@ To create a screen comparator you can use screenComparatorByRectangle or screenC
The default ScreenComparator orders screens by the upper-left-most corner, from top-to-bottom The default ScreenComparator orders screens by the upper-left-most corner, from top-to-bottom
and then left-to-right. and then left-to-right.
Example usage in your @~\/.xmonad\/xmonad.hs@ file: Example usage in your @xmonad.hs@ file:
> import XMonad.Actions.PhysicalScreens > import XMonad.Actions.PhysicalScreens
> import Data.Default > import Data.Default
@ -65,7 +70,7 @@ Example usage in your @~\/.xmonad\/xmonad.hs@ file:
> , (f, mask) <- [(viewScreen def, 0), (sendToScreen def, shiftMask)]] > , (f, mask) <- [(viewScreen def, 0), (sendToScreen def, shiftMask)]]
For detailed instructions on editing your key bindings, see For detailed instructions on editing your key bindings, see
"XMonad.Doc.Extending#Editing_key_bindings". <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-} -}
-- | The type of the index of a screen by location -- | The type of the index of a screen by location
@ -75,7 +80,7 @@ getScreenIdAndRectangle :: W.Screen i l a ScreenId ScreenDetail -> (ScreenId, Re
getScreenIdAndRectangle screen = (W.screen screen, rect) where getScreenIdAndRectangle screen = (W.screen screen, rect) where
rect = screenRect $ W.screenDetail screen rect = screenRect $ W.screenDetail screen
-- | Translate a physical screen index to a "ScreenId" -- | Translate a physical screen index to a 'ScreenId'
getScreen:: ScreenComparator -> PhysicalScreen -> X (Maybe ScreenId) getScreen:: ScreenComparator -> PhysicalScreen -> X (Maybe ScreenId)
getScreen (ScreenComparator cmpScreen) (P i) = do w <- gets windowset getScreen (ScreenComparator cmpScreen) (P i) = do w <- gets windowset
let screens = W.current w : W.visible w let screens = W.current w : W.visible w
@ -146,3 +151,53 @@ onNextNeighbour sc = neighbourWindows sc 1
-- | Apply operation on a WindowSet with the WorkspaceId of the previous screen in the physical order as parameter. -- | Apply operation on a WindowSet with the WorkspaceId of the previous screen in the physical order as parameter.
onPrevNeighbour :: ScreenComparator -> (WorkspaceId -> WindowSet -> WindowSet) -> X () onPrevNeighbour :: ScreenComparator -> (WorkspaceId -> WindowSet -> WindowSet) -> X ()
onPrevNeighbour sc = neighbourWindows sc (-1) onPrevNeighbour sc = neighbourWindows sc (-1)
-- | An alternative to 'XMonad.Operations.rescreen' that avoids reshuffling
-- the workspaces if the number of screens doesn't change and only their
-- locations do. Useful for users of @xrandr --setmonitor@.
--
-- See 'XMonad.Hooks.Rescreen.setRescreenWorkspacesHook', which lets you
-- replace the builtin rescreen handler.
rescreen :: ScreenComparator -> X ()
rescreen (ScreenComparator cmpScreen) = withDisplay (fmap nonEmpty . getCleanedScreenInfo) >>= \case
Nothing -> trace "getCleanedScreenInfo returned []"
Just xinescs -> windows $ rescreen' xinescs
where
rescreen' :: NonEmpty Rectangle -> WindowSet -> WindowSet
rescreen' xinescs ws
| NE.length xinescs == length (W.visible ws) + 1 = rescreenSameLength xinescs ws
| otherwise = rescreenCore xinescs ws
-- the 'XMonad.Operations.rescreen' implementation from core as a fallback
rescreenCore :: NonEmpty Rectangle -> WindowSet -> WindowSet
rescreenCore (xinesc :| xinescs) ws@W.StackSet{ W.current = v, W.visible = vs, W.hidden = hs } =
let (xs, ys) = splitAt (length xinescs) (map W.workspace vs ++ hs)
a = W.Screen (W.workspace v) 0 (SD xinesc)
as = zipWith3 W.Screen xs [1..] $ map SD xinescs
in ws{ W.current = a
, W.visible = as
, W.hidden = ys }
-- sort both existing screens and the screens we just got from xinerama
-- using cmpScreen, and then replace the rectangles in the WindowSet,
-- keeping the order of current/visible workspaces intact
rescreenSameLength :: NonEmpty Rectangle -> WindowSet -> WindowSet
rescreenSameLength xinescs ws =
ws{ W.current = (W.current ws){ W.screenDetail = SD newCurrentRect }
, W.visible = [ w{ W.screenDetail = SD r } | w <- W.visible ws | r <- newVisibleRects ]
}
where
undoSort =
NE.map fst $
NE.sortBy (cmpScreen `on` (getScreenIdAndRectangle . snd)) $
NE.zip ((0 :: Int) :| [1..]) $ -- add indices to undo the sort later
W.current ws :| W.visible ws
newCurrentRect :| newVisibleRects =
NE.map snd $ NE.sortWith fst $ NE.zip undoSort $ -- sort back into current:visible order
NE.map snd $ NE.sortBy cmpScreen $ NE.zip (0 :| [1..]) xinescs
-- TODO:
-- If number of screens before and after isn't the same, we might still
-- try to match locations and avoid changing the workspace for those that
-- didn't move, while making sure that the current workspace is still
-- visible somewhere.

View File

@ -41,13 +41,13 @@ module XMonad.Actions.Plane
import Data.Map (Map, fromList) import Data.Map (Map, fromList)
import XMonad.Prelude import XMonad.Prelude hiding (fromList)
import XMonad import XMonad
import XMonad.StackSet hiding (workspaces) import XMonad.StackSet hiding (workspaces)
import XMonad.Util.Run import XMonad.Util.Run
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@ file: -- You can use this module with the following in your @xmonad.hs@ file:
-- --
-- > import XMonad.Actions.Plane -- > import XMonad.Actions.Plane
-- > import Data.Map (union) -- > import Data.Map (union)
@ -59,7 +59,7 @@ import XMonad.Util.Run
-- > myNewKeys (XConfig {modMask = modm}) = planeKeys modm (Lines 3) Finite -- > myNewKeys (XConfig {modMask = modm}) = planeKeys modm (Lines 3) Finite
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- | Direction to go in the plane. -- | Direction to go in the plane.
data Direction = ToLeft | ToUp | ToRight | ToDown deriving Enum data Direction = ToLeft | ToUp | ToRight | ToDown deriving Enum

View File

@ -29,6 +29,7 @@ module XMonad.Actions.Prefix
, withPrefixArgument , withPrefixArgument
, isPrefixRaw , isPrefixRaw
, isPrefixNumeric , isPrefixNumeric
, orIfPrefixed
, ppFormatPrefix , ppFormatPrefix
) where ) where
@ -40,11 +41,13 @@ import XMonad.Util.ExtensibleState as XS
import XMonad.Util.Paste (sendKey) import XMonad.Util.Paste (sendKey)
import XMonad.Actions.Submap (submapDefaultWithKey) import XMonad.Actions.Submap (submapDefaultWithKey)
import XMonad.Util.EZConfig (readKeySequence) import XMonad.Util.EZConfig (readKeySequence)
import qualified Data.List.NonEmpty as NE
import Data.List.NonEmpty ((<|))
{- $usage {- $usage
This module implements Emacs-style prefix argument. The argument This module implements Emacs-style prefix argument. The argument
comes in two flavours, "Raw" and "Numeric". comes in two flavours, 'Raw' and 'Numeric'.
To initiate the "prefix mode" you hit the prefix keybinding (default To initiate the "prefix mode" you hit the prefix keybinding (default
C-u). This sets the Raw argument value to 1. Repeatedly hitting this C-u). This sets the Raw argument value to 1. Repeatedly hitting this
@ -72,7 +75,7 @@ Binding it in your config
> ((modm, xK_a), withPrefixArgument addMaybeClean) > ((modm, xK_a), withPrefixArgument addMaybeClean)
Hitting MOD-a will add the <file> to the playlist while C-u MOD-a will Hitting MOD-a will add the @\<file\>@ to the playlist while C-u MOD-a will
clear the playlist and then add the file. clear the playlist and then add the file.
You can of course use an anonymous action, like so: You can of course use an anonymous action, like so:
@ -128,11 +131,11 @@ usePrefixArgument :: LayoutClass l Window
-> XConfig l -> XConfig l
-> XConfig l -> XConfig l
usePrefixArgument prefix conf = usePrefixArgument prefix conf =
conf{ keys = M.insert binding (handlePrefixArg [binding]) . keys conf } conf{ keys = M.insert binding (handlePrefixArg (binding :| [])) . keys conf }
where where
binding = case readKeySequence conf prefix of binding = case readKeySequence conf prefix of
Just [key] -> key Just (key :| []) -> key
_ -> (controlMask, xK_u) _ -> (controlMask, xK_u)
-- | Set Prefix up with default prefix key (C-u). -- | Set Prefix up with default prefix key (C-u).
useDefaultPrefixArgument :: LayoutClass l Window useDefaultPrefixArgument :: LayoutClass l Window
@ -140,7 +143,7 @@ useDefaultPrefixArgument :: LayoutClass l Window
-> XConfig l -> XConfig l
useDefaultPrefixArgument = usePrefixArgument "C-u" useDefaultPrefixArgument = usePrefixArgument "C-u"
handlePrefixArg :: [(KeyMask, KeySym)] -> X () handlePrefixArg :: NonEmpty (KeyMask, KeySym) -> X ()
handlePrefixArg events = do handlePrefixArg events = do
ks <- asks keyActions ks <- asks keyActions
logger <- asks (logHook . config) logger <- asks (logHook . config)
@ -161,19 +164,19 @@ handlePrefixArg events = do
Raw _ -> XS.put $ Numeric x Raw _ -> XS.put $ Numeric x
Numeric a -> XS.put $ Numeric $ a * 10 + x Numeric a -> XS.put $ Numeric $ a * 10 + x
None -> return () -- should never happen None -> return () -- should never happen
handlePrefixArg (key:events) handlePrefixArg (key <| events)
else do else do
prefix <- XS.get prefix <- XS.get
mapM_ (uncurry sendKey) $ case prefix of mapM_ (uncurry sendKey) $ case prefix of
Raw a -> replicate a (head events) ++ [key] Raw a -> replicate a (NE.head events) ++ [key]
_ -> reverse (key:events) _ -> reverse (key : toList events)
keyToNum = (xK_0, 0) : zip [xK_1 .. xK_9] [1..9] keyToNum = (xK_0, 0) : zip [xK_1 .. xK_9] [1..9]
-- | Turn a prefix-aware X action into an X-action. -- | Turn a prefix-aware X action into an X-action.
-- --
-- First, fetch the current prefix, then pass it as argument to the -- First, fetch the current prefix, then pass it as argument to the
-- original function. You should use this to "run" your commands. -- original function. You should use this to "run" your commands.
withPrefixArgument :: (PrefixArgument -> X ()) -> X () withPrefixArgument :: (PrefixArgument -> X a) -> X a
withPrefixArgument = (>>=) XS.get withPrefixArgument = (>>=) XS.get
-- | Test if 'PrefixArgument' is 'Raw' or not. -- | Test if 'PrefixArgument' is 'Raw' or not.
@ -186,6 +189,13 @@ isPrefixNumeric :: PrefixArgument -> Bool
isPrefixNumeric (Numeric _) = True isPrefixNumeric (Numeric _) = True
isPrefixNumeric _ = False isPrefixNumeric _ = False
-- | Execute the first action, unless any prefix argument is given,
-- in which case the second action is chosen instead.
--
-- > action1 `orIfPrefixed` action2
orIfPrefixed :: X a -> X a -> X a
orIfPrefixed xa xb = withPrefixArgument $ bool xa xb . isPrefixRaw
-- | Format the prefix using the Emacs convetion for use in a -- | Format the prefix using the Emacs convetion for use in a
-- statusbar, like xmobar. -- statusbar, like xmobar.
-- --

545
XMonad/Actions/Profiles.hs Normal file
View File

@ -0,0 +1,545 @@
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE DerivingVia #-}
--------------------------------------------------------------------------------
-- |
-- Module : XMonad.Actions.Profiles
-- Description : Group your workspaces by similarity.
-- Copyright : (c) Mislav Zanic
-- License : BSD3-style (see LICENSE)
--
-- Maintainer : Mislav Zanic <mislavzanic3@gmail.com>
-- Stability : experimental
-- Portability : unportable
--
--------------------------------------------------------------------------------
module XMonad.Actions.Profiles
( -- * Overview
-- $overview
-- * Usage
-- $usage
-- * Types
ProfileId
, Profile(..)
, ProfileConfig(..)
-- * Hooks
, addProfiles
, addProfilesWithHistory
-- * Switching profiles
, switchToProfile
-- * Workspace navigation and keybindings
, wsFilter
, bindOn
-- * Loggers and pretty printers
, excludeWSPP
, profileLogger
-- * Prompts
, switchProfilePrompt
, addWSToProfilePrompt
, removeWSFromProfilePrompt
, switchProfileWSPrompt
, shiftProfileWSPrompt
-- * Utilities
, currentProfile
, profileIds
, previousProfile
, profileHistory
, allProfileWindows
, profileWorkspaces
)where
--------------------------------------------------------------------------------
import Data.Map.Strict (Map)
import Data.List
import qualified Data.Map.Strict as Map
import Control.DeepSeq
import XMonad
import XMonad.Prelude
import qualified XMonad.StackSet as W
import XMonad.Actions.CycleWS
import qualified XMonad.Util.ExtensibleState as XS
import XMonad.Util.Loggers (Logger)
import XMonad.Prompt.Window (XWindowMap)
import XMonad.Actions.WindowBringer (WindowBringerConfig(..))
import XMonad.Actions.OnScreen (greedyViewOnScreen)
import XMonad.Hooks.Rescreen (addAfterRescreenHook)
import XMonad.Hooks.DynamicLog (PP(ppRename))
import XMonad.Prompt
--------------------------------------------------------------------------------
-- $overview
-- This module allows you to group your workspaces into 'Profile's based on certain similarities.
-- The idea is to expand upon the philosophy set by "XMonad.Actions.TopicSpace"
-- which states that you can look at a topic/workspace as a
-- single unit of work instead of multiple related units of work.
-- This comes in handy if you have lots of workspaces with windows open and need only to
-- work with a few of them at a time. With 'Profile's, you can focus on those few workspaces that
-- require your attention by not displaying, or allowing you to switch to the rest of the workspaces.
-- The best example is having a profile for development and a profile for leisure activities.
--------------------------------------------------------------------------------
-- $usage
-- To use @Profiles@ you need to add it to your XMonad configuration
-- and configure your profiles.
--
-- First you'll need to handle the imports.
--
-- > import XMonad.Actions.Profiles
-- > import XMonad.Util.EZConfig -- for keybindings
-- > import qualified XMonad.StackSet as W
-- > import qualified XMonad.Actions.DynamicWorkspaceOrder as DO -- for workspace navigation
--
-- Next you'll need to define your profiles.
--
-- > myStartingProfile :: ProfileId
-- > myStartingProfile = "Work"
-- >
-- > myProfiles :: [Profile]
-- > myProfiles =
-- > [ Profile { profileId = "Home"
-- > , profileWS = [ "www"
-- > , "rss"
-- > , "vid"
-- > , "vms"
-- > , "writing"
-- > , "notes"
-- > ]
-- > }
-- > , Profile { profileId = "Work"
-- > , profileWS = [ "www"
-- > , "slack"
-- > , "dev"
-- > , "k8s"
-- > , "notes"
-- > ]
-- > }
-- > ]
--
-- So, while using @Home@ 'Profile', you'll only be able to see, navigate to and
-- do actions with @["www", "rss", "vid", "vms", "writing", "notes"]@ workspaces.
--
-- You may also need to define some keybindings. Since @M-1@ .. @M-9@ are
-- sensible keybindings for switching workspaces, you'll need to use
-- 'bindOn' to have different keybindings per profile.
-- Here, we'll use "XMonad.Util.EZConfig" syntax:
--
-- > myKeys :: [(String, X())]
-- > myKeys =
-- > [ ("M-p", switchProfilePrompt xpConfig)
-- > , ("M-g", switchProfileWSPrompt xpConfig)
-- > , ("M1-j", DO.moveTo Next wsFilter)
-- > , ("M1-k", DO.moveTo Prev wsFilter)
-- > ]
-- > <>
-- > [ ("M-" ++ m ++ k, bindOn $ map (\x -> (fst x, f $ snd x)) i)
-- > | (i, k) <- map (\(x:xs) -> (map fst (x:xs), snd x)) $ sortGroupBy snd tupleList
-- > , (f, m) <- [(mby $ windows . W.greedyView, ""), (mby $ windows . W.shift, "S-")]
-- > ]
-- > where
-- > mby f wid = if wid == "" then return () else f wid
-- > sortGroupBy f = groupBy (\ x y -> f x == f y) . sortBy (\x y -> compare (f x) (f y))
-- > tupleList = concatMap (\p -> zip (map (\wid -> (profileId p, wid)) (profileWS p <> repeat "")) (map show [1..9 :: Int])) myProfiles
--
-- After that, you'll need to hook @Profiles@ into your XMonad config:
--
-- > main = xmonad $ addProfiles def { profiles = myProfiles
-- > , startingProfile = myStartingProfile
-- > }
-- > $ def `additionalKeysP` myKeys
--
--------------------------------------------------------------------------------
type ProfileId = String
type ProfileMap = Map ProfileId Profile
--------------------------------------------------------------------------------
-- | Profile representation.
data Profile = Profile
{ profileId :: !ProfileId -- ^ Profile name.
, profileWS :: ![WorkspaceId] -- ^ A list of workspaces contained within a profile.
}
--------------------------------------------------------------------------------
-- | Internal profile state.
data ProfileState = ProfileState
{ profilesMap :: !ProfileMap
, current :: !(Maybe Profile)
, previous :: !(Maybe ProfileId)
}
--------------------------------------------------------------------------------
-- | User config for profiles.
data ProfileConfig = ProfileConfig
{ workspaceExcludes :: ![WorkspaceId] -- ^ A list of workspaces to exclude from the @profileHistoryHook@.
, profiles :: ![Profile] -- ^ A list of user-defined profiles.
, startingProfile :: !ProfileId -- ^ Profile shown on startup.
}
--------------------------------------------------------------------------------
instance Default ProfileConfig where
def = ProfileConfig { workspaceExcludes = []
, profiles = []
, startingProfile = ""
}
--------------------------------------------------------------------------------
instance ExtensionClass ProfileState where
initialValue = ProfileState Map.empty Nothing Nothing
--------------------------------------------------------------------------------
-- Internal type for history tracking.
-- Main problem with @XMonad.Hooks.HistoryHook@ is that it isn't profile aware.
-- Because of that, when switching to a previous workspace, you might switch to
-- a workspace
newtype ProfileHistory = ProfileHistory
{ history :: Map ProfileId [(ScreenId, WorkspaceId)]
}
deriving (Read, Show)
deriving NFData via Map ProfileId [(Int, WorkspaceId)]
--------------------------------------------------------------------------------
instance ExtensionClass ProfileHistory where
extensionType = PersistentExtension
initialValue = ProfileHistory Map.empty
--------------------------------------------------------------------------------
newtype ProfilePrompt = ProfilePrompt String
--------------------------------------------------------------------------------
instance XPrompt ProfilePrompt where
showXPrompt (ProfilePrompt x) = x
--------------------------------------------------------------------------------
defaultProfile :: Profile
defaultProfile = defaultProfile
--------------------------------------------------------------------------------
-- | Returns current profile.
currentProfile :: X ProfileId
currentProfile = profileId . fromMaybe defaultProfile . current <$> XS.get
--------------------------------------------------------------------------------
-- | Returns previous profile.
previousProfile :: X (Maybe ProfileId)
previousProfile = XS.gets previous
--------------------------------------------------------------------------------
-- | Returns the history of viewed workspaces per profile.
profileHistory :: X (Map ProfileId [(ScreenId, WorkspaceId)])
profileHistory = XS.gets history
--------------------------------------------------------------------------------
profileMap :: X ProfileMap
profileMap = XS.gets profilesMap
--------------------------------------------------------------------------------
-- | Returns ids of all profiles.
profileIds :: X [ProfileId]
profileIds = Map.keys <$> XS.gets profilesMap
--------------------------------------------------------------------------------
currentProfileWorkspaces :: X [WorkspaceId]
currentProfileWorkspaces = XS.gets current <&> profileWS . fromMaybe defaultProfile
--------------------------------------------------------------------------------
-- | Hook profiles into XMonad. This function adds a startup hook that
-- sets up ProfileState. Also adds an afterRescreenHook for viewing correct
-- workspaces when adding new screens.
addProfiles :: ProfileConfig -> XConfig a -> XConfig a
addProfiles profConf conf = addAfterRescreenHook hook $ conf
{ startupHook = profileStartupHook' <> startupHook conf
}
where
profileStartupHook' :: X()
profileStartupHook' = profilesStartupHook (profiles profConf) (startingProfile profConf)
hook = currentProfile >>= switchWSOnScreens
--------------------------------------------------------------------------------
-- | Hooks profiles into XMonad and enables Profile history logging.
addProfilesWithHistory :: ProfileConfig -> XConfig a -> XConfig a
addProfilesWithHistory profConf conf = conf'
{ logHook = profileHistoryHookExclude (workspaceExcludes profConf) <> logHook conf
}
where
conf' = addProfiles profConf conf
--------------------------------------------------------------------------------
profileHistoryHookExclude :: [WorkspaceId] -> X()
profileHistoryHookExclude ews = do
cur <- gets $ W.current . windowset
vis <- gets $ W.visible . windowset
pws <- currentProfileWorkspaces
p <- currentProfile
updateHist p $ workspaceScreenPairs $ filterWS pws $ cur:vis
where
workspaceScreenPairs wins = zip (W.screen <$> wins) (W.tag . W.workspace <$> wins)
filterWS pws = filter ((\wid -> (wid `elem` pws) && (wid `notElem` ews)) . W.tag . W.workspace)
--------------------------------------------------------------------------------
updateHist :: ProfileId -> [(ScreenId, WorkspaceId)] -> X()
updateHist pid xs = profileWorkspaces pid >>= XS.modify' . update
where
update pws hs = force $ hs { history = doUpdate pws $ history hs }
doUpdate pws hist = foldl (\acc (sid, wid) -> Map.alter (f pws sid wid) pid acc) hist xs
f pws sid wid val = case val of
Nothing -> pure [(sid, wid)]
Just hs -> pure $ let new = (sid, wid) in new:filterWS pws new hs
filterWS :: [WorkspaceId] -> (ScreenId, WorkspaceId) -> [(ScreenId, WorkspaceId)] -> [(ScreenId, WorkspaceId)]
filterWS pws new = filter (\x -> snd x `elem` pws && x /= new)
--------------------------------------------------------------------------------
-- | Adds profiles to ProfileState and sets current profile using .
profilesStartupHook :: [Profile] -> ProfileId -> X ()
profilesStartupHook ps pid = XS.modify go >> switchWSOnScreens pid
where
go :: ProfileState -> ProfileState
go s = s {profilesMap = update $ profilesMap s, current = setCurrentProfile $ Map.fromList $ map entry ps}
update :: ProfileMap -> ProfileMap
update = Map.union (Map.fromList $ map entry ps)
entry :: Profile -> (ProfileId, Profile)
entry p = (profileId p, p)
setCurrentProfile :: ProfileMap -> Maybe Profile
setCurrentProfile s = case Map.lookup pid s of
Nothing -> Just $ Profile pid []
Just pn -> Just pn
--------------------------------------------------------------------------------
setPrevious :: ProfileId -> X()
setPrevious name = XS.modify update
where
update ps = ps { previous = doUpdate ps }
doUpdate ps = case Map.lookup name $ profilesMap ps of
Nothing -> previous ps
Just p -> Just $ profileId p
--------------------------------------------------------------------------------
setProfile :: ProfileId -> X ()
setProfile p = currentProfile >>= setPrevious >> setProfile' p
--------------------------------------------------------------------------------
setProfile' :: ProfileId -> X ()
setProfile' name = XS.modify update
where
update ps = ps { current = doUpdate ps }
doUpdate ps = case Map.lookup name $ profilesMap ps of
Nothing -> current ps
Just p -> Just p
--------------------------------------------------------------------------------
-- | Switch to a profile.
switchToProfile :: ProfileId -> X()
switchToProfile pid = setProfile pid >> switchWSOnScreens pid
--------------------------------------------------------------------------------
-- | Returns the workspace ids associated with a profile id.
profileWorkspaces :: ProfileId -> X [WorkspaceId]
profileWorkspaces pid = profileMap >>= findPWs
where
findPWs pm = return . profileWS . fromMaybe defaultProfile $ Map.lookup pid pm
--------------------------------------------------------------------------------
-- | Prompt for adding a workspace id to a profile.
addWSToProfilePrompt :: XPConfig -> X()
addWSToProfilePrompt c = do
ps <- profileIds
mkXPrompt (ProfilePrompt "Add ws to profile:") c (mkComplFunFromList' c ps) f
where
f :: String -> X()
f p = do
vis <- gets $ fmap (W.tag . W.workspace) . W.visible . windowset
cur <- gets $ W.tag . W.workspace . W.current . windowset
hid <- gets $ fmap W.tag . W.hidden . windowset
let
arr = cur:(vis <> hid)
in mkXPrompt (ProfilePrompt "Ws to add to profile:") c (mkComplFunFromList' c arr) (`addWSToProfile` p)
--------------------------------------------------------------------------------
-- | Prompt for switching profiles.
switchProfilePrompt :: XPConfig -> X()
switchProfilePrompt c = do
ps <- profileIds
mkXPrompt (ProfilePrompt "Profile: ") c (mkComplFunFromList' c ps) switchToProfile
--------------------------------------------------------------------------------
-- | Prompt for switching workspaces.
switchProfileWSPrompt :: XPConfig -> X ()
switchProfileWSPrompt c = mkPrompt =<< currentProfileWorkspaces
where
mkPrompt pws = mkXPrompt (ProfilePrompt "Switch to workspace:") c (mkComplFunFromList' c pws) mbygoto
mbygoto wid = do
pw <- profileWorkspaces =<< currentProfile
unless (wid `notElem` pw) (windows . W.greedyView $ wid)
--------------------------------------------------------------------------------
-- | Prompt for shifting windows to a different workspace.
shiftProfileWSPrompt :: XPConfig -> X ()
shiftProfileWSPrompt c = mkPrompt =<< currentProfileWorkspaces
where
mkPrompt pws = mkXPrompt (ProfilePrompt "Send window to workspace:") c (mkComplFunFromList' c pws) mbyshift
mbyshift wid = do
pw <- profileWorkspaces =<< currentProfile
unless (wid `notElem` pw) (windows . W.shift $ wid)
--------------------------------------------------------------------------------
addWSToProfile :: WorkspaceId -> ProfileId -> X()
addWSToProfile wid pid = XS.modify go
where
go :: ProfileState -> ProfileState
go ps = ps {profilesMap = update $ profilesMap ps, current = update' $ fromMaybe defaultProfile $ current ps}
update :: ProfileMap -> ProfileMap
update mp = case Map.lookup pid mp of
Nothing -> mp
Just p -> if wid `elem` profileWS p then mp else Map.adjust f pid mp
f :: Profile -> Profile
f p = Profile pid (wid : profileWS p)
update' :: Profile -> Maybe Profile
update' cp = if profileId cp == pid && wid `notElem` profileWS cp then Just (Profile pid $ wid:profileWS cp) else Just cp
--------------------------------------------------------------------------------
-- | Prompt for removing a workspace from a profile.
removeWSFromProfilePrompt :: XPConfig -> X()
removeWSFromProfilePrompt c = do
ps <- profileIds
mkXPrompt (ProfilePrompt "Remove ws from profile:") c (mkComplFunFromList' c ps) f
where
f :: String -> X()
f p = do
arr <- profileWorkspaces p
mkXPrompt (ProfilePrompt "Ws to remove from profile:") c (mkComplFunFromList' c arr) $
\ws -> do
cp <- currentProfile
ws `removeWSFromProfile` p
when (cp == p) $ currentProfile >>= switchWSOnScreens
--------------------------------------------------------------------------------
removeWSFromProfile :: WorkspaceId -> ProfileId -> X()
removeWSFromProfile wid pid = XS.modify go
where
go :: ProfileState -> ProfileState
go ps = ps {profilesMap = update $ profilesMap ps, current = update' $ fromMaybe defaultProfile $ current ps}
update :: ProfileMap -> ProfileMap
update mp = case Map.lookup pid mp of
Nothing -> mp
Just p -> if wid `elem` profileWS p then Map.adjust f pid mp else mp
f :: Profile -> Profile
f p = Profile pid (delete wid $ profileWS p)
update' :: Profile -> Maybe Profile
update' cp = if profileId cp == pid && wid `elem` profileWS cp then Just (Profile pid $ delete wid $ profileWS cp) else Just cp
--------------------------------------------------------------------------------
-- | Pretty printer for a bar. Prints workspace ids of current profile.
excludeWSPP :: PP -> X PP
excludeWSPP pp = modifyPP <$> currentProfileWorkspaces
where
modifyPP pws = pp { ppRename = ppRename pp . printTag pws }
printTag pws tag = if tag `elem` pws then tag else ""
--------------------------------------------------------------------------------
-- | For cycling through workspaces associated with the current.
wsFilter :: WSType
wsFilter = WSIs $ currentProfileWorkspaces >>= (\ws -> return $ (`elem` ws) . W.tag)
--------------------------------------------------------------------------------
-- Takes care of placing correct workspaces on their respective screens.
-- It does this by reducing the history of a Profile until it gets an array of length
-- equal to the number of screens with pairs that have unique workspace ids.
switchWSOnScreens :: ProfileId -> X()
switchWSOnScreens pid = do
hist <- profileHistory
vis <- gets $ W.visible . windowset
cur <- gets $ W.current . windowset
pws <- profileMap <&> (profileWS . fromMaybe (Profile pid []) . Map.lookup pid)
case Map.lookup pid hist of
Nothing -> switchScreens $ zip (W.screen <$> (cur:vis)) pws
Just xs -> compareAndSwitch (f (W.screen <$> cur:vis) xs) (cur:vis) pws
where
f :: [ScreenId] -> [(ScreenId, WorkspaceId)] -> [(ScreenId, WorkspaceId)]
f sids = reorderUniq . reorderUniq . reverse . filter ((`elem` sids) . fst)
reorderUniq :: (Ord k, Ord v) => [(k,v)] -> [(v,k)]
reorderUniq = map (\(x,y) -> (y,x)) . uniq
uniq :: (Ord k, Ord v) => [(k,v)] -> [(k,v)]
uniq = Map.toList . Map.fromList
viewWS fview sid wid = windows $ fview sid wid
switchScreens = mapM_ (uncurry $ viewWS greedyViewOnScreen)
compareAndSwitch hist wins pws | length hist < length wins = switchScreens $ hist <> populateScreens hist wins pws
| otherwise = switchScreens hist
populateScreens hist wins pws = zip (filter (`notElem` map fst hist) $ W.screen <$> wins) (filter (`notElem` map snd hist) pws)
--------------------------------------------------------------------------------
chooseAction :: (String -> X ()) -> X ()
chooseAction f = XS.gets current <&> (profileId . fromMaybe defaultProfile) >>= f
--------------------------------------------------------------------------------
-- | Create keybindings per profile.
bindOn :: [(String, X ())] -> X ()
bindOn bindings = chooseAction chooser
where
chooser profile = case lookup profile bindings of
Just action -> action
Nothing -> case lookup "" bindings of
Just action -> action
Nothing -> return ()
--------------------------------------------------------------------------------
-- | Loggs currentProfile and all profiles with hidden workspaces
-- (workspaces that aren't shown on a screen but have windows).
profileLogger :: (String -> String) -> (String -> String) -> Logger
profileLogger formatFocused formatUnfocused = do
hws <- gets $ W.hidden . windowset
p <- currentProfile
hm <- map fst
. filter (\(p', xs) -> any ((`elem` htags hws) . snd) xs || p' == p)
. Map.toList <$> profileHistory
return $ Just $ foldl (\a b -> a ++ " " ++ b) "" $ format p <$> hm
where
format p a = if a == p then formatFocused a else formatUnfocused a
htags wins = W.tag <$> filter (isJust . W.stack) wins
--------------------------------------------------------------------------------
-- | @XWindowMap@ of all windows contained in a profile.
allProfileWindows :: XWindowMap
allProfileWindows = allProfileWindows' def
--------------------------------------------------------------------------------
allProfileWindows' :: WindowBringerConfig -> XWindowMap
allProfileWindows' WindowBringerConfig{ windowTitler = titler, windowFilter = include } = do
pws <- currentProfileWorkspaces
windowSet <- gets windowset
Map.fromList . concat <$> mapM keyValuePairs (filter ((`elem` pws) . W.tag) $ W.workspaces windowSet)
where keyValuePairs ws = let wins = W.integrate' (W.stack ws)
in mapM (keyValuePair ws) =<< filterM include wins
keyValuePair ws w = (, w) <$> titler ws w

View File

@ -28,7 +28,7 @@ import XMonad.StackSet
-- $usage -- $usage
-- --
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.Promote -- > import XMonad.Actions.Promote
-- --
@ -37,7 +37,7 @@ import XMonad.StackSet
-- > , ((modm, xK_Return), promote) -- > , ((modm, xK_Return), promote)
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- | Move the focused window to the master pane. All other windows -- | Move the focused window to the master pane. All other windows
-- retain their order. If focus is in the master, swap it with the -- retain their order. If focus is in the master, swap it with the

View File

@ -0,0 +1,89 @@
-----------------------------------------------------------------------------
-- |
-- Module : XMonad.Actions.Repeatable
-- Description : Actions you'd like to repeat.
-- Copyright : (c) 2022 L. S. Leary
-- License : BSD3-style (see LICENSE)
--
-- Maintainer : @LSLeary (on github)
-- Stability : unstable
-- Portability : unportable
--
-- This module factors out the shared logic of "XMonad.Actions.CycleRecentWS",
-- "XMonad.Actions.CycleWorkspaceByScreen", "XMonad.Actions.CycleWindows" and
-- "XMonad.Actions.MostRecentlyUsed".
--
-- See the source of these modules for usage examples.
--
-----------------------------------------------------------------------------
module XMonad.Actions.Repeatable
( repeatable
, repeatableSt
, repeatableM
) where
-- mtl
import Control.Monad.State (StateT(..))
-- X11
import Graphics.X11.Xlib.Extras
-- xmonad
import XMonad
-- | An action that temporarily usurps and responds to key press/release events,
-- concluding when one of the modifier keys is released.
repeatable
:: [KeySym] -- ^ The list of 'KeySym's under the
-- modifiers used to invoke the action.
-> KeySym -- ^ The keypress that invokes the action.
-> (EventType -> KeySym -> X ()) -- ^ The keypress handler.
-> X ()
repeatable = repeatableM id
-- | A more general variant of 'repeatable' with a stateful handler,
-- accumulating a monoidal return value throughout the events.
repeatableSt
:: Monoid a
=> s -- ^ Initial state.
-> [KeySym] -- ^ The list of 'KeySym's under the
-- modifiers used to invoke the
-- action.
-> KeySym -- ^ The keypress that invokes the
-- action.
-> (EventType -> KeySym -> StateT s X a) -- ^ The keypress handler.
-> X (a, s)
repeatableSt iSt = repeatableM $ \m -> runStateT m iSt
-- | A more general variant of 'repeatable' with an arbitrary monadic handler,
-- accumulating a monoidal return value throughout the events.
repeatableM
:: (MonadIO m, Monoid a)
=> (m a -> X b) -- ^ How to run the monad in 'X'.
-> [KeySym] -- ^ The list of 'KeySym's under the
-- modifiers used to invoke the action.
-> KeySym -- ^ The keypress that invokes the action.
-> (EventType -> KeySym -> m a) -- ^ The keypress handler.
-> X b
repeatableM run mods key pressHandler = do
XConf{ theRoot = root, display = d } <- ask
run (repeatableRaw d root mods key pressHandler)
repeatableRaw
:: (MonadIO m, Monoid a)
=> Display -> Window
-> [KeySym] -> KeySym -> (EventType -> KeySym -> m a) -> m a
repeatableRaw d root mods key pressHandler = do
io (grabKeyboard d root False grabModeAsync grabModeAsync currentTime)
handleEvent (keyPress, key) <* io (ungrabKeyboard d currentTime)
where
getNextEvent = io $ allocaXEvent $ \p -> do
maskEvent d (keyPressMask .|. keyReleaseMask) p
KeyEvent{ ev_event_type = t, ev_keycode = c } <- getEvent p
s <- keycodeToKeysym d c 0
return (t, s)
handleEvent (t, s)
| t == keyRelease && s `elem` mods = pure mempty
| otherwise = (<>) <$> pressHandler t s <*> (getNextEvent >>= handleEvent)

View File

@ -17,7 +17,11 @@
module XMonad.Actions.RotSlaves ( module XMonad.Actions.RotSlaves (
-- $usage -- $usage
rotSlaves', rotSlavesUp, rotSlavesDown, rotSlaves', rotSlavesUp, rotSlavesDown,
rotAll', rotAllUp, rotAllDown rotAll', rotAllUp, rotAllDown,
-- * Generic list rotations
-- $generic
rotUp, rotDown
) where ) where
import XMonad import XMonad
@ -39,13 +43,13 @@ import XMonad.Prelude
-- TwoPane layout (see "XMonad.Layout.TwoPane"). -- TwoPane layout (see "XMonad.Layout.TwoPane").
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- | Rotate the windows in the current stack, excluding the first one -- | Rotate the windows in the current stack, excluding the first one
-- (master). -- (master).
rotSlavesUp,rotSlavesDown :: X () rotSlavesUp,rotSlavesDown :: X ()
rotSlavesUp = windows $ modify' (rotSlaves' (\l -> tail l++[head l])) rotSlavesUp = windows $ modify' (rotSlaves' rotUp)
rotSlavesDown = windows $ modify' (rotSlaves' (\l -> last l : init l)) rotSlavesDown = windows $ modify' (rotSlaves' rotDown)
-- | The actual rotation, as a pure function on the window stack. -- | The actual rotation, as a pure function on the window stack.
rotSlaves' :: ([a] -> [a]) -> Stack a -> Stack a rotSlaves' :: ([a] -> [a]) -> Stack a -> Stack a
@ -57,10 +61,19 @@ rotSlaves' f s@(Stack _ ls _ ) = Stack t' (reverse revls') rs' -- otherwise
-- | Rotate all the windows in the current stack. -- | Rotate all the windows in the current stack.
rotAllUp,rotAllDown :: X () rotAllUp,rotAllDown :: X ()
rotAllUp = windows $ modify' (rotAll' (\l -> tail l++[head l])) rotAllUp = windows $ modify' (rotAll' rotUp)
rotAllDown = windows $ modify' (rotAll' (\l -> last l : init l)) rotAllDown = windows $ modify' (rotAll' rotDown)
-- | The actual rotation, as a pure function on the window stack. -- | The actual rotation, as a pure function on the window stack.
rotAll' :: ([a] -> [a]) -> Stack a -> Stack a rotAll' :: ([a] -> [a]) -> Stack a -> Stack a
rotAll' f s = Stack r (reverse revls) rs rotAll' f s = Stack r (reverse revls) rs
where (revls, notEmpty -> r :| rs) = splitAt (length (up s)) (f (integrate s)) where (revls, notEmpty -> r :| rs) = splitAt (length (up s)) (f (integrate s))
-- $generic
-- Generic list rotations such that @rotUp [1..4]@ is equivalent to
-- @[2,3,4,1]@ and @rotDown [1..4]@ to @[4,1,2,3]@. They both are
-- @id@ for null or singleton lists.
rotUp :: [a] -> [a]
rotUp l = drop 1 l ++ take 1 l
rotDown :: [a] -> [a]
rotDown = reverse . rotUp . reverse

View File

@ -35,7 +35,7 @@ import XMonad.StackSet (Screen (Screen), Stack (Stack), current, floating, modif
import XMonad.Util.Stack (reverseS) import XMonad.Util.Stack (reverseS)
{- $usage {- $usage
You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: You can use this module with the following in your @xmonad.hs@:
> import XMonad.Actions.RotateSome > import XMonad.Actions.RotateSome

View File

@ -31,33 +31,50 @@ module XMonad.Actions.Search ( -- * Usage
prefixAware, prefixAware,
namedEngine, namedEngine,
amazon,
alpha, alpha,
amazon,
arXiv,
aur,
clojureDocs,
codesearch, codesearch,
cratesIo,
deb, deb,
debbts, debbts,
debpts, debpts,
dictionary, dictionary,
duckduckgo,
ebay, ebay,
flora,
github, github,
google, google,
hackage, hackage,
homeManager,
hoogle, hoogle,
images, images,
imdb, imdb,
lucky, lucky,
maps, maps,
mathworld, mathworld,
ncatlab,
nixos,
noogle,
openstreetmap, openstreetmap,
protondb,
rosettacode,
rustStd,
scholar, scholar,
sourcehut,
stackage, stackage,
steam,
thesaurus, thesaurus,
vocabulary,
voidpgks_x86_64,
voidpgks_x86_64_musl,
wayback, wayback,
wikipedia, wikipedia,
wiktionary, wiktionary,
youtube, youtube,
vocabulary, zbmath,
duckduckgo,
multi, multi,
-- * Use case: searching with a submap -- * Use case: searching with a submap
-- $tip -- $tip
@ -102,12 +119,20 @@ import XMonad.Util.XSelection (getSelection)
The currently available search engines are: The currently available search engines are:
* 'amazon' -- Amazon keyword search.
* 'alpha' -- Wolfram|Alpha query. * 'alpha' -- Wolfram|Alpha query.
* 'amazon' -- Amazon keyword search.
* 'arXiv' -- Open-access preprint archive.
* 'aur' -- Arch User Repository.
* 'clojureDocs' -- Documentation and examples repository for Clojure.
* 'codesearch' -- Google Labs Code Search search. * 'codesearch' -- Google Labs Code Search search.
* 'cratesIo' -- Rust crate registry.
* 'deb' -- Debian package search. * 'deb' -- Debian package search.
* 'debbts' -- Debian Bug Tracking System. * 'debbts' -- Debian Bug Tracking System.
@ -116,17 +141,21 @@ import XMonad.Util.XSelection (getSelection)
* 'dictionary' -- dictionary.reference.com search. * 'dictionary' -- dictionary.reference.com search.
* 'duckduckgo' -- DuckDuckGo search engine.
* 'ebay' -- Ebay keyword search. * 'ebay' -- Ebay keyword search.
* 'flora' -- Prettier Haskell package database.
* 'github' -- GitHub keyword search. * 'github' -- GitHub keyword search.
* 'google' -- basic Google search. * 'google' -- basic Google search.
* 'hackage' -- Hackage, the Haskell package database. * 'hackage' -- Hackage, the Haskell package database.
* 'hoogle' -- Hoogle, the Haskell libraries API search engine. * 'homeManager' -- Search Nix's home-manager's options.
* 'stackage' -- Stackage, An alternative Haskell libraries API search engine. * 'hoogle' -- Hoogle, the Haskell libraries API search engine.
* 'images' -- Google images. * 'images' -- Google images.
@ -138,21 +167,45 @@ import XMonad.Util.XSelection (getSelection)
* 'mathworld' -- Wolfram MathWorld search. * 'mathworld' -- Wolfram MathWorld search.
* 'ncatlab' -- Higer Algebra, Homotopy and Category Theory Wiki.
* 'nixos' -- Search NixOS packages and options.
* 'noogle' -- 'hoogle'-like Nix API search engine.
* 'openstreetmap' -- OpenStreetMap free wiki world map. * 'openstreetmap' -- OpenStreetMap free wiki world map.
* 'protondb' -- Steam Proton Game Database.
* 'rosettacode' -- Programming chrestomathy wiki.
* 'rustStd' -- Rust standard library documentation.
* 'scholar' -- Google scholar academic search. * 'scholar' -- Google scholar academic search.
* 'sourcehut' -- Sourcehut projects search.
* 'stackage' -- Stackage, An alternative Haskell libraries API search engine.
* 'steam' -- Steam games search.
* 'thesaurus' -- thesaurus.com search. * 'thesaurus' -- thesaurus.com search.
* 'vocabulary' -- Dictionary search.
* 'voidpgks_x86_64' -- Void Linux packages search for @x86_64@.
* 'voidpgks_x86_64_musl' -- Void Linux packages search for @x86_64-musl@.
* 'wayback' -- the Wayback Machine. * 'wayback' -- the Wayback Machine.
* 'wikipedia' -- basic Wikipedia search. * 'wikipedia' -- basic Wikipedia search.
* 'wiktionary' -- Wiktionary search.
* 'youtube' -- Youtube video search. * 'youtube' -- Youtube video search.
* 'vocabulary' -- Dictionary search * 'zbmath' -- Open alternative to MathSciNet.
* 'duckduckgo' -- DuckDuckGo search engine.
* 'multi' -- Search based on the prefix. \"amazon:Potter\" will use amazon, etc. With no prefix searches google. * 'multi' -- Search based on the prefix. \"amazon:Potter\" will use amazon, etc. With no prefix searches google.
@ -269,7 +322,7 @@ searchEngine name site = searchEngineF name (\s -> site ++ escape s)
inside of a URL instead of in the end) you can use the alternative 'searchEngineF' function. inside of a URL instead of in the end) you can use the alternative 'searchEngineF' function.
> searchFunc :: String -> String > searchFunc :: String -> String
> searchFunc s | "wiki:" `isPrefixOf` s = "https://en.wikipedia.org/wiki/" ++ (escape $ tail $ snd $ break (==':') s) > searchFunc s | "wiki:" `isPrefixOf` s = "https://en.wikipedia.org/wiki/" ++ (escape $ drop 1 $ snd $ break (==':') s)
> | "https://" `isPrefixOf` s = s > | "https://" `isPrefixOf` s = s
> | otherwise = (use google) s > | otherwise = (use google) s
> myNewEngine = searchEngineF "mymulti" searchFunc > myNewEngine = searchEngineF "mymulti" searchFunc
@ -286,39 +339,57 @@ searchEngineF :: Name -> Site -> SearchEngine
searchEngineF = SearchEngine searchEngineF = SearchEngine
-- The engines. -- The engines.
amazon, alpha, codesearch, deb, debbts, debpts, dictionary, ebay, github, google, hackage, hoogle, alpha, amazon, arXiv, aur, clojureDocs, codesearch, cratesIo, deb, debbts, debpts, dictionary, duckduckgo, ebay, flora,
images, imdb, lucky, maps, mathworld, openstreetmap, scholar, stackage, thesaurus, vocabulary, wayback, wikipedia, wiktionary, github, google, hackage, homeManager, hoogle, images, imdb, lucky, maps, mathworld, ncatlab, nixos, noogle, openstreetmap, protondb,
youtube, duckduckgo :: SearchEngine rosettacode, rustStd, scholar, sourcehut, stackage, steam, thesaurus, vocabulary, voidpgks_x86_64, voidpgks_x86_64_musl, wayback,
amazon = searchEngine "amazon" "https://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias%3Daps&field-keywords=" wikipedia, wiktionary, youtube, zbmath :: SearchEngine
alpha = searchEngine "alpha" "https://www.wolframalpha.com/input/?i=" alpha = searchEngine "alpha" "https://www.wolframalpha.com/input/?i="
amazon = searchEngine "amazon" "https://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias%3Daps&field-keywords="
arXiv = searchEngineF "arXiv" (\s -> "https://arxiv.org/search/?query=" <> s <> "&searchtype=all")
aur = searchEngine "aur" "https://aur.archlinux.org/packages?&K="
clojureDocs = searchEngine "clojureDocs" "https://clojuredocs.org/search?q="
codesearch = searchEngine "codesearch" "https://developers.google.com/s/results/code-search?q=" codesearch = searchEngine "codesearch" "https://developers.google.com/s/results/code-search?q="
cratesIo = searchEngine "cratesIo" "https://crates.io/search?q="
deb = searchEngine "deb" "https://packages.debian.org/" deb = searchEngine "deb" "https://packages.debian.org/"
debbts = searchEngine "debbts" "https://bugs.debian.org/" debbts = searchEngine "debbts" "https://bugs.debian.org/"
debpts = searchEngine "debpts" "https://packages.qa.debian.org/" debpts = searchEngine "debpts" "https://packages.qa.debian.org/"
dictionary = searchEngine "dict" "https://dictionary.reference.com/browse/" dictionary = searchEngine "dict" "https://dictionary.reference.com/browse/"
duckduckgo = searchEngine "duckduckgo" "https://duckduckgo.com/?t=lm&q="
ebay = searchEngine "ebay" "https://www.ebay.com/sch/i.html?_nkw=" ebay = searchEngine "ebay" "https://www.ebay.com/sch/i.html?_nkw="
flora = searchEngine "flora" "https://flora.pm/search?q="
github = searchEngine "github" "https://github.com/search?q=" github = searchEngine "github" "https://github.com/search?q="
google = searchEngine "google" "https://www.google.com/search?q=" google = searchEngine "google" "https://www.google.com/search?q="
hackage = searchEngine "hackage" "https://hackage.haskell.org/package/" hackage = searchEngine "hackage" "https://hackage.haskell.org/package/"
homeManager = searchEngine "homeManager" "https://mipmip.github.io/home-manager-option-search/?query="
hoogle = searchEngine "hoogle" "https://hoogle.haskell.org/?hoogle=" hoogle = searchEngine "hoogle" "https://hoogle.haskell.org/?hoogle="
images = searchEngine "images" "https://images.google.fr/images?q=" images = searchEngine "images" "https://images.google.fr/images?q="
imdb = searchEngine "imdb" "https://www.imdb.com/find?s=all&q=" imdb = searchEngine "imdb" "https://www.imdb.com/find?s=all&q="
lucky = searchEngine "lucky" "https://www.google.com/search?btnI&q=" lucky = searchEngine "lucky" "https://www.google.com/search?btnI&q="
maps = searchEngine "maps" "https://maps.google.com/maps?q=" maps = searchEngine "maps" "https://maps.google.com/maps?q="
mathworld = searchEngine "mathworld" "https://mathworld.wolfram.com/search/?query=" mathworld = searchEngine "mathworld" "https://mathworld.wolfram.com/search/?query="
ncatlab = searchEngine "ncatlab" "https://ncatlab.org/nlab/search?query="
nixos = searchEngine "nixos" "https://search.nixos.org/packages?channel=unstable&from=0&size=200&sort=relevance&type=packages&query="
noogle = searchEngineF "noogle" (\s -> "https://noogle.dev/?search=" <> s <> "&page=1&to=any&from=any")
openstreetmap = searchEngine "openstreetmap" "https://www.openstreetmap.org/search?query=" openstreetmap = searchEngine "openstreetmap" "https://www.openstreetmap.org/search?query="
protondb = searchEngine "protondb" "https://www.protondb.com/search?q="
rosettacode = searchEngine "rosettacode" "https://rosettacode.org/w/index.php?search="
rustStd = searchEngine "rustStd" "https://doc.rust-lang.org/std/index.html?search="
scholar = searchEngine "scholar" "https://scholar.google.com/scholar?q=" scholar = searchEngine "scholar" "https://scholar.google.com/scholar?q="
sourcehut = searchEngine "sourcehut" "https://sr.ht/projects?search="
stackage = searchEngine "stackage" "https://www.stackage.org/lts/hoogle?q=" stackage = searchEngine "stackage" "https://www.stackage.org/lts/hoogle?q="
steam = searchEngine "steam" "https://store.steampowered.com/search/?term="
thesaurus = searchEngine "thesaurus" "https://thesaurus.com/browse/" thesaurus = searchEngine "thesaurus" "https://thesaurus.com/browse/"
vocabulary = searchEngine "vocabulary" "https://www.vocabulary.com/search?q="
voidpgks_x86_64 = searchEngine "voidpackages" "https://voidlinux.org/packages/?arch=x86_64&q="
voidpgks_x86_64_musl = searchEngine "voidpackages" "https://voidlinux.org/packages/?arch=x86_64-musl&q="
wayback = searchEngineF "wayback" ("https://web.archive.org/web/*/"++)
wikipedia = searchEngine "wiki" "https://en.wikipedia.org/wiki/Special:Search?go=Go&search=" wikipedia = searchEngine "wiki" "https://en.wikipedia.org/wiki/Special:Search?go=Go&search="
wiktionary = searchEngine "wikt" "https://en.wiktionary.org/wiki/Special:Search?go=Go&search=" wiktionary = searchEngine "wikt" "https://en.wiktionary.org/wiki/Special:Search?go=Go&search="
youtube = searchEngine "youtube" "https://www.youtube.com/results?search_type=search_videos&search_query=" youtube = searchEngine "youtube" "https://www.youtube.com/results?search_type=search_videos&search_query="
wayback = searchEngineF "wayback" ("https://web.archive.org/web/*/"++) zbmath = searchEngine "zbmath" "https://zbmath.org/?q="
vocabulary = searchEngine "vocabulary" "https://www.vocabulary.com/search?q="
duckduckgo = searchEngine "duckduckgo" "https://duckduckgo.com/?t=lm&q="
multi :: SearchEngine multi :: SearchEngine
multi = namedEngine "multi" $ foldr1 (!>) [amazon, alpha, codesearch, deb, debbts, debpts, dictionary, ebay, github, google, hackage, hoogle, images, imdb, lucky, maps, mathworld, openstreetmap, scholar, thesaurus, wayback, wikipedia, wiktionary, duckduckgo, prefixAware google] multi = namedEngine "multi" $ foldr1 (!>) [alpha, amazon, aur, codesearch, deb, debbts, debpts, dictionary, duckduckgo, ebay, flora, github, hackage, hoogle, images, imdb, lucky, maps, mathworld, ncatlab, openstreetmap, protondb, rosettacode, scholar, sourcehut, stackage, steam, thesaurus, vocabulary, voidpgks_x86_64, voidpgks_x86_64_musl, wayback, wikipedia, wiktionary, youtube, prefixAware google]
{- | This function wraps up a search engine and creates a new one, which works {- | This function wraps up a search engine and creates a new one, which works
like the argument, but goes directly to a URL if one is given rather than like the argument, but goes directly to a URL if one is given rather than
@ -366,14 +437,14 @@ namedEngine name (SearchEngine _ site) = searchEngineF name site
browser. -} browser. -}
promptSearchBrowser :: XPConfig -> Browser -> SearchEngine -> X () promptSearchBrowser :: XPConfig -> Browser -> SearchEngine -> X ()
promptSearchBrowser config browser (SearchEngine name site) = do promptSearchBrowser config browser (SearchEngine name site) = do
hc <- historyCompletionP ("Search [" `isPrefixOf`) hc <- historyCompletionP config ("Search [" `isPrefixOf`)
mkXPrompt (Search name) config hc $ search browser site mkXPrompt (Search name) config hc $ search browser site
{- | Like 'promptSearchBrowser', but only suggest previous searches for the {- | Like 'promptSearchBrowser', but only suggest previous searches for the
given 'SearchEngine' in the prompt. -} given 'SearchEngine' in the prompt. -}
promptSearchBrowser' :: XPConfig -> Browser -> SearchEngine -> X () promptSearchBrowser' :: XPConfig -> Browser -> SearchEngine -> X ()
promptSearchBrowser' config browser (SearchEngine name site) = do promptSearchBrowser' config browser (SearchEngine name site) = do
hc <- historyCompletionP (searchName `isPrefixOf`) hc <- historyCompletionP config (searchName `isPrefixOf`)
mkXPrompt (Search name) config hc $ search browser site mkXPrompt (Search name) config hc $ search browser site
where where
searchName = showXPrompt (Search name) searchName = showXPrompt (Search name)

View File

@ -1,4 +1,5 @@
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
{-# LANGUAGE MultiWayIf #-}
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- | -- |
-- Module : XMonad.Actions.ShowText -- Module : XMonad.Actions.ShowText
@ -26,7 +27,7 @@ module XMonad.Actions.ShowText
import Data.Map (Map,empty,insert,lookup) import Data.Map (Map,empty,insert,lookup)
import Prelude hiding (lookup) import Prelude hiding (lookup)
import XMonad import XMonad
import XMonad.Prelude (All, fi, when) import XMonad.Prelude (All, fi, listToMaybe)
import XMonad.StackSet (current,screen) import XMonad.StackSet (current,screen)
import XMonad.Util.Font (Align(AlignCenter) import XMonad.Util.Font (Align(AlignCenter)
, initXMF , initXMF
@ -41,7 +42,7 @@ import XMonad.Util.XUtils (createNewWindow
import qualified XMonad.Util.ExtensibleState as ES import qualified XMonad.Util.ExtensibleState as ES
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.ShowText -- > import XMonad.Actions.ShowText
-- --
@ -87,8 +88,9 @@ handleTimerEvent :: Event -> X All
handleTimerEvent (ClientMessageEvent _ _ _ dis _ mtyp d) = do handleTimerEvent (ClientMessageEvent _ _ _ dis _ mtyp d) = do
(ShowText m) <- ES.get :: X ShowText (ShowText m) <- ES.get :: X ShowText
a <- io $ internAtom dis "XMONAD_TIMER" False a <- io $ internAtom dis "XMONAD_TIMER" False
when (mtyp == a && not (null d)) if | mtyp == a, Just dh <- listToMaybe d ->
(whenJust (lookup (fromIntegral $ head d) m) deleteWindow) whenJust (lookup (fromIntegral dh) m) deleteWindow
| otherwise -> pure ()
mempty mempty
handleTimerEvent _ = mempty handleTimerEvent _ = mempty

View File

@ -28,7 +28,7 @@ import XMonad.StackSet (Stack (Stack), StackSet, modify')
import XMonad.Util.Stack (reverseS) import XMonad.Util.Stack (reverseS)
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.Sift -- > import XMonad.Actions.Sift
-- --

View File

@ -24,7 +24,7 @@ import XMonad.Core
import XMonad.Util.Run import XMonad.Util.Run
-- $usage -- $usage
-- To use, import this module into @~\/.xmonad\/xmonad.hs@: -- To use, import this module into @xmonad.hs@:
-- --
-- > import XMonad.Actions.SimpleDate -- > import XMonad.Actions.SimpleDate
-- --
@ -35,7 +35,7 @@ import XMonad.Util.Run
-- In this example, a popup date menu will now be bound to @mod-d@. -- In this example, a popup date menu will now be bound to @mod-d@.
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
date :: X () date :: X ()
date = unsafeSpawn "(date; sleep 10) | dzen2" date = unsafeSpawn "(date; sleep 10) | dzen2"

View File

@ -13,7 +13,7 @@
-- 'sinkAll' function for backwards compatibility. -- 'sinkAll' function for backwards compatibility.
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
module XMonad.Actions.SinkAll ( module XMonad.Actions.SinkAll {-# DEPRECATED "Use XMonad.Actions.WithAll instead" #-} (
-- * Usage -- * Usage
-- $usage -- $usage
@ -23,7 +23,7 @@ import XMonad.Actions.WithAll (sinkAll)
-- $usage -- $usage
-- --
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.SinkAll -- > import XMonad.Actions.SinkAll
-- --
@ -32,4 +32,4 @@ import XMonad.Actions.WithAll (sinkAll)
-- > , ((modm .|. shiftMask, xK_t), sinkAll) -- > , ((modm .|. shiftMask, xK_t), sinkAll)
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.

View File

@ -43,7 +43,7 @@ import qualified XMonad.Util.ExtensibleState as XS
import XMonad.Util.Process (getPPIDChain) import XMonad.Util.Process (getPPIDChain)
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.SpawnOn -- > import XMonad.Actions.SpawnOn
-- --
@ -63,7 +63,7 @@ import XMonad.Util.Process (getPPIDChain)
-- the spawned application(e.g. float or resize it). -- the spawned application(e.g. float or resize it).
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
newtype Spawner = Spawner {pidsRef :: [(ProcessID, ManageHook)]} newtype Spawner = Spawner {pidsRef :: [(ProcessID, ManageHook)]}

View File

@ -18,6 +18,7 @@ module XMonad.Actions.Submap (
-- $usage -- $usage
submap, submap,
visualSubmap, visualSubmap,
visualSubmapSorted,
submapDefault, submapDefault,
submapDefaultWithKey, submapDefaultWithKey,
@ -32,10 +33,7 @@ import XMonad.Util.XUtils
{- $usage {- $usage
First, import this module into your @xmonad.hs@:
First, import this module into your @~\/.xmonad\/xmonad.hs@:
> import XMonad.Actions.Submap > import XMonad.Actions.Submap
@ -56,7 +54,7 @@ because that is a special value passed to XGrabKey() and not an actual
modifier. modifier.
For detailed instructions on editing your key bindings, see For detailed instructions on editing your key bindings, see
"XMonad.Doc.Extending#Editing_key_bindings". <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-} -}
@ -76,30 +74,47 @@ submap = submapDefault (return ())
-- > -- >
-- > gotoLayout :: [(String, X ())] -- for use with EZConfig -- > gotoLayout :: [(String, X ())] -- for use with EZConfig
-- > gotoLayout = -- assumes you have a layout named "Tall" and one named "Full". -- > gotoLayout = -- assumes you have a layout named "Tall" and one named "Full".
-- > ["M-l", visualSubmap def $ Map.fromList $ map (\(k, s, a) -> ((0, k), (s, a))) -- > [("M-l", visualSubmap def $ Map.fromList $ map (\(k, s, a) -> ((0, k), (s, a)))
-- > [ (xK_t, "Tall", switchToLayout "Tall") -- "M-l t" switches to "Tall" -- > [ (xK_t, "Tall", switchToLayout "Tall") -- "M-l t" switches to "Tall"
-- > , (xK_r, "Full", switchToLayout "Full") -- "M-l r" switches to "full" -- > , (xK_r, "Full", switchToLayout "Full") -- "M-l r" switches to "full"
-- > ]] -- > ])]
-- --
-- One could alternatively also write @gotoLayout@ as -- One could alternatively also write @gotoLayout@ as
-- --
-- > gotoLayout = ["M-l", visualSubmap def $ Map.fromList $ -- > gotoLayout = [("M-l", visualSubmap def $ Map.fromList $
-- > [ ((0, xK_t), subName "Tall" $ switchToLayout "Tall") -- > [ ((0, xK_t), subName "Tall" $ switchToLayout "Tall")
-- > , ((0, xK_r), subName "Full" $ switchToLayout "Full") -- > , ((0, xK_r), subName "Full" $ switchToLayout "Full")
-- > ]] -- > ])]
visualSubmap :: WindowConfig -- ^ The config for the spawned window. visualSubmap :: WindowConfig -- ^ The config for the spawned window.
-> M.Map (KeyMask, KeySym) (String, X ()) -> M.Map (KeyMask, KeySym) (String, X ())
-- ^ A map @keybinding -> (description, action)@. -- ^ A map @keybinding -> (description, action)@.
-> X () -> X ()
visualSubmap wc keys = visualSubmap = visualSubmapSorted id
-- | Like 'visualSubmap', but is able to sort the descriptions.
-- For example,
--
-- > import Data.Ord (comparing, Down)
-- >
-- > visualSubmapSorted (sortBy (comparing Down)) def
--
-- would sort the @(key, description)@ pairs by their keys in descending
-- order.
visualSubmapSorted :: ([((KeyMask, KeySym), String)] -> [((KeyMask, KeySym), String)])
-- ^ A function to resort the descriptions
-> WindowConfig -- ^ The config for the spawned window.
-> M.Map (KeyMask, KeySym) (String, X ())
-- ^ A map @keybinding -> (description, action)@.
-> X ()
visualSubmapSorted sorted wc keys =
withSimpleWindow wc descriptions waitForKeyPress >>= \(m', s) -> withSimpleWindow wc descriptions waitForKeyPress >>= \(m', s) ->
maybe (pure ()) snd (M.lookup (m', s) keys) maybe (pure ()) snd (M.lookup (m', s) keys)
where where
descriptions :: [String] descriptions :: [String]
descriptions = descriptions =
zipWith (\key desc -> keyToString key <> ": " <> desc) map (\(key, desc) -> keyToString key <> ": " <> desc)
(M.keys keys) . sorted
(map fst (M.elems keys)) $ zip (M.keys keys) (map fst (M.elems keys))
-- | Give a name to an action. -- | Give a name to an action.
subName :: String -> X () -> (String, X ()) subName :: String -> X () -> (String, X ())

View File

@ -63,6 +63,7 @@ import qualified XMonad.Util.ExtensibleState as XS
import qualified Data.Map as M import qualified Data.Map as M
import qualified Data.Set as S import qualified Data.Set as S
import Control.Arrow import Control.Arrow
import qualified Data.List.NonEmpty as NE
-- $usage -- $usage
@ -99,7 +100,7 @@ import Control.Arrow
-- So far floating windows have been treated no differently than tiled windows -- So far floating windows have been treated no differently than tiled windows
-- even though their positions are independent of the stack. Often, yanking -- even though their positions are independent of the stack. Often, yanking
-- floating windows in and out of the workspace will obliterate the stack -- floating windows in and out of the workspace will obliterate the stack
-- history - particularly frustrating with 'XMonad.Util.Scratchpad' since it is -- history - particularly frustrating with "XMonad.Util.Scratchpad" since it is
-- toggled so frequenty and always replaces the master window. That's why the -- toggled so frequenty and always replaces the master window. That's why the
-- swap functions accept a boolean argument; when @True@ non-focused floating -- swap functions accept a boolean argument; when @True@ non-focused floating
-- windows will be ignored. -- windows will be ignored.
@ -240,8 +241,8 @@ swapApply ignoreFloats swapFunction = do
(r,s2) = stackSplit s1 fl' :: ([(Int,Window)],W.Stack Window) (r,s2) = stackSplit s1 fl' :: ([(Int,Window)],W.Stack Window)
(b,s3) = swapFunction pm s2 (b,s3) = swapFunction pm s2
s4 = stackMerge s3 r s4 = stackMerge s3 r
mh = let w = head . W.integrate $ s3 mh = let w = NE.head . notEmpty . W.integrate $ s3
in const $ w : delete w ch in const $ w : delete w ch
in (b,Just s4,mh) in (b,Just s4,mh)
(x,y,z) = maybe (False,Nothing,id) swapApply' st (x,y,z) = maybe (False,Nothing,id) swapApply' st
-- Any floating master windows will be added to the history when 'windows' -- Any floating master windows will be added to the history when 'windows'

View File

@ -30,7 +30,7 @@ import XMonad.Util.WorkspaceCompare
-- $usage -- $usage
-- Add this import to your @~\/.xmonad\/xmonad.hs@: -- Add this import to your @xmonad.hs@:
-- --
-- > import XMonad.Actions.SwapWorkspaces -- > import XMonad.Actions.SwapWorkspaces
-- --
@ -44,7 +44,7 @@ import XMonad.Util.WorkspaceCompare
-- will swap workspaces 1 and 5. -- will swap workspaces 1 and 5.
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- | Swaps the currently focused workspace with the given workspace tag, via -- | Swaps the currently focused workspace with the given workspace tag, via
-- @swapWorkspaces@. -- @swapWorkspaces@.

View File

@ -39,7 +39,7 @@ econst = const . return
-- $usage -- $usage
-- --
-- To use window tags, import this module into your @~\/.xmonad\/xmonad.hs@: -- To use window tags, import this module into your @xmonad.hs@:
-- --
-- > import XMonad.Actions.TagWindows -- > import XMonad.Actions.TagWindows
-- > import XMonad.Prompt -- to use tagPrompt -- > import XMonad.Prompt -- to use tagPrompt
@ -64,7 +64,7 @@ econst = const . return
-- the tags \"a\" and \"b\" but not \"a b\". -- the tags \"a\" and \"b\" but not \"a b\".
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- | set multiple tags for a window at once (overriding any previous tags) -- | set multiple tags for a window at once (overriding any previous tags)
setTags :: [String] -> Window -> X () setTags :: [String] -> Window -> X ()
@ -134,11 +134,6 @@ focusTagged' :: (WindowSet -> [Window]) -> String -> X ()
focusTagged' wl t = gets windowset >>= findM (hasTag t) . wl >>= focusTagged' wl t = gets windowset >>= findM (hasTag t) . wl >>=
maybe (return ()) (windows . focusWindow) maybe (return ()) (windows . focusWindow)
findM :: (Monad m) => (a -> m Bool) -> [a] -> m (Maybe a)
findM _ [] = return Nothing
findM p (x:xs) = do b <- p x
if b then return (Just x) else findM p xs
-- | apply a pure function to windows with a tag -- | apply a pure function to windows with a tag
withTaggedP, withTaggedGlobalP :: String -> (Window -> WindowSet -> WindowSet) -> X () withTaggedP, withTaggedGlobalP :: String -> (Window -> WindowSet -> WindowSet) -> X ()
withTaggedP t f = withTagged' t (winMap f) withTaggedP t f = withTagged' t (winMap f)

View File

@ -27,7 +27,7 @@ import qualified XMonad.StackSet as W
import XMonad.Layout.DraggingVisualizer import XMonad.Layout.DraggingVisualizer
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.TiledWindowDragging -- > import XMonad.Actions.TiledWindowDragging
-- > import XMonad.Layout.DraggingVisualizer -- > import XMonad.Layout.DraggingVisualizer

View File

@ -0,0 +1,122 @@
-- |
-- Module : XMonad.Actions.ToggleFullFloat
-- Description : Fullscreen (float) a window while remembering its original state.
-- Copyright : (c) 2022 Tomáš Janoušek <tomi@nomi.cz>
-- License : BSD3
-- Maintainer : Tomáš Janoušek <tomi@nomi.cz>
--
module XMonad.Actions.ToggleFullFloat (
-- * Usage
-- $usage
toggleFullFloatEwmhFullscreen,
toggleFullFloat,
fullFloat,
unFullFloat,
gcToggleFullFloat,
) where
import qualified Data.Map.Strict as M
import XMonad
import XMonad.Prelude
import XMonad.Hooks.EwmhDesktops (setEwmhFullscreenHooks)
import XMonad.Hooks.ManageHelpers
import qualified XMonad.StackSet as W
import qualified XMonad.Util.ExtensibleState as XS
-- ---------------------------------------------------------------------
-- $usage
--
-- The main use-case is to make 'ewmhFullscreen' (re)store the size and
-- position of floating windows instead of just unconditionally sinking them
-- into the floating layer. To enable this, you'll need this in your
-- @xmonad.hs@:
--
-- > import XMonad
-- > import XMonad.Actions.ToggleFullFloat
-- > import XMonad.Hooks.EwmhDesktops
-- >
-- > main = xmonad $ … . toggleFullFloatEwmhFullscreen . ewmhFullscreen . ewmh . … $ def{…}
--
-- Additionally, this "smart" fullscreening can be bound to a key and invoked
-- manually whenever one needs a larger window temporarily:
--
-- > , ((modMask .|. shiftMask, xK_t), withFocused toggleFullFloat)
newtype ToggleFullFloat = ToggleFullFloat{ fromToggleFullFloat :: M.Map Window (Maybe W.RationalRect) }
deriving (Show, Read)
instance ExtensionClass ToggleFullFloat where
extensionType = PersistentExtension
initialValue = ToggleFullFloat mempty
-- | Full-float a window, remembering its state (tiled/floating and
-- position/size).
fullFloat :: Window -> X ()
fullFloat = windows . appEndo <=< runQuery doFullFloatSave
-- | Restore window to its remembered state.
unFullFloat :: Window -> X ()
unFullFloat = windows . appEndo <=< runQuery doFullFloatRestore
-- | Full-float a window, if it's not already full-floating. Otherwise,
-- restore its original state.
toggleFullFloat :: Window -> X ()
toggleFullFloat w = ifM (isFullFloat w) (unFullFloat w) (fullFloat w)
isFullFloat :: Window -> X Bool
isFullFloat w = gets $ (Just fullRect ==) . M.lookup w . W.floating . windowset
where
fullRect = W.RationalRect 0 0 1 1
doFullFloatSave :: ManageHook
doFullFloatSave = do
w <- ask
liftX $ do
f <- gets $ M.lookup w . W.floating . windowset
-- @M.insertWith const@ = don't overwrite stored original state
XS.modify' $ ToggleFullFloat . M.insertWith const w f . fromToggleFullFloat
doFullFloat
doFullFloatRestore :: ManageHook
doFullFloatRestore = do
w <- ask
mf <- liftX $ do
mf <- XS.gets $ M.lookup w . fromToggleFullFloat
XS.modify' $ ToggleFullFloat . M.delete w . fromToggleFullFloat
pure mf
doF $ case mf of
Just (Just f) -> W.float w f -- was floating before
Just Nothing -> W.sink w -- was tiled before
Nothing -> W.sink w -- fallback when not found in ToggleFullFloat
-- | Install ToggleFullFloat garbage collection hooks.
--
-- Note: This is included in 'toggleFullFloatEwmhFullscreen', only needed if
-- using the 'toggleFullFloat' separately from the EWMH hook.
gcToggleFullFloat :: XConfig a -> XConfig a
gcToggleFullFloat c = c { startupHook = startupHook c <> gcToggleFullFloatStartupHook
, handleEventHook = handleEventHook c <> gcToggleFullFloatEventHook }
-- | ToggleFullFloat garbage collection: drop windows when they're destroyed.
gcToggleFullFloatEventHook :: Event -> X All
gcToggleFullFloatEventHook DestroyWindowEvent{ev_window = w} = do
XS.modify' $ ToggleFullFloat . M.delete w . fromToggleFullFloat
mempty
gcToggleFullFloatEventHook _ = mempty
-- | ToggleFullFloat garbage collection: restrict to existing windows at
-- startup.
gcToggleFullFloatStartupHook :: X ()
gcToggleFullFloatStartupHook = withWindowSet $ \ws ->
XS.modify' $ ToggleFullFloat . M.filterWithKey (\w _ -> w `W.member` ws) . fromToggleFullFloat
-- | Hook this module into 'XMonad.Hooks.EwmhDesktops.ewmhFullscreen'. This
-- makes windows restore their original state (size and position if floating)
-- instead of unconditionally sinking into the tiling layer.
--
-- ('gcToggleFullFloat' is included here.)
toggleFullFloatEwmhFullscreen :: XConfig a -> XConfig a
toggleFullFloatEwmhFullscreen =
setEwmhFullscreenHooks doFullFloatSave doFullFloatRestore .
gcToggleFullFloat

View File

@ -103,9 +103,12 @@ import XMonad.Hooks.WorkspaceHistory
-- display your topics in an historical way using a custom `pprWindowSet' -- display your topics in an historical way using a custom `pprWindowSet'
-- function. You can also easily switch to recent topics using this history -- function. You can also easily switch to recent topics using this history
-- of last focused topics. -- of last focused topics.
--
-- A blog post highlighting some features of this module can be found
-- <https://tony-zorman.com/posts/topic-space/2022-09-11-topic-spaces.html here>.
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import qualified Data.Map.Strict as M -- > import qualified Data.Map.Strict as M
-- > import qualified XMonad.StackSet as W -- > import qualified XMonad.StackSet as W

169
XMonad/Actions/UpKeys.hs Normal file
View File

@ -0,0 +1,169 @@
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE TypeApplications #-}
{- |
Module : XMonad.Actions.UpKeys
Description : Bind an action to the release of a key
Copyright : (c) Tony Zorman, 2024
License : BSD-3
Maintainer : Tony Zorman <soliditsallgood@mailbox.org>
A combinator for binding an action to the release of a key. This can be
useful for hold-type buttons, where the press of a key engages some
functionality, and its release releases it again.
-}
module XMonad.Actions.UpKeys
( -- * Usage
-- $usage
useUpKeys,
UpKeysConfig (..),
ezUpKeys,
)
where
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import XMonad
import XMonad.Prelude
import XMonad.Util.EZConfig (mkKeymap)
import qualified XMonad.Util.ExtensibleConf as XC
{- $usage
You can use this module with the following in your @xmonad.hs@:
> import XMonad.Actions.UpKeys
Next, define the keys and actions you want to have happen on the release
of a key:
> myUpKeys = ezUpKeys $
> [ ("M-z", myAction)
> , ("M-a", myAction2)
> ]
All that's left is to plug this definition into the 'useUpKeys'
combinator that this module provides:
> main :: IO ()
> main = xmonad
> . useUpKeys (def{ grabKeys = True, upKeys = myUpKeys })
> $ myConfig
Note the presence of @'grabKeys' = True@; this is for situations where
you don't have any of these keys bound to do something upon pressing
them; i.e., you use them solely for their release actions. If you want
something to happen in both cases, remove that part (@'grabKeys' =
False@ is the default) and bind the keys to actions as you normally
would.
==== __Examples__
As an extended example, consider the case where you want all of your
docks (e.g., status bar) to "pop up" when you press the super key, and
then vanish again once that keys is released.
Since docks are not generally part of XMonad's window-setotherwise, we
would have to manage themwe first need a way to access and manipulate
all docks.
> onAllDocks :: (Display -> Window -> IO ()) -> X ()
> onAllDocks act = withDisplay \dpy -> do
> rootw <- asks theRoot
> (_, _, wins) <- io $ queryTree dpy rootw
> traverse_ (io . act dpy) =<< filterM (runQuery checkDock) wins
This is also the place where one could filter for just status bar,
trayer, and so on.
Now we have to decide what kinds of keys we want to watch out for. Since
you most likely use left super as your modifier key, this is a little
bit more complicated than for other keys, as you will most likely see
the key both as a @KeyMask@, as well as a @KeySym@. One could think a
bit and probably come up with an elegant solution for thisor one could
grab all possible key combinations by brute-force!
> dockKeys :: X () -> [((KeyMask, KeySym), X ())]
> dockKeys act = map (actKey . foldr1 (.|.)) . combinations $ keyMasks
> where
> actKey :: KeyMask -> ((KeyMask, KeySym), X ())
> actKey mask = ((mask, xK_Super_L), act)
>
> keyMasks :: [KeyMask]
> keyMasks = [ noModMask, shiftMask, lockMask, controlMask, mod1Mask, mod2Mask, mod3Mask, mod4Mask, mod5Mask ]
>
> -- Return all combinations of a sequence of values.
> combinations :: [a] -> [[a]]
> combinations xs = concat [combs i xs | i <- [1 .. length xs]]
> where
> combs 0 _ = [[]]
> combs _ [] = []
> combs n (x:xs) = map (x:) (combs (n-1) xs) <> combs n xs
Given some action, like lowering or raising the window, we generate all
possible combinations of modifiers that may be pressed with the super
key. This is a good time to say that this is just for demonstrative
purposes, btwplease don't actually do this.
All that's left is to plug everything into the machinery of this module,
and we're done!
> import qualified Data.Map.Strict as Map
>
> main :: IO ()
> main = xmonad
> . -- other combinators
> . useUpKeys (def { upKeys = Map.fromList $ dockKeys (onAllDocks lowerWindow) })
> $ myConfig `additionalKeys` dockKeys (onAllDocks raiseWindow)
>
> myConfig =
-}
data UpKeysConfig = UpKeysConfig
{ -- | Whether to grab all keys that are not already grabbed.
grabKeys :: !Bool
-- | The keys themselves.
, upKeys :: !(Map (KeyMask, KeySym) (X ()))
}
-- | The default 'UpKeysConfig'; keys are not grabbed, and no upkeys are
-- specified.
instance Default UpKeysConfig where
def :: UpKeysConfig
def = UpKeysConfig { grabKeys = False, upKeys = mempty }
instance Semigroup UpKeysConfig where
(<>) :: UpKeysConfig -> UpKeysConfig -> UpKeysConfig
UpKeysConfig g u <> UpKeysConfig g' u' = UpKeysConfig (g && g') (u <> u')
-- | Bind actions to keys upon their release.
useUpKeys :: UpKeysConfig -> (XConfig l -> XConfig l)
useUpKeys upKeysConf = flip XC.once upKeysConf \conf -> conf
{ handleEventHook = handleEventHook conf <> (\e -> handleKeyUp e $> All True)
, startupHook = startupHook conf <> when (grabKeys upKeysConf) grabUpKeys
}
where
grabUpKeys :: X ()
grabUpKeys = do
XConf{ display = dpy, theRoot = rootw } <- ask
realKeys <- maybe mempty upKeys <$> XC.ask @X @UpKeysConfig
let grab :: (KeyMask, KeyCode) -> X ()
grab (km, kc) = io $ grabKey dpy kc km rootw True grabModeAsync grabModeAsync
traverse_ grab =<< mkGrabs (Map.keys realKeys)
-- | Parse the given EZConfig-style keys into the internal keymap
-- representation.
--
-- This is just 'mkKeymap' with a better name.
ezUpKeys :: XConfig l -> [(String, X ())] -> Map (KeyMask, KeySym) (X ())
ezUpKeys = mkKeymap
-- | A handler for key-up events.
handleKeyUp :: Event -> X ()
handleKeyUp KeyEvent{ ev_event_type, ev_state, ev_keycode }
| ev_event_type == keyRelease = withDisplay \dpy -> do
s <- io $ keycodeToKeysym dpy ev_keycode 0
cln <- cleanMask ev_state
ks <- maybe mempty upKeys <$> XC.ask @X @UpKeysConfig
userCodeDef () $ whenJust (ks Map.!? (cln, s)) id
handleKeyUp _ = pure ()

View File

@ -27,7 +27,7 @@ import qualified XMonad.StackSet as W
-- $usage -- $usage
-- To make the focus update on mouse movement within an unfocused window, add the -- To make the focus update on mouse movement within an unfocused window, add the
-- following to your @~\/.xmonad\/xmonad.hs@: -- following to your @xmonad.hs@:
-- --
-- > import XMonad.Actions.UpdateFocus -- > import XMonad.Actions.UpdateFocus
-- > xmonad $ def { -- > xmonad $ def {

View File

@ -31,7 +31,7 @@ import XMonad.StackSet (member, peek, screenDetail, current)
import Control.Arrow ((&&&), (***)) import Control.Arrow ((&&&), (***))
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad -- > import XMonad
-- > import XMonad.Actions.UpdatePointer -- > import XMonad.Actions.UpdatePointer

View File

@ -28,7 +28,7 @@ import XMonad
import XMonad.StackSet as W import XMonad.StackSet as W
{- $usage {- $usage
You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: You can use this module with the following in your @xmonad.hs@:
> import XMonad.Actions.Warp > import XMonad.Actions.Warp
@ -45,7 +45,7 @@ Note that warping to a particular screen may change the focus.
-} -}
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
data Corner = UpperLeft | UpperRight | LowerLeft | LowerRight data Corner = UpperLeft | UpperRight | LowerLeft | LowerRight

View File

@ -22,6 +22,7 @@ module XMonad.Actions.WindowBringer (
WindowBringerConfig(..), WindowBringerConfig(..),
gotoMenu, gotoMenuConfig, gotoMenu', gotoMenuArgs, gotoMenuArgs', gotoMenu, gotoMenuConfig, gotoMenu', gotoMenuArgs, gotoMenuArgs',
bringMenu, bringMenuConfig, bringMenu', bringMenuArgs, bringMenuArgs', bringMenu, bringMenuConfig, bringMenu', bringMenuArgs, bringMenuArgs',
copyMenu, copyMenuConfig, copyMenu', copyMenuArgs, copyMenuArgs',
windowMap, windowAppMap, windowMap', bringWindow, actionMenu windowMap, windowAppMap, windowMap', bringWindow, actionMenu
) where ) where
@ -33,10 +34,11 @@ import XMonad
import qualified XMonad as X import qualified XMonad as X
import XMonad.Util.Dmenu (menuMapArgs) import XMonad.Util.Dmenu (menuMapArgs)
import XMonad.Util.NamedWindows (getName, getNameWMClass) import XMonad.Util.NamedWindows (getName, getNameWMClass)
import XMonad.Actions.CopyWindow (copyWindow)
-- $usage -- $usage
-- --
-- Import the module into your @~\/.xmonad\/xmonad.hs@: -- Import the module into your @xmonad.hs@:
-- --
-- > import XMonad.Actions.WindowBringer -- > import XMonad.Actions.WindowBringer
-- --
@ -44,9 +46,10 @@ import XMonad.Util.NamedWindows (getName, getNameWMClass)
-- --
-- > , ((modm .|. shiftMask, xK_g ), gotoMenu) -- > , ((modm .|. shiftMask, xK_g ), gotoMenu)
-- > , ((modm .|. shiftMask, xK_b ), bringMenu) -- > , ((modm .|. shiftMask, xK_b ), bringMenu)
-- > , ((modm .|. shiftMask, xK_y ), copyMenu)
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
data WindowBringerConfig = WindowBringerConfig data WindowBringerConfig = WindowBringerConfig
{ menuCommand :: String -- ^ The shell command that will handle window selection { menuCommand :: String -- ^ The shell command that will handle window selection
@ -90,6 +93,37 @@ gotoMenu' cmd = gotoMenuConfig def { menuArgs = [], menuCommand = cmd }
gotoMenuArgs' :: String -> [String] -> X () gotoMenuArgs' :: String -> [String] -> X ()
gotoMenuArgs' cmd args = gotoMenuConfig def { menuCommand = cmd, menuArgs = args } gotoMenuArgs' cmd args = gotoMenuConfig def { menuCommand = cmd, menuArgs = args }
-- | Pops open a dmenu with window titles. Choose one, and it will be copied into your current workspace.
copyMenu :: X ()
copyMenu = copyMenuArgs def
-- | Pops open a dmenu with window titles. Choose one, and it will be
-- copied into your current workspace. This version
-- accepts a configuration object.
copyMenuConfig :: WindowBringerConfig -> X ()
copyMenuConfig wbConfig = actionMenu wbConfig copyBringWindow
-- | Pops open a dmenu with window titles. Choose one, and it will be
-- copied into your current workspace. This version
-- takes a list of arguments to pass to dmenu.
copyMenuArgs :: [String] -> X ()
copyMenuArgs args = copyMenuConfig def { menuArgs = args }
-- | Pops open an application with window titles given over stdin. Choose one,
-- and it will be copied into your current workspace.
copyMenu' :: String -> X ()
copyMenu' cmd = copyMenuConfig def { menuArgs = [], menuCommand = cmd }
-- | Pops open an application with window titles given over stdin. Choose one,
-- and it will be copied into your current
-- workspace. This version allows arguments to the chooser to be specified.
copyMenuArgs' :: String -> [String] -> X ()
copyMenuArgs' cmd args = copyMenuConfig def { menuArgs = args, menuCommand = cmd }
-- | Brings a copy of the specified window into the current workspace.
copyBringWindow :: Window -> X.WindowSet -> X.WindowSet
copyBringWindow w ws = copyWindow w (W.currentTag ws) ws
-- | Pops open a dmenu with window titles. Choose one, and it will be -- | Pops open a dmenu with window titles. Choose one, and it will be
-- dragged, kicking and screaming, into your current workspace. -- dragged, kicking and screaming, into your current workspace.
bringMenu :: X () bringMenu :: X ()
@ -159,7 +193,7 @@ decorateName ws w = do
return $ name ++ " [" ++ W.tag ws ++ "]" return $ name ++ " [" ++ W.tag ws ++ "]"
-- | Returns the window name as will be listed in dmenu. This will -- | Returns the window name as will be listed in dmenu. This will
-- return the executable name of the window along with it's workspace -- return the executable name of the window along with its workspace
-- ID. -- ID.
decorateAppName :: X.WindowSpace -> Window -> X String decorateAppName :: X.WindowSpace -> Window -> X String
decorateAppName ws w = do decorateAppName ws w = do

View File

@ -48,9 +48,11 @@ import XMonad.Operations (windows)
import XMonad.Prompt.Shell (getBrowser, getEditor) import XMonad.Prompt.Shell (getBrowser, getEditor)
import qualified XMonad.StackSet as W (peek, swapMaster, focusWindow, workspaces, StackSet, Workspace, integrate', tag, stack) import qualified XMonad.StackSet as W (peek, swapMaster, focusWindow, workspaces, StackSet, Workspace, integrate', tag, stack)
import XMonad.Util.Run (safeSpawnProg) import XMonad.Util.Run (safeSpawnProg)
import qualified Data.List.NonEmpty as NE
{- $usage {- $usage
Import the module into your @~\/.xmonad\/xmonad.hs@: Import the module into your @xmonad.hs@:
> import XMonad.Actions.WindowGo > import XMonad.Actions.WindowGo
@ -66,7 +68,8 @@ appropriate one, or cover your bases by using instead something like:
> (className =? "Firefox" <||> className =? "Firefox-bin") > (className =? "Firefox" <||> className =? "Firefox-bin")
For detailed instructions on editing your key bindings, see For detailed instructions on editing your key bindings, see
"XMonad.Doc.Extending#Editing_key_bindings". -} <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-}
-- | Get the list of workspaces sorted by their tag -- | Get the list of workspaces sorted by their tag
workspacesSorted :: Ord i => W.StackSet i l a s sd -> [W.Workspace i l a] workspacesSorted :: Ord i => W.StackSet i l a s sd -> [W.Workspace i l a]
@ -89,7 +92,10 @@ ifWindows qry f el = withWindowSet $ \wins -> do
-- | The same as ifWindows, but applies a ManageHook to the first match -- | The same as ifWindows, but applies a ManageHook to the first match
-- instead and discards the other matches -- instead and discards the other matches
ifWindow :: Query Bool -> ManageHook -> X () -> X () ifWindow :: Query Bool -> ManageHook -> X () -> X ()
ifWindow qry mh = ifWindows qry (windows . appEndo <=< runQuery mh . head) ifWindow qry mh = ifWindows qry (windows . appEndo <=< runQuery mh . NE.head . notEmpty)
-- ifWindows guarantees that the list given to the function is
-- non-empty. This should really use Data.List.NonEmpty, but, alas,
-- that would be a breaking change.
{- | 'action' is an executable to be run via 'safeSpawnProg' (of "XMonad.Util.Run") if the Window cannot be found. {- | 'action' is an executable to be run via 'safeSpawnProg' (of "XMonad.Util.Run") if the Window cannot be found.
Presumably this executable is the same one that you were looking for. Presumably this executable is the same one that you were looking for.
@ -164,7 +170,8 @@ raiseNextMaybeCustomFocus focusFn f qry = flip (ifWindows qry) f $ \ws -> do
let (notEmpty -> _ :| (notEmpty -> y :| _)) = dropWhile (/=w) $ cycle ws let (notEmpty -> _ :| (notEmpty -> y :| _)) = dropWhile (/=w) $ cycle ws
-- cannot fail to match -- cannot fail to match
in windows $ focusFn y in windows $ focusFn y
_ -> windows . focusFn . head $ ws _ -> windows . focusFn . NE.head . notEmpty $ ws
-- ws is non-empty by ifWindows's definition.
-- | Given a function which gets us a String, we try to raise a window with that classname, -- | Given a function which gets us a String, we try to raise a window with that classname,
-- or we then interpret that String as a executable name. -- or we then interpret that String as a executable name.

View File

@ -34,7 +34,7 @@ import XMonad.Prelude (fi)
-- $usage -- $usage
-- --
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.WindowMenu -- > import XMonad.Actions.WindowMenu
-- --

View File

@ -1,10 +1,12 @@
{-# LANGUAGE TupleSections #-} -- I didn't want this, it's hlint's "suggestion" and it's apparently non-negotiable
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- | -- |
-- Module : XMonad.Actions.WindowNavigation -- Module : XMonad.Actions.WindowNavigation
-- Description : Experimental rewrite of "XMonad.Layout.WindowNavigation". -- Description : Experimental rewrite of "XMonad.Layout.WindowNavigation".
-- Copyright : (c) 2007 David Roundy <droundy@darcs.net>, -- Copyright : (c) 2007 David Roundy <droundy@darcs.net>,
-- Devin Mullins <me@twifkak.com> -- Devin Mullins <me@twifkak.com>
-- Maintainer : Devin Mullins <me@twifkak.com> -- Maintainer : Devin Mullins <me@twifkak.com>,
-- Platon Pronko <platon7pronko@gmail.com>
-- License : BSD3-style (see LICENSE) -- License : BSD3-style (see LICENSE)
-- Stability : unstable -- Stability : unstable
-- Portability : unportable -- Portability : unportable
@ -37,17 +39,19 @@ module XMonad.Actions.WindowNavigation (
withWindowNavigationKeys, withWindowNavigationKeys,
WNAction(..), WNAction(..),
go, swap, go, swap,
goPure, swapPure,
Direction2D(..), WNState, Direction2D(..), WNState,
) where ) where
import XMonad import XMonad hiding (state)
import XMonad.Prelude (catMaybes, fromMaybe, listToMaybe, sortOn) import XMonad.Prelude (catMaybes, fromMaybe, sortOn)
import XMonad.Util.Types (Direction2D(..)) import XMonad.Util.Types (Direction2D(..))
import qualified XMonad.StackSet as W import qualified XMonad.StackSet as W
import Control.Arrow (second) import Control.Arrow (second)
import Data.IORef import Data.IORef
import Data.Map (Map()) import Data.Map (Map())
import Data.List (partition, find)
import qualified Data.Map as M import qualified Data.Map as M
import qualified Data.Set as S import qualified Data.Set as S
@ -101,27 +105,60 @@ withWindowNavigation (u,l,d,r) conf@XConfig{modMask=modm} =
withWindowNavigationKeys :: [((KeyMask, KeySym), WNAction)] -> XConfig l -> IO (XConfig l) withWindowNavigationKeys :: [((KeyMask, KeySym), WNAction)] -> XConfig l -> IO (XConfig l)
withWindowNavigationKeys wnKeys conf = do withWindowNavigationKeys wnKeys conf = do
posRef <- newIORef M.empty stateRef <- newIORef M.empty
return conf { keys = \cnf -> M.fromList (map (second (fromWNAction posRef)) wnKeys) return conf { keys = \cnf -> M.fromList (map (second (fromWNAction stateRef)) wnKeys)
`M.union` keys conf cnf, `M.union` keys conf cnf,
logHook = logHook conf >> trackMovement posRef } logHook = logHook conf >> trackMovement stateRef }
where fromWNAction posRef (WNGo dir) = go posRef dir where fromWNAction stateRef (WNGo dir) = go stateRef dir
fromWNAction posRef (WNSwap dir) = swap posRef dir fromWNAction stateRef (WNSwap dir) = swap stateRef dir
data WNAction = WNGo Direction2D | WNSwap Direction2D data WNAction = WNGo Direction2D | WNSwap Direction2D
type WNState = Map WorkspaceId Point type WNState = Map WorkspaceId Point
-- go: -- | Focus window in the given direction.
-- 1. get current position, verifying it matches the current window
-- 2. get target windowrect
-- 3. focus window
-- 4. set new position
go :: IORef WNState -> Direction2D -> X () go :: IORef WNState -> Direction2D -> X ()
go = withTargetWindow W.focusWindow go stateRef dir = runPureAction stateRef (goPure dir)
-- | Swap current window with the window in the given direction.
-- Note: doesn't work with floating windows (don't think it makes much sense to swap floating windows).
swap :: IORef WNState -> Direction2D -> X () swap :: IORef WNState -> Direction2D -> X ()
swap = withTargetWindow swapWithFocused swap stateRef dir = runPureAction stateRef (swapPure dir)
type WindowRectFn x = (Window -> x (Maybe Rectangle))
-- | (state, oldWindowSet, mappedWindows, windowRect)
type WNInput x = (WNState, WindowSet, S.Set Window, WindowRectFn x)
type WNOutput = (WNState, WindowSet)
-- | Run the pure action inside X monad.
runPureAction :: IORef WNState -> (WNInput X -> X WNOutput) -> X ()
runPureAction stateRef action = do
oldState <- io (readIORef stateRef)
oldWindowSet <- gets windowset
mappedWindows <- gets mapped
(newState, newWindowSet) <- action (oldState, oldWindowSet, mappedWindows, windowRectX)
windows (const newWindowSet)
io $ writeIORef stateRef newState
-- | Version of `go` not dependent on X monad (needed for testing).
goPure :: Monad x => Direction2D -> WNInput x -> x WNOutput
goPure dir input@(oldState, oldWindowSet, mappedWindows, _) =
if length (filter (`S.member` mappedWindows) $ W.integrate' $ W.stack $ W.workspace $ W.current oldWindowSet) == 1
then
-- Handle the special case of Full layout, when there's only one mapped window on a screen.
return ( oldState
, case dir of
U -> W.focusUp oldWindowSet
L -> W.focusDown oldWindowSet
D -> W.focusDown oldWindowSet
R -> W.focusUp oldWindowSet
)
else
withTargetWindow W.focusWindow dir input
-- | Version of `swap` not dependent on X monad (needed for testing).
swapPure :: Monad x => Direction2D -> WNInput x -> x WNOutput
swapPure = withTargetWindow swapWithFocused
where swapWithFocused targetWin winSet = where swapWithFocused targetWin winSet =
case W.peek winSet of case W.peek winSet of
Just currentWin -> W.focusWindow currentWin $ Just currentWin -> W.focusWindow currentWin $
@ -135,87 +172,249 @@ swap = withTargetWindow swapWithFocused
| win == win2 = win1 | win == win2 = win1
| otherwise = win | otherwise = win
withTargetWindow :: (Window -> WindowSet -> WindowSet) -> IORef WNState -> Direction2D -> X () -- | Select a target window in the given direction and modify the WindowSet.
withTargetWindow adj posRef dir = fromCurrentPoint posRef $ \win pos -> do -- 1. Get current position, verifying it matches the current window (exit if no focused window).
targets <- filter ((/= win) . fst) <$> navigableTargets pos dir -- 2. Get the target window.
whenJust (listToMaybe targets) $ \(targetWin, targetRect) -> do -- 3. Execute an action on the target window and windowset.
windows (adj targetWin) -- 4. Set the new position.
setPosition posRef pos targetRect withTargetWindow :: Monad x => (Window -> WindowSet -> WindowSet) -> Direction2D -> WNInput x -> x WNOutput
withTargetWindow adj dir input@(oldState, oldWindowSet, _, _) = do
whenJust' (getCurrentWindow input) (oldState, oldWindowSet) $ \(win, winRect, pos) -> do
targetMaybe <- find ((/= win) . fst) <$> navigableTargets input dir winRect pos
whenJust' (pure targetMaybe) (oldState, oldWindowSet) $ \(targetWin, newPos) ->
let newWindowSet = adj targetWin oldWindowSet
in return (modifyState newWindowSet newPos oldState, newWindowSet)
-- | Update position on outside changes in windows.
trackMovement :: IORef WNState -> X () trackMovement :: IORef WNState -> X ()
trackMovement posRef = fromCurrentPoint posRef $ \win pos -> trackMovement stateRef = do
windowRect win >>= flip whenJust (setPosition posRef pos . snd) oldState <- io (readIORef stateRef)
oldWindowSet <- gets windowset
mappedWindows <- gets mapped
whenJust' (getCurrentWindow (oldState, oldWindowSet, mappedWindows, windowRectX)) () $ \(_, _, pos) -> do
io $ writeIORef stateRef $ modifyState oldWindowSet pos oldState
fromCurrentPoint :: IORef WNState -> (Window -> Point -> X ()) -> X () -- | Get focused window and current position.
fromCurrentPoint posRef f = withFocused $ \win -> getCurrentWindow :: Monad x => WNInput x -> x (Maybe (Window, Rectangle, Point))
currentPosition posRef >>= f win getCurrentWindow input@(_, oldWindowSet, _, _) =
whenJust' (pure $ W.peek oldWindowSet) Nothing $ \window -> do
(pos, rect) <- currentPosition input
return $ Just (window, rect, pos)
-- Gets the current position from the IORef passed in, or if nothing (say, from -- | Gets the current position from the state passed in, or if nothing
-- a restart), derives the current position from the current window. Also, -- (say, from a restart), derives the current position from the current window.
-- verifies that the position is congruent with the current window (say, if you -- Also, verifies that the position is congruent with the current window
-- used mod-j/k or mouse or something). -- (say, if you moved focus using mouse or something).
currentPosition :: IORef WNState -> X Point -- Returns the window rectangle for convenience, since we'll need it later anyway.
currentPosition posRef = do currentPosition :: Monad x => WNInput x -> x (Point, Rectangle)
root <- asks theRoot currentPosition (state, oldWindowSet, _, windowRect) = do
currentWindow <- gets (W.peek . windowset) currentRect <- fromMaybe (Rectangle 0 0 0 0) <$> maybe (pure Nothing) windowRect (W.peek oldWindowSet)
currentRect <- maybe (Rectangle 0 0 0 0) snd <$> windowRect (fromMaybe root currentWindow) let posMaybe = M.lookup (W.currentTag oldWindowSet) state
middleOf (Rectangle x y w h) = Point (midPoint x w) (midPoint y h)
return $ case posMaybe of
Nothing -> (middleOf currentRect, currentRect)
Just pos -> (centerPosition currentRect pos, currentRect)
wsid <- gets (W.currentTag . windowset) -- | Inserts new position into the state.
mp <- M.lookup wsid <$> io (readIORef posRef) modifyState :: WindowSet -> Point -> WNState -> WNState
modifyState oldWindowSet =
M.insert (W.currentTag oldWindowSet)
return $ maybe (middleOf currentRect) (`inside` currentRect) mp -- | "Jumps" the current position into the middle of target rectangle.
-- (keeps the position as-is if it is already inside the target rectangle)
where middleOf (Rectangle x y w h) = Point (midPoint x w) (midPoint y h) centerPosition :: Rectangle -> Point -> Point
centerPosition r@(Rectangle rx ry rw rh) pos@(Point x y) = do
setPosition :: IORef WNState -> Point -> Rectangle -> X () if pointWithin x y r
setPosition posRef oldPos newRect = do then pos
wsid <- gets (W.currentTag . windowset) else Point (midPoint rx rw) (midPoint ry rh)
io $ modifyIORef posRef $ M.insert wsid (oldPos `inside` newRect)
inside :: Point -> Rectangle -> Point
Point x y `inside` Rectangle rx ry rw rh =
Point (x `within` (rx, rw)) (y `within` (ry, rh))
where pos `within` (lower, dim) = if pos >= lower && pos < lower + fromIntegral dim
then pos
else midPoint lower dim
midPoint :: Position -> Dimension -> Position midPoint :: Position -> Dimension -> Position
midPoint pos dim = pos + fromIntegral dim `div` 2 midPoint pos dim = pos + fromIntegral dim `div` 2
navigableTargets :: Point -> Direction2D -> X [(Window, Rectangle)] -- | Make a list of target windows we can navigate to,
navigableTargets point dir = navigable dir point <$> windowRects -- sorted by desirability of navigation.
navigableTargets :: Monad x => WNInput x -> Direction2D -> Rectangle -> Point -> x [(Window, Point)]
navigableTargets input@(_, oldWindowSet, _, _) dir currentRect currentPos = do
allScreensWindowsAndRectangles <- mapSnd (rectTransform dir) <$> windowRects input
let
screenWindows = S.fromList $ W.integrate' $ W.stack $ W.workspace $ W.current oldWindowSet
(thisScreenWindowsAndRectangles, otherScreensWindowsAndRectangles) = partition (\(w, _) -> S.member w screenWindows) allScreensWindowsAndRectangles
-- Filters and sorts the windows in terms of what is closest from the Point in pos = pointTransform dir currentPos
-- the Direction2D. wr = rectTransform dir currentRect
navigable :: Direction2D -> Point -> [(Window, Rectangle)] -> [(Window, Rectangle)]
navigable d pt = sortby d . filter (inr d pt . snd)
-- Produces a list of normal-state windows, on any screen. Rectangles are rectInside r = (rect_p1 r >= rect_p1 wr && rect_p1 r < rect_p2 wr && rect_p2 r > rect_p1 wr && rect_p2 r <= rect_p2 wr) &&
-- adjusted based on screen position relative to the current screen, because I'm ((rect_o1 r >= rect_o1 wr && rect_o1 r < rect_o2 wr && rect_o2 r > rect_o1 wr && rect_o2 r <= rect_o2 wr) ||
-- bad like that. (rect_o1 r <= rect_o1 wr && rect_o2 r >= rect_o2 wr)) -- include windows that fully overlaps current on the orthogonal axis
windowRects :: X [(Window, Rectangle)] sortByP2 = sortOn (rect_p2 . snd)
windowRects = fmap catMaybes . mapM windowRect . S.toList =<< gets mapped posBeforeEdge r = point_p pos < rect_p2 r
windowRect :: Window -> X (Maybe (Window, Rectangle)) rectOverlapsEdge r = rect_p1 r <= rect_p2 wr && rect_p2 r > rect_p2 wr &&
windowRect win = withDisplay $ \dpy -> do rect_o1 r < rect_o2 wr && rect_o2 r > rect_o1 wr
rectOverlapsOneEdge r = rectOverlapsEdge r && rect_p1 r > rect_p1 wr
rectOverlapsBothEdges r = rectOverlapsEdge r &&
rect_o1 r > rect_o1 wr && rect_o2 r < rect_o2 wr && point_o pos >= rect_o1 r && point_o pos < rect_o2 r
distanceToRectEdge r = max (max 0 (rect_o1 r - point_o pos)) (max 0 (point_o pos + 1 - rect_o2 r))
distanceToRectCenter r =
let distance = (rect_o1 r + rect_o2 r) `div` 2 - point_o pos
in if distance <= 0
then distance + 1
else distance
sortByPosDistance = sortOn ((\r -> (rect_p1 r, distanceToRectEdge r, distanceToRectCenter r)) . snd)
rectOutside r = rect_p1 r < rect_p1 wr && rect_p2 r > rect_p2 wr &&
rect_o1 r < rect_o1 wr && rect_o2 r > rect_o2 wr
sortByLength = sortOn (rect_psize . snd)
rectAfterEdge r = rect_p1 r > rect_p2 wr
-- Modified from David Roundy and Devin Mullins original implementation of WindowNavigation:
inr r = point_p pos < rect_p2 r && point_o pos >= rect_o1 r && point_o pos < rect_o2 r
clamp v v1 v2 | v < v1 = v1
| v >= v2 = v2 - 1
| otherwise = v
dragPos r = DirPoint (max (point_p pos) (rect_p1 r)) (clamp (point_o pos) (rect_o1 r) (rect_o2 r))
return $ mapSnd (inversePointTransform dir) $ concat
[
-- First, navigate to windows that are fully inside current window
-- and have higher coordinate bigger than current position.
-- ┌──────────────────┐
-- │ current │ (all examples assume direction=R)
-- │ ┌──────────┐ │
-- │ ──┼─► inside │ │
-- │ └──────────┘ │
-- └──────────────────┘
-- Also include windows fully overlapping current on the orthogonal axis:
-- ┌──────────────┐
-- │ overlapping │
-- ┌───────────┤ ├────┐
-- │ current ──┼─► │ │
-- └───────────┤ ├────┘
-- └──────────────┘
mapSnd dragPos $ sortByP2 $ filterSnd posBeforeEdge $ filterSnd rectInside thisScreenWindowsAndRectangles
-- Then navigate to windows that touch or overlap the edge of current window in the chosen direction.
-- ┌──────────────┬─────────────┐ ┌───────────┐ ┌─────────────┐
-- │ current │ adjacent │ │ current │ │ current │
-- │ ──┼─► │ │ ┌───┴───────────────┐ │ ┌───┴─────────────┐
-- │ │ │ │ ──┼─► │ overlapping │ │ ──┼─► │
-- │ ├─────────────┘ │ └───┬───────────────┘ └─────────┤ overlapping │
-- │ │ │ │ │ │
-- └──────────────┘ └───────────┘ └─────────────────┘
, mapSnd dragPos $ sortByPosDistance $ filterSnd rectOverlapsOneEdge thisScreenWindowsAndRectangles
-- Windows fully overlapping current window "in the middle" on the parallel axis are also included,
-- if position is inside them:
-- ┌───────────┐
-- │ current │
-- ┌───┤-----------├────────────────┐
-- │ │ * ──┼─► overlapping │
-- └───┤-----------├────────────────┘
-- └───────────┘
, mapSnd (\_ -> DirPoint (rect_p2 wr) (point_o pos)) $ sortByPosDistance $ filterSnd rectOverlapsBothEdges thisScreenWindowsAndRectangles
-- Then navigate to windows that fully encompass the current window.
-- ┌─────────────────────┐
-- │ outer │
-- │ ┌─────────────┐ │
-- │ │ current ──┼─► │
-- │ └─────────────┘ │
-- └─────────────────────┘
, mapSnd (\_ -> DirPoint (rect_p2 wr) (point_o pos)) $ sortByLength $ filterSnd rectOutside thisScreenWindowsAndRectangles
-- Then navigate to windows that are fully after current window in the chosen direction.
-- ┌──────────────┐
-- │ current │ ┌────────────────┐
-- │ │ │ │
-- │ ──┼──┼─► not adjacent │
-- │ │ │ │
-- │ │ └────────────────┘
-- └──────────────┘
, mapSnd dragPos $ sortByPosDistance $ filterSnd rectAfterEdge thisScreenWindowsAndRectangles
-- Cast a ray from the current position, jump to the first window (on another screen) that intersects this ray.
, mapSnd dragPos $ sortByPosDistance $ filterSnd inr otherScreensWindowsAndRectangles
-- If everything else fails, then navigate to the window that is fully inside current window,
-- but is before the current position.
-- This can happen when we are at the last window on a screen, and attempt to navigate even further.
-- In this case it seems okay to jump to the remaining inner windows, since we don't have any other choice anyway,
-- and user is probably not so fully aware of the precise position anyway.
, mapSnd (\r -> DirPoint (rect_p2 r - 1) (clamp (point_o pos) (rect_o1 r) (rect_o2 r))) $
sortByP2 $ filterSnd (not . posBeforeEdge) $ filterSnd rectInside thisScreenWindowsAndRectangles
]
-- Structs for direction-independent space - equivalent to rotating points and rectangles such that
-- navigation direction points to the right.
-- Allows us to abstract over direction in the navigation functions.
data DirPoint = DirPoint
{ point_p :: Position -- coordinate parallel to the direction
, point_o :: Position -- coordinate orthogonal to the direction
}
data DirRectangle = DirRectangle
{ rect_p1 :: Position -- lower rectangle coordinate parallel to the direction
, rect_p2 :: Position -- higher rectangle coordinate parallel to the direction
, rect_o1 :: Position -- lower rectangle coordinate orthogonal to the direction
, rect_o2 :: Position -- higher rectangle coordinate orthogonal to the direction
}
{- HLINT ignore "Use camelCase" -}
rect_psize :: DirRectangle -> Dimension
rect_psize r = fromIntegral (rect_p2 r - rect_p1 r)
-- | Transform a point from screen space into direction-independent space.
pointTransform :: Direction2D -> Point -> DirPoint
pointTransform dir (Point x y) = case dir of
U -> DirPoint (negate y - 1) x
L -> DirPoint (negate x - 1) (negate y - 1)
D -> DirPoint y (negate x - 1)
R -> DirPoint x y
-- | Transform a point from direction-independent space back into screen space.
inversePointTransform :: Direction2D -> DirPoint -> Point
inversePointTransform dir p = case dir of
U -> Point (point_o p) (negate $ point_p p + 1)
L -> Point (negate $ point_p p + 1) (negate $ point_o p + 1)
D -> Point (negate $ point_o p + 1) (point_p p)
R -> Point (point_p p) (point_o p)
-- | Transform a rectangle from screen space into direction-independent space.
rectTransform :: Direction2D -> Rectangle -> DirRectangle
rectTransform dir (Rectangle x y w h) = case dir of
U -> DirRectangle (negate $ y + fromIntegral h) (negate y) x (x + fromIntegral w)
L -> DirRectangle (negate $ x + fromIntegral w) (negate x) (negate $ y + fromIntegral h) (negate y)
D -> DirRectangle y (y + fromIntegral h) (negate $ x + fromIntegral w) (negate x)
R -> DirRectangle x (x + fromIntegral w) y (y + fromIntegral h)
-- | Produces a list of normal-state windows on all screens, excluding currently focused window.
windowRects :: Monad x => WNInput x -> x [(Window, Rectangle)]
windowRects (_, oldWindowSet, mappedWindows, windowRect) =
let
allWindows = filter (\w -> w `notElem` W.peek oldWindowSet) $ S.toList mappedWindows
windowRect2 w = fmap (w,) <$> windowRect w
in catMaybes <$> mapM windowRect2 allWindows
windowRectX :: Window -> X (Maybe Rectangle)
windowRectX win = withDisplay $ \dpy -> do
(_, x, y, w, h, bw, _) <- io $ getGeometry dpy win (_, x, y, w, h, bw, _) <- io $ getGeometry dpy win
return $ Just (win, Rectangle x y (w + 2 * bw) (h + 2 * bw)) return $ Just $ Rectangle x y (w + 2 * bw) (h + 2 * bw)
`catchX` return Nothing `catchX` return Nothing
-- Modified from droundy's implementation of WindowNavigation: -- Maybe below functions can be replaced with some standard helper functions?
inr :: Direction2D -> Point -> Rectangle -> Bool -- | Execute a monadic action on the contents if Just, otherwise wrap default value and return it.
inr D (Point px py) (Rectangle rx ry w h) = px >= rx && px < rx + fromIntegral w && whenJust' :: Monad x => x (Maybe a) -> b -> (a -> x b) -> x b
py < ry + fromIntegral h whenJust' monadMaybeValue deflt f = do
inr U (Point px py) (Rectangle rx ry w _) = px >= rx && px < rx + fromIntegral w && maybeValue <- monadMaybeValue
py > ry case maybeValue of
inr R (Point px py) (Rectangle rx ry w h) = px < rx + fromIntegral w && Nothing -> return deflt
py >= ry && py < ry + fromIntegral h Just value -> f value
inr L (Point px py) (Rectangle rx ry _ h) = px > rx &&
py >= ry && py < ry + fromIntegral h
sortby :: Direction2D -> [(a,Rectangle)] -> [(a,Rectangle)] -- | Filter a list of tuples on the second tuple member.
sortby D = sortOn (rect_y . snd) filterSnd :: (b -> Bool) -> [(a, b)] -> [(a, b)]
sortby R = sortOn (rect_x . snd) filterSnd f = filter (f . snd)
sortby U = reverse . sortby D
sortby L = reverse . sortby R -- | Map a second tuple member in a list of tuples.
mapSnd :: (b -> b') -> [(a, b)] -> [(a, b')]
mapSnd f = map (second f)

View File

@ -24,7 +24,7 @@ import XMonad.StackSet
-- $usage -- $usage
-- --
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.WithAll -- > import XMonad.Actions.WithAll
-- --
@ -33,7 +33,7 @@ import XMonad.StackSet
-- , ((modm .|. shiftMask, xK_t), sinkAll) -- , ((modm .|. shiftMask, xK_t), sinkAll)
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
-- | Un-float all floating windows on the current workspace. -- | Un-float all floating windows on the current workspace.
sinkAll :: X () sinkAll :: X ()

View File

@ -43,7 +43,7 @@ import qualified XMonad.Util.ExtensibleState as XS
import XMonad.Actions.OnScreen import XMonad.Actions.OnScreen
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Actions.Workscreen -- > import XMonad.Actions.Workscreen
-- > myWorkspaces = let myOldWorkspaces = ["adm","work","mail"] -- > myWorkspaces = let myOldWorkspaces = ["adm","work","mail"]
@ -58,7 +58,7 @@ import XMonad.Actions.OnScreen
-- > , (f, m) <- [(Workscreen.viewWorkscreen, 0), (Workscreen.shiftToWorkscreen, shiftMask)]] -- > , (f, m) <- [(Workscreen.viewWorkscreen, 0), (Workscreen.shiftToWorkscreen, shiftMask)]]
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
data Workscreen = Workscreen{workscreenId::Int,workspaces::[WorkspaceId]} deriving (Show) data Workscreen = Workscreen{workscreenId::Int,workspaces::[WorkspaceId]} deriving (Show)
@ -109,5 +109,6 @@ shiftWs a = drop 1 a ++ take 1 a
-- @WorkscreenId@. -- @WorkscreenId@.
shiftToWorkscreen :: WorkscreenId -> X () shiftToWorkscreen :: WorkscreenId -> X ()
shiftToWorkscreen wscrId = do (WorkscreenStorage _ a) <- XS.get shiftToWorkscreen wscrId = do (WorkscreenStorage _ a) <- XS.get
let ws = head . workspaces $ a !! wscrId case workspaces (a !! wscrId) of
windows $ W.shift ws [] -> pure ()
(w : _) -> windows $ W.shift w

View File

@ -50,7 +50,7 @@ import XMonad.Layout.LayoutModifier(ModifiedLayout(..),
import XMonad(Message, WorkspaceId, X, XState(windowset), import XMonad(Message, WorkspaceId, X, XState(windowset),
fromMessage, sendMessage, windows, gets) fromMessage, sendMessage, windows, gets)
import XMonad.Util.Stack (reverseS) import XMonad.Util.Stack (reverseS)
import XMonad.Prelude (find, fromJust, guard, liftA2, toList, when, (<=<)) import XMonad.Prelude
-- $usage -- $usage
-- --
@ -95,10 +95,10 @@ import XMonad.Prelude (find, fromJust, guard, liftA2, toList, when, (<=<))
-- | makeCursors requires a nonempty string, and each sublist must be nonempty -- | makeCursors requires a nonempty string, and each sublist must be nonempty
makeCursors :: [[String]] -> Cursors String makeCursors :: [[String]] -> Cursors String
makeCursors [] = error "Workspace Cursors cannot be empty" makeCursors [] = error "Workspace Cursors cannot be empty"
makeCursors a = concat . reverse <$> foldl addDim x xs makeCursors (a : as) = concat . reverse <$> foldl addDim x xs
where x = end $ map return $ head a where x = end $ map return a
xs = map (map return) $ tail a xs = map (map return) as
-- this could probably be simplified, but this true: -- this could probably be simplified, but this true:
-- toList . makeCursors == map (concat . reverse) . sequence . reverse . map (map (:[])) -- toList . makeCursors == map (concat . reverse) . sequence . reverse . map (map (:[]))
-- the strange order is used because it makes the regular M-1..9 -- the strange order is used because it makes the regular M-1..9

View File

@ -51,14 +51,14 @@ import XMonad.Actions.CycleWS (findWorkspace, WSType(..), Direction1D(..), anyWS
import qualified XMonad.Actions.SwapWorkspaces as Swap import qualified XMonad.Actions.SwapWorkspaces as Swap
import XMonad.Hooks.StatusBar.PP (PP(..)) import XMonad.Hooks.StatusBar.PP (PP(..))
import XMonad.Hooks.EwmhDesktops (addEwmhWorkspaceRename) import XMonad.Hooks.EwmhDesktops (addEwmhWorkspaceRename)
import XMonad.Prompt (mkXPrompt, XPConfig) import XMonad.Prompt (mkXPrompt, XPConfig, historyCompletionP)
import XMonad.Prompt.Workspace (Wor(Wor)) import XMonad.Prompt.Workspace (Wor(Wor))
import XMonad.Util.WorkspaceCompare (getSortByIndex) import XMonad.Util.WorkspaceCompare (getSortByIndex)
import qualified Data.Map as M import qualified Data.Map as M
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@ file: -- You can use this module with the following in your @xmonad.hs@ file:
-- --
-- > import XMonad.Actions.WorkspaceNames -- > import XMonad.Actions.WorkspaceNames
-- --
@ -88,7 +88,7 @@ import qualified Data.Map as M
-- > | (i, k) <- zip workspaces [xK_1 ..]] -- > | (i, k) <- zip workspaces [xK_1 ..]]
-- --
-- For detailed instructions on editing your key bindings, see -- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings". -- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
@ -137,9 +137,11 @@ setCurrentWorkspaceName name = do
-- | Prompt for a new name for the current workspace and set it. -- | Prompt for a new name for the current workspace and set it.
renameWorkspace :: XPConfig -> X () renameWorkspace :: XPConfig -> X ()
renameWorkspace conf = renameWorkspace conf = do
mkXPrompt pr conf (const (return [])) setCurrentWorkspaceName completion <- historyCompletionP conf (prompt ==)
where pr = Wor "Workspace name: " mkXPrompt (Wor prompt) conf completion setCurrentWorkspaceName
where
prompt = "Workspace name: "
-- | See 'XMonad.Actions.SwapWorkspaces.swapTo'. This is the same with names. -- | See 'XMonad.Actions.SwapWorkspaces.swapTo'. This is the same with names.
swapTo :: Direction1D -> X () swapTo :: Direction1D -> X ()

View File

@ -47,7 +47,7 @@ import XMonad.Util.Themes
-- $usage -- $usage
-- The simplest way to use this configuration module is to use an -- The simplest way to use this configuration module is to use an
-- @~\/.xmonad\/xmonad.hs@ like this: -- @xmonad.hs@ like this:
-- --
-- > module Main (main) where -- > module Main (main) where
-- > -- >
@ -64,7 +64,7 @@ import XMonad.Util.Themes
-- --
-- You can use this module also as a starting point for writing your -- You can use this module also as a starting point for writing your
-- own configuration module from scratch. Save it as your -- own configuration module from scratch. Save it as your
-- @~\/.xmonad\/xmonad.hs@ and: -- @xmonad.hs@ and:
-- --
-- 1. Change the module name from -- 1. Change the module name from
-- --

View File

@ -27,7 +27,7 @@ import qualified XMonad.StackSet as W
import qualified Data.Map as M import qualified Data.Map as M
-- $usage -- $usage
-- To use this module, start with the following @~\/.xmonad\/xmonad.hs@: -- To use this module, start with the following @xmonad.hs@:
-- --
-- > import XMonad -- > import XMonad
-- > import XMonad.Config.Azerty -- > import XMonad.Config.Azerty

View File

@ -26,7 +26,7 @@ import qualified XMonad.StackSet as W
import qualified Data.Map as M import qualified Data.Map as M
-- $usage -- $usage
-- To use this module, start with the following @~\/.xmonad\/xmonad.hs@: -- To use this module, start with the following @xmonad.hs@:
-- --
-- > import XMonad -- > import XMonad
-- > import XMonad.Config.Bepo -- > import XMonad.Config.Bepo

View File

@ -29,7 +29,7 @@ module XMonad.Config.Bluetile (
import XMonad import XMonad
import XMonad.Layout.BorderResize import XMonad.Layout.BorderResize
import XMonad.Layout.BoringWindows import XMonad.Layout.BoringWindows hiding (Replace)
import XMonad.Layout.ButtonDecoration import XMonad.Layout.ButtonDecoration
import XMonad.Layout.Decoration import XMonad.Layout.Decoration
import XMonad.Layout.DecorationAddons import XMonad.Layout.DecorationAddons
@ -37,7 +37,7 @@ import XMonad.Layout.DraggingVisualizer
import XMonad.Layout.Maximize import XMonad.Layout.Maximize
import XMonad.Layout.Minimize import XMonad.Layout.Minimize
import XMonad.Layout.MouseResizableTile import XMonad.Layout.MouseResizableTile
import XMonad.Layout.Named import XMonad.Layout.Renamed
import XMonad.Layout.NoBorders import XMonad.Layout.NoBorders
import XMonad.Layout.PositionStoreFloat import XMonad.Layout.PositionStoreFloat
import XMonad.Layout.WindowSwitcherDecoration import XMonad.Layout.WindowSwitcherDecoration
@ -65,7 +65,7 @@ import System.Exit
import XMonad.Prelude(when) import XMonad.Prelude(when)
-- $usage -- $usage
-- To use this module, start with the following @~\/.xmonad\/xmonad.hs@: -- To use this module, start with the following @xmonad.hs@:
-- --
-- > import XMonad -- > import XMonad
-- > import XMonad.Config.Bluetile -- > import XMonad.Config.Bluetile
@ -183,10 +183,10 @@ bluetileManageHook = composeAll
, isFullscreen --> doFullFloat] , isFullscreen --> doFullFloat]
bluetileLayoutHook = avoidStruts $ minimize $ boringWindows $ bluetileLayoutHook = avoidStruts $ minimize $ boringWindows $
named "Floating" floating ||| renamed [Replace "Floating"] floating |||
named "Tiled1" tiled1 ||| renamed [Replace "Tiled1"] tiled1 |||
named "Tiled2" tiled2 ||| renamed [Replace "Tiled2"] tiled2 |||
named "Fullscreen" fullscreen renamed [Replace "Fullscreen"] fullscreen
where where
floating = floatingDeco $ maximize $ borderResize positionStoreFloat floating = floatingDeco $ maximize $ borderResize positionStoreFloat
tiled1 = tilingDeco $ maximize mouseResizableTileMirrored tiled1 = tilingDeco $ maximize mouseResizableTileMirrored

View File

@ -24,7 +24,7 @@ module XMonad.Config.Desktop (
-- specification. Extra xmonad settings unique to specific DE's are -- specification. Extra xmonad settings unique to specific DE's are
-- added by overriding or modifying @desktopConfig@ fields in the -- added by overriding or modifying @desktopConfig@ fields in the
-- same way that the default configuration is customized in -- same way that the default configuration is customized in
-- @~\/.xmonad/xmonad.hs@. -- @xmonad.hs@.
-- --
-- For more information about EWMH see: -- For more information about EWMH see:
-- --
@ -72,7 +72,7 @@ import qualified Data.Map as M
-- <http://haskell.org/haskellwiki/Xmonad> -- <http://haskell.org/haskellwiki/Xmonad>
-- --
-- To configure xmonad for use with a DE or with DE tools like panels -- To configure xmonad for use with a DE or with DE tools like panels
-- and pagers, in place of @def@ in your @~\/.xmonad/xmonad.hs@, -- and pagers, in place of @def@ in your @xmonad.hs@,
-- use @desktopConfig@ or one of the other desktop configs from the -- use @desktopConfig@ or one of the other desktop configs from the
-- @XMonad.Config@ namespace. The following setup and customization examples -- @XMonad.Config@ namespace. The following setup and customization examples
-- work the same way for the other desktop configs as for @desktopConfig@. -- work the same way for the other desktop configs as for @desktopConfig@.
@ -91,7 +91,7 @@ import qualified Data.Map as M
-- $customizing -- $customizing
-- To customize a desktop config, modify its fields as is illustrated with -- To customize a desktop config, modify its fields as is illustrated with
-- the default configuration @def@ in "XMonad.Doc.Extending#Extending xmonad". -- the default configuration @def@ in <https://xmonad.org/TUTORIAL.html the tutorial>.
-- $layouts -- $layouts
-- See also "XMonad.Util.EZConfig" for more options for modifying key bindings. -- See also "XMonad.Util.EZConfig" for more options for modifying key bindings.

View File

@ -34,7 +34,7 @@ import XMonad.Layout.Grid
import XMonad.Layout.IndependentScreens hiding (withScreen) import XMonad.Layout.IndependentScreens hiding (withScreen)
import XMonad.Layout.Magnifier import XMonad.Layout.Magnifier
import XMonad.Layout.NoBorders import XMonad.Layout.NoBorders
import XMonad.Prelude import XMonad.Prelude hiding (fromList)
import XMonad.Util.Dzen hiding (x, y) import XMonad.Util.Dzen hiding (x, y)
import XMonad.Util.SpawnOnce import XMonad.Util.SpawnOnce
-- }}} -- }}}

View File

@ -1,4 +1,5 @@
{-# LANGUAGE PatternGuards #-} {-# LANGUAGE PatternGuards #-}
{-# LANGUAGE TupleSections #-}
{-# OPTIONS_GHC -fno-warn-missing-signatures -fno-warn-orphans #-} {-# OPTIONS_GHC -fno-warn-missing-signatures -fno-warn-orphans #-}
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- | -- |
@ -20,7 +21,7 @@ import System.Exit ( exitSuccess )
import XMonad.Layout.Tabbed ( tabbed, import XMonad.Layout.Tabbed ( tabbed,
shrinkText, Shrinker, shrinkIt, CustomShrink(CustomShrink) ) shrinkText, Shrinker, shrinkIt, CustomShrink(CustomShrink) )
import XMonad.Layout.Combo ( combineTwo ) import XMonad.Layout.Combo ( combineTwo )
import XMonad.Layout.Named ( named ) import XMonad.Layout.Renamed ( Rename(Replace), renamed )
import XMonad.Layout.LayoutCombinators import XMonad.Layout.LayoutCombinators
import XMonad.Layout.Square ( Square(Square) ) import XMonad.Layout.Square ( Square(Square) )
import XMonad.Layout.WindowNavigation ( Navigate(Move,Swap,Go), Direction2D(U,D,R,L), import XMonad.Layout.WindowNavigation ( Navigate(Move,Swap,Go), Direction2D(U,D,R,L),
@ -114,9 +115,9 @@ keys x = M.fromList $
] ]
++ ++
zip (zip (repeat $ modMask x) [xK_F1..xK_F12]) (map (withNthWorkspace W.greedyView) [0..]) zip (map (modMask x,) [xK_F1..xK_F12]) (map (withNthWorkspace W.greedyView) [0..])
++ ++
zip (zip (repeat (modMask x .|. shiftMask)) [xK_F1..xK_F12]) (map (withNthWorkspace copy) [0..]) zip (map (modMask x .|. shiftMask,) [xK_F1..xK_F12]) (map (withNthWorkspace copy) [0..])
config = docks $ ewmh def config = docks $ ewmh def
{ borderWidth = 1 -- Width of the window border in pixels. { borderWidth = 1 -- Width of the window border in pixels.
@ -124,10 +125,10 @@ config = docks $ ewmh def
, layoutHook = showWName $ workspaceDir "~" $ , layoutHook = showWName $ workspaceDir "~" $
boringWindows $ smartBorders $ windowNavigation $ boringWindows $ smartBorders $ windowNavigation $
maximizeVertical $ toggleLayouts Full $ avoidStruts $ maximizeVertical $ toggleLayouts Full $ avoidStruts $
named "tabbed" mytab ||| renamed [Replace "tabbed"] mytab |||
named "xclock" (mytab ****//* combineTwo Square mytab mytab) ||| renamed [Replace "xclock"] (mytab ****//* combineTwo Square mytab mytab) |||
named "three" (mytab **//* mytab *//* combineTwo Square mytab mytab) ||| renamed [Replace "three"] (mytab **//* mytab *//* combineTwo Square mytab mytab) |||
named "widescreen" ((mytab *||* mytab) renamed [Replace "widescreen"] ((mytab *||* mytab)
****//* combineTwo Square mytab mytab) -- ||| ****//* combineTwo Square mytab mytab) -- |||
--mosaic 0.25 0.5 --mosaic 0.25 0.5
, terminal = "xterm" -- The preferred terminal program. , terminal = "xterm" -- The preferred terminal program.

View File

@ -32,7 +32,7 @@ import qualified Data.Map as M
import System.Environment (getEnvironment) import System.Environment (getEnvironment)
-- $usage -- $usage
-- To use this module, start with the following @~\/.xmonad\/xmonad.hs@: -- To use this module, start with the following @xmonad.hs@:
-- --
-- > import XMonad -- > import XMonad
-- > import XMonad.Config.Gnome -- > import XMonad.Config.Gnome

View File

@ -28,7 +28,7 @@ import XMonad.Config.Desktop
import qualified Data.Map as M import qualified Data.Map as M
-- $usage -- $usage
-- To use this module, start with the following @~\/.xmonad\/xmonad.hs@: -- To use this module, start with the following @xmonad.hs@:
-- --
-- > import XMonad -- > import XMonad
-- > import XMonad.Config.Kde -- > import XMonad.Config.Kde

View File

@ -27,7 +27,7 @@ import XMonad.Config.Desktop
import qualified Data.Map as M import qualified Data.Map as M
-- $usage -- $usage
-- To use this module, start with the following @~\/.xmonad\/xmonad.hs@: -- To use this module, start with the following @xmonad.hs@:
-- --
-- > import XMonad -- > import XMonad
-- > import XMonad.Config.LXQt -- > import XMonad.Config.LXQt

View File

@ -1,5 +1,7 @@
{-# OPTIONS_GHC -fno-warn-missing-signatures #-} {-# OPTIONS_GHC -fno-warn-missing-signatures #-}
-- TODO: Remove when we depend on a version of xmonad that has unGrab.
{-# OPTIONS_GHC -Wno-deprecations #-}
{-# OPTIONS_GHC -Wno-dodgy-imports #-}
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- | -- |
-- Module : XMonad.Config.Mate -- Module : XMonad.Config.Mate
@ -28,18 +30,17 @@ module XMonad.Config.Mate (
desktopLayoutModifiers desktopLayoutModifiers
) where ) where
import XMonad import System.Environment (getEnvironment)
import XMonad.Config.Desktop
import XMonad.Util.Run (safeSpawn)
import XMonad.Util.Ungrab
import XMonad.Prelude (toUpper)
import qualified Data.Map as M import qualified Data.Map as M
import System.Environment (getEnvironment) import XMonad hiding (unGrab)
import XMonad.Config.Desktop
import XMonad.Prelude (toUpper)
import XMonad.Util.Run (safeSpawn)
import XMonad.Util.Ungrab (unGrab)
-- $usage -- $usage
-- To use this module, start with the following @~\/.xmonad\/xmonad.hs@: -- To use this module, start with the following @xmonad.hs@:
-- --
-- > import XMonad -- > import XMonad
-- > import XMonad.Config.Mate -- > import XMonad.Config.Mate

View File

@ -1,3 +1,4 @@
{-# OPTIONS_HADDOCK hide #-}
{-# LANGUAGE FlexibleContexts, FlexibleInstances, FunctionalDependencies, KindSignatures, UndecidableInstances #-} {-# LANGUAGE FlexibleContexts, FlexibleInstances, FunctionalDependencies, KindSignatures, UndecidableInstances #-}
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
@ -126,7 +127,7 @@ import qualified XMonad as X (xmonad, XConfig(..))
import XMonad.Util.EZConfig (additionalKeysP, additionalMouseBindings, checkKeymap, removeKeysP, removeMouseBindings) import XMonad.Util.EZConfig (additionalKeysP, additionalMouseBindings, checkKeymap, removeKeysP, removeMouseBindings)
-- $start_here -- $start_here
-- To start with, create a @~\/.xmonad\/xmonad.hs@ that looks like this: -- To start with, create a @xmonad.hs@ that looks like this:
-- --
-- > {-# LANGUAGE RebindableSyntax #-} -- > {-# LANGUAGE RebindableSyntax #-}
-- > import XMonad.Config.Prime -- > import XMonad.Config.Prime
@ -388,7 +389,7 @@ instance RemovableClass MouseBindings [(ButtonMask, Button)] where
MouseBindings { mRemove = r } =- sadBindings = return . r sadBindings MouseBindings { mRemove = r } =- sadBindings = return . r sadBindings
-- | Mouse button bindings to an 'X' actions on a window. Default: see @`man -- | Mouse button bindings to an 'X' actions on a window. Default: see @`man
-- xmonad`@. To make mod-<scrollwheel> switch workspaces: -- xmonad`@. To make @mod-\<scrollwheel\>@ switch workspaces:
-- --
-- > import XMonad.Actions.CycleWS (nextWS, prevWS) -- > import XMonad.Actions.CycleWS (nextWS, prevWS)
-- > ... -- > ...

View File

@ -27,7 +27,7 @@ import XMonad.Config.Desktop
import qualified Data.Map as M import qualified Data.Map as M
-- $usage -- $usage
-- To use this module, start with the following @~\/.xmonad\/xmonad.hs@: -- To use this module, start with the following @xmonad.hs@:
-- --
-- > import XMonad -- > import XMonad
-- > import XMonad.Config.Xfce -- > import XMonad.Config.Xfce

View File

@ -14,7 +14,9 @@
-- <https://xmonad.org/TUTORIAL.html xmonad website>. -- <https://xmonad.org/TUTORIAL.html xmonad website>.
-- --
-- For more detailed instructions on extending xmonad with the -- For more detailed instructions on extending xmonad with the
-- xmonad-contrib library, see "XMonad.Doc.Extending". -- xmonad-contrib library, see
-- <https://xmonad.org/TUTORIAL.html the tutorial>
-- and "XMonad.Doc.Extending".
-- --
----------------------------------------------------------------------------- -----------------------------------------------------------------------------

View File

@ -86,7 +86,7 @@ customize the window manager to fit her needs.
Basically, xmonad and the xmonad-contrib libraries let users write Basically, xmonad and the xmonad-contrib libraries let users write
their own window manager in just a few lines of code. While their own window manager in just a few lines of code. While
@~\/.xmonad\/xmonad.hs@ at first seems to be simply a configuration @xmonad.hs@ at first seems to be simply a configuration
file, it is actually a complete Haskell program which uses the xmonad file, it is actually a complete Haskell program which uses the xmonad
and xmonad-contrib libraries to create a custom window manager. and xmonad-contrib libraries to create a custom window manager.
@ -106,13 +106,13 @@ manager you are writing in any way you see fit.
xmonad installs a binary, @xmonad@, which must be executed by the xmonad installs a binary, @xmonad@, which must be executed by the
Xsession starting script. This binary, whose code can be read in Xsession starting script. This binary, whose code can be read in
@Main.hs@ of the xmonad source tree, will use 'XMonad.Core.recompile' @Main.hs@ of the xmonad source tree, will use 'XMonad.Core.recompile'
to run @ghc@ in order to build a binary from @~\/.xmonad\/xmonad.hs@. to run @ghc@ in order to build a binary from @xmonad.hs@.
If this compilation process fails, for any reason, a default @main@ If this compilation process fails, for any reason, a default @main@
entry point will be used, which calls the 'XMonad.Main.xmonad' entry point will be used, which calls the 'XMonad.Main.xmonad'
function with a default configuration. function with a default configuration.
Thus, the real @main@ entry point, the one that even the users' custom Thus, the real @main@ entry point, the one that even the users' custom
window manager application in @~\/.xmonad\/xmonad.hs@ must call, is window manager application in @xmonad.hs@ must call, is
the 'XMonad.Main.xmonad' function. This function takes a configuration the 'XMonad.Main.xmonad' function. This function takes a configuration
as its only argument, whose type ('XMonad.Core.XConfig') as its only argument, whose type ('XMonad.Core.XConfig')
is defined in "XMonad.Core". is defined in "XMonad.Core".

View File

@ -71,20 +71,15 @@ module XMonad.Doc.Extending
-- *** Removing key bindings -- *** Removing key bindings
-- $keyDel -- $keyDel
-- *** Adding and removing key bindings
-- $keyAddDel
-- ** Editing mouse bindings -- ** Editing mouse bindings
-- $mouse -- $mouse
-- ** Editing the layout hook -- ** Editing the layout hook #LayoutHook#
-- $layoutHook -- $layoutHook
-- ** Editing the manage hook -- ** Editing the manage hook #ManageHook#
-- $manageHook -- $manageHook
-- ** The log hook and external status bars
-- $logHook
) where ) where
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -108,8 +103,8 @@ For more information about any particular module, go to the root of
the documentation and just click on its name to view its Haddock the documentation and just click on its name to view its Haddock
documentation; each module should come with extensive documentation. documentation; each module should come with extensive documentation.
If you find a module that could be better documented, or has incorrect If you find a module that could be better documented, or has incorrect
documentation, please report it as a bug documentation, please
(<https://github.com/xmonad/xmonad-contrib/issues>)! <https://github.com/xmonad/xmonad-contrib/issues report it as a bug>!
First and foremost, xmonad defines its own prelude for commonly used First and foremost, xmonad defines its own prelude for commonly used
functions, as well as re-exports from @base@. functions, as well as re-exports from @base@.
@ -137,33 +132,31 @@ A list of the contrib modules can be found at
In the @XMonad.Actions@ namespace you can find modules exporting In the @XMonad.Actions@ namespace you can find modules exporting
various functions that are usually intended to be bound to key various functions that are usually intended to be bound to key
combinations or mouse actions, in order to provide functionality combinations or mouse actions, in order to provide functionality
beyond the standard keybindings provided by xmonad. beyond the standard keybindings offered by xmonad.
-} -}
{- $hooks {- $hooks
In the @XMonad.Hooks@ namespace you can find modules exporting In the @XMonad.Hooks@ namespace you can find modules exporting
hooks. Hooks are actions that xmonad performs when certain events hooksactions that xmonad performs when certain events occur.
occur. The three most important hooks are: The three most important hooks are:
* 'XMonad.Core.manageHook': this hook is called when a new window that * 'XMonad.Core.manageHook': this hook is called when a new window that
xmonad must take care of is created. This is a very powerful hook, xmonad must take care of is created. This is a very powerful hook,
since it lets us examine the new window's properties and act since it lets us examine the new window's properties and act
accordingly. For instance, we can configure xmonad to put windows accordingly. For instance, we can configure xmonad to put windows
belonging to a given application in the float layer, not to manage belonging to a given application in the float layer, not to manage
dock applications, or open them in a given workspace. See dock applications, or open them in a given workspace. See [Editing the
"XMonad.Doc.Extending#Editing_the_manage_hook" for more information manage hook](#g:Editing_the_manage_hook) for more information on
on customizing 'XMonad.Core.manageHook'. customizing 'XMonad.Core.manageHook'.
* 'XMonad.Core.logHook': this hook is called when the stack of windows * 'XMonad.Core.logHook': this hook is called when the stack of windows
managed by xmonad has been changed; for example, this is invoked at managed by xmonad changes; for example, this is invoked at the end of
the end of the 'XMonad.Operations.windows' function. For instance the 'XMonad.Operations.windows' function. A big application for this
"XMonad.Hooks.DynamicLog" will produce a string (whose format can be is to display some information about xmonad in a status bar. The aptly
configured) to be printed to the standard output. This can be used named "XMonad.Hooks.StatusBar" will produce a string (whose format can
to display some information about the xmonad state in a status bar. be configured) to be written, for example, to an X11 property.
See "XMonad.Doc.Extending#The_log_hook_and_external_status_bars" for
more information.
* 'XMonad.Core.handleEventHook': this hook is called on all events handled * 'XMonad.Core.handleEventHook': this hook is called on all events handled
by xmonad, thus it is extremely powerful. See "Graphics.X11.Xlib.Extras" by xmonad, thus it is extremely powerful. See "Graphics.X11.Xlib.Extras"
@ -187,13 +180,13 @@ interface for writing layout modifiers is implemented in
"XMonad.Layout.LayoutModifier". "XMonad.Layout.LayoutModifier".
For more information on using those modules for customizing your For more information on using those modules for customizing your
'XMonad.Core.layoutHook' see "XMonad.Doc.Extending#Editing_the_layout_hook". 'XMonad.Core.layoutHook' see [Editing the layout hook](#g:LayoutHook).
-} -}
{- $prompts {- $prompts
In the @XMonad.Prompt@ name space you can find modules providing In the @XMonad.Prompt@ namespace you can find modules providing
graphical prompts for getting user input and using it to perform graphical prompts for getting user input and using it to perform
various actions. various actions.
@ -206,7 +199,7 @@ prompts.
In the @XMonad.Util@ namespace you can find modules exporting various In the @XMonad.Util@ namespace you can find modules exporting various
utility functions that are used by the other modules of the utility functions that are used by the other modules of the
xmonad-contrib library. @xmonad-contrib@ library.
There are also utilities for helping in configuring xmonad or using There are also utilities for helping in configuring xmonad or using
external utilities. external utilities.
@ -222,7 +215,7 @@ external utilities.
{- $extending {- $extending
#Extending_xmonad# #Extending_xmonad#
Since the @xmonad.hs@ file is just another Haskell module, you may Since the @xmonad.hs@ file is just another Haskell program, you may
import and use any Haskell code or libraries you wish, such as import and use any Haskell code or libraries you wish, such as
extensions from the xmonad-contrib library, or other code you write extensions from the xmonad-contrib library, or other code you write
yourself. yourself.
@ -388,83 +381,74 @@ extend xmonad an scratch a particular itch!
{- $keyDel {- $keyDel
#Removing_key_bindings# #Removing_key_bindings#
Removing key bindings requires modifying the 'Data.Map.Strict.Map' which As we've learned, XMonad stores keybindings inside of a
stores the key bindings. This can be done with 'Data.Map.difference' or 'Data.Map.Strict.Map', which means that removing keybindings requires
with 'Data.Map.Strict.delete'. modifying it. This can be done with 'Data.Map.difference' or with
'Data.Map.Strict.delete'.
For example, suppose you want to get rid of @mod-q@ and @mod-shift-q@ For example, suppose you want to entirely rid yourself of @"M-q"@ and
(you just want to leave xmonad running forever). To do this you need to @"M-s-q"@ (you just want to leave xmonad running forever). To do this
define @newKeys@ as a 'Data.Map.Strict.difference' between the default with bare @xmonad@, you need to define @newKeys@ as a
map and the map of the key bindings you want to remove. Like so: 'Data.Map.Strict.difference' between the default map and the map of the
key bindings you want to remove. Like so:
> newKeys x = keys def x `M.difference` keysToRemove x > newKeys :: XConfig l -> Map (KeyMask, KeySym) (X ())
> newKeys x = keys def x `M.difference` keysToRemove x
> >
> keysToRemove :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ()) > keysToRemove :: XConfig l -> Map (KeyMask, KeySym) (X ())
> keysToRemove x = M.fromList > keysToRemove x = M.fromList
> [ ((modm , xK_q ), return ()) > [ ((modm , xK_q ), return ())
> , ((modm .|. shiftMask, xK_q ), return ()) > , ((modm .|. shiftMask, xK_q ), return ())
> ] > ]
As you can see, it doesn't matter what actions we associate with the As you can see, it doesn't matter what actions we associate with the
keys listed in @keysToRemove@, so we just use @return ()@ (the keys listed in @keysToRemove@, so we just use @return ()@ (the \"null\"
\"null\" action). action). Since @newKeys@ contains all of the default keys, you can
simply pass it to 'XMonad.Core.XConfig' as your map of keybindings:
It is also possible to simply define a list of keys we want to unbind > main :: IO ()
and then use 'Data.Map.Strict.delete' to remove them. In that case we > main = xmonad $ def { keys = newKeys }
would write something like:
> newKeys x = foldr M.delete (keys def x) (keysToRemove x) However, having to manually type @return ()@ every time seems like a
> drag, doesn't it? And this approach isn't at all compatible with adding
> keysToRemove :: XConfig Layout -> [(KeyMask, KeySym)] custom keybindings via 'XMonad.Util.EZConfig.additionalKeysP'! Well,
> keysToRemove x = good thing "XMonad.Util.EZConfig" also sports
> [ (modm , xK_q ) 'XMonad.Util.EZConfig.removeKeysP'. You can use it as you would expect.
> , (modm .|. shiftMask, xK_q )
> ]
Another even simpler possibility is the use of some of the utilities > main :: IO ()
provided by the xmonad-contrib library. Look, for instance, at > main = xmonad $ def
'XMonad.Util.EZConfig.removeKeys'. > { }
> `removeKeysP` ["M-q", "M-S-q"]
-} Can you guess how 'XMonad.Util.EZConfig.removeKeysP' works? It's almost
the same code we wrote above, just accepting a list of keybindings. Try
to see if you can come up with an implementation of
{- $keyAddDel > removeKeysP :: XConfig l -> [String] -> XConfig l
#Adding_and_removing_key_bindings#
Adding and removing key bindings requires simply combining the steps If you're done, just click on @# Source@ when viewing the
for removing and adding. Here is an example from 'XMonad.Util.EZConfig.removeKeysP' documentation (did you know that
"XMonad.Config.Arossato": Haddock lets you do that for every function?) and compare.
> defKeys = keys def By the way, one can conveniently combine
> delKeys x = foldr M.delete (defKeys x) (toRemove x) 'XMonad.Util.EZConfig.additionalKeysP' and
> newKeys x = foldr (uncurry M.insert) (delKeys x) (toAdd x) 'XMonad.Util.EZConfig.removeKeysP' by just intuitively chaining them:
> -- remove some of the default key bindings
> toRemove XConfig{modMask = modm} =
> [ (modm , xK_j )
> , (modm , xK_k )
> , (modm , xK_p )
> , (modm .|. shiftMask, xK_p )
> , (modm .|. shiftMask, xK_q )
> , (modm , xK_q )
> ] ++
> -- I want modm .|. shiftMask 1-9 to be free!
> [(shiftMask .|. modm, k) | k <- [xK_1 .. xK_9]]
> -- These are my personal key bindings
> toAdd XConfig{modMask = modm} =
> [ ((modm , xK_F12 ), xmonadPrompt def )
> , ((modm , xK_F3 ), shellPrompt def )
> ] ++
> -- Use modm .|. shiftMask .|. controlMask 1-9 instead
> [( (m .|. modm, k), windows $ f i)
> | (i, k) <- zip (workspaces x) [xK_1 .. xK_9]
> , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask .|. controlMask)]
> ]
You can achieve the same result using the "XMonad.Util.CustomKeys" > main :: IO ()
module; take a look at the 'XMonad.Util.CustomKeys.customKeys' > main = xmonad $ def
function in particular. > { }
> `additionalKeysP myKeys
> `removeKeysP` ["M-q", "M-S-q"]
If you don't use the @P@ alternatives of EZConfig, there is also an
aptly named 'XMonad.Util.EZConfig.removeKeys'. Again, can you try to
come up with an implementation yourself that has the correct signature?
> removeKeys :: XConfig a -> [(KeyMask, KeySym)] -> XConfig a
In addition to 'Data.Map.Strict.delete', you will probably need to use
'foldr'.
NOTE: modm is defined as the modMask you defined (or left as the default) in
your config.
-} -}
{- $mouse {- $mouse
@ -506,8 +490,7 @@ xmonad will use for laying out windows on the screen(s).
The problem is that the layout subsystem is implemented with an The problem is that the layout subsystem is implemented with an
advanced feature of the Haskell programming language: type classes. advanced feature of the Haskell programming language: type classes.
This allows us to very easily write new layouts, combine or modify This allows us to very easily write new layouts, combine or modify
existing layouts, create layouts with internal state, etc. See existing layouts, create layouts with internal state, etc. This
"XMonad.Doc.Extending#The_LayoutClass" for more information. This
means that we cannot simply have a list of layouts: a list requires means that we cannot simply have a list of layouts: a list requires
every member to belong to the same type! every member to belong to the same type!
@ -517,7 +500,7 @@ with a specific layout combinator: 'XMonad.Layout.|||'.
Suppose we want a list with the 'XMonad.Layout.Full', Suppose we want a list with the 'XMonad.Layout.Full',
'XMonad.Layout.Tabbed.tabbed' and 'XMonad.Layout.Tabbed.tabbed' and
'XMonad.Layout.Accordion.Accordion' layouts. First we import, in our 'XMonad.Layout.Accordion.Accordion' layouts. First we import, in our
@~\/.xmonad\/xmonad.hs@, all the needed modules: @xmonad.hs@, all the needed modules:
> import XMonad > import XMonad
> >
@ -546,7 +529,7 @@ If we want only the tabbed layout without borders, then we may write:
> mylayoutHook = Full ||| noBorders (tabbed shrinkText def) ||| Accordion > mylayoutHook = Full ||| noBorders (tabbed shrinkText def) ||| Accordion
Our @~\/.xmonad\/xmonad.hs@ will now look like this: Our @xmonad.hs@ will now look like this:
> import XMonad > import XMonad
> >
@ -711,42 +694,3 @@ For additional rules and actions you can use in your manageHook, check
out the contrib module "XMonad.Hooks.ManageHelpers". out the contrib module "XMonad.Hooks.ManageHelpers".
-} -}
{- $logHook
#The_log_hook_and_external_status_bars#
When the stack of the windows managed by xmonad changes for any
reason, xmonad will call 'XMonad.Core.logHook', which can be used to
output some information about the internal state of xmonad, such as the
layout that is presently in use, the workspace we are in, the focused
window's title, and so on.
Extracting information about the internal xmonad state can be somewhat
difficult if you are not familiar with the source code. Therefore,
it's usually easiest to use a module that has been designed
specifically for logging some of the most interesting information
about the internal state of xmonad: "XMonad.Hooks.DynamicLog". This
module can be used with an external status bar to print the produced
logs in a convenient way; the most commonly used status bars are dzen
and xmobar. The module "XMonad.Hooks.StatusBar" offers another interface
to interact with status bars, that might be more convenient to use.
By default the 'XMonad.Core.logHook' doesn't produce anything. To
enable it you need first to import "XMonad.Hooks.DynamicLog":
> import XMonad.Hooks.DynamicLog
Then you just need to update the 'XMonad.Core.logHook' field of the
'XMonad.Core.XConfig' record with one of the provided functions. For
example:
> main = xmonad def { logHook = dynamicLog }
More interesting configurations are also possible; see the
"XMonad.Hooks.DynamicLog" module for more possibilities.
You may now enjoy your extended xmonad experience.
Have fun!
-}

View File

@ -22,14 +22,15 @@ module XMonad.Hooks.CurrentWorkspaceOnTop (
currentWorkspaceOnTop currentWorkspaceOnTop
) where ) where
import qualified Data.List.NonEmpty as NE (nonEmpty)
import qualified Data.Map as M
import XMonad import XMonad
import XMonad.Prelude (NonEmpty ((:|)), when)
import qualified XMonad.StackSet as S import qualified XMonad.StackSet as S
import qualified XMonad.Util.ExtensibleState as XS import qualified XMonad.Util.ExtensibleState as XS
import XMonad.Prelude (unless, when)
import qualified Data.Map as M
-- $usage -- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: -- You can use this module with the following in your @xmonad.hs@:
-- --
-- > import XMonad.Hooks.CurrentWorkspaceOnTop -- > import XMonad.Hooks.CurrentWorkspaceOnTop
-- > -- >
@ -63,7 +64,9 @@ currentWorkspaceOnTop = withDisplay $ \d -> do
wins = fltWins ++ map fst rs -- order: first all floating windows, then the order the layout returned wins = fltWins ++ map fst rs -- order: first all floating windows, then the order the layout returned
-- end of reimplementation -- end of reimplementation
unless (null wins) $ do case NE.nonEmpty wins of
io $ raiseWindow d (head wins) -- raise first window of current workspace to the very top, Nothing -> pure ()
io $ restackWindows d wins -- then use restackWindows to let all other windows from the workspace follow Just (w :| ws') -> do
io $ raiseWindow d w -- raise first window of current workspace to the very top,
io $ restackWindows d (w : ws') -- then use restackWindows to let all other windows from the workspace follow
XS.put(CWOTS curTag) XS.put(CWOTS curTag)

View File

@ -33,16 +33,16 @@ import XMonad.Util.DebugWindow (debugWindow)
-- import Graphics.X11.Xlib.Extras.GetAtomName (getAtomName) -- import Graphics.X11.Xlib.Extras.GetAtomName (getAtomName)
import Control.Exception as E import Control.Exception as E
import Control.Monad.Fail
import Control.Monad.State import Control.Monad.State
import Control.Monad.Reader import Control.Monad.Reader
import Codec.Binary.UTF8.String import Codec.Binary.UTF8.String
import Foreign import Foreign hiding (void)
import Foreign.C.Types import Foreign.C.Types
import Numeric (showHex) import Numeric (showHex)
import System.Exit import System.Exit
import System.IO import System.IO
import System.Process import System.Process
import GHC.Stack (HasCallStack, prettyCallStack, callStack)
-- | Event hook to dump all received events. You should probably not use this -- | Event hook to dump all received events. You should probably not use this
-- unconditionally; it will produce massive amounts of output. -- unconditionally; it will produce massive amounts of output.
@ -203,7 +203,7 @@ windowEvent l w = debugWindow w >>= say l
-- | Helper to emit tagged event information. -- | Helper to emit tagged event information.
say :: String -> String -> X () say :: String -> String -> X ()
say l s = trace $ l ++ ' ':s say l s = XMonad.trace $ l ++ ' ':s
-- | Deconstuct a list of 'CInt's into raw bytes -- | Deconstuct a list of 'CInt's into raw bytes
splitCInt :: [CInt] -> IO Raw splitCInt :: [CInt] -> IO Raw
@ -240,7 +240,7 @@ data DecodeState = DecS {value :: Raw -- unconsumed raw property value
} }
newtype Decoder a = Decoder (ReaderT Decode (StateT DecodeState X) a) newtype Decoder a = Decoder (ReaderT Decode (StateT DecodeState X) a)
#ifndef __HADDOCK__
deriving (Functor deriving (Functor
,Applicative ,Applicative
,Monad ,Monad
@ -249,12 +249,12 @@ newtype Decoder a = Decoder (ReaderT Decode (StateT DecodeState X) a)
,MonadState DecodeState ,MonadState DecodeState
,MonadReader Decode ,MonadReader Decode
) )
#endif
-- | Retrive, parse, and dump a window property. As all the high-level property -- | Retrive, parse, and dump a window property. As all the high-level property
-- interfaces lose information necessary to decode properties correctly, we -- interfaces lose information necessary to decode properties correctly, we
-- work at the lowest level available. -- work at the lowest level available.
dumpProperty :: Atom -> String -> Window -> Int -> X String dumpProperty :: HasCallStack => Atom -> String -> Window -> Int -> X String
dumpProperty a n w i = do dumpProperty a n w i = do
prop <- withDisplay $ \d -> prop <- withDisplay $ \d ->
io $ io $
@ -279,7 +279,7 @@ dumpProperty a n w i = do
case rc of case rc of
0 -> do 0 -> do
fmt <- fromIntegral <$> peek fmtp fmt <- fromIntegral <$> peek fmtp
vs' <- peek vsp vs' <- peek vsp
sz <- fromIntegral <$> peek szp sz <- fromIntegral <$> peek szp
case () of case () of
() | fmt == none -> xFree vs' >> return (Left "(property deleted)" ) () | fmt == none -> xFree vs' >> return (Left "(property deleted)" )
@ -303,7 +303,8 @@ dumpProperty a n w i = do
-- @@@ am I better off passing in the Decode and DecodeState? -- @@@ am I better off passing in the Decode and DecodeState?
-- | Parse and dump a property (or a 'ClientMessage'). -- | Parse and dump a property (or a 'ClientMessage').
dumpProperty' :: Window -- source window dumpProperty' :: HasCallStack
=> Window -- source window
-> Atom -- property id -> Atom -- property id
-> String -- property name -> String -- property name
-> Atom -- property type -> Atom -- property type
@ -334,11 +335,11 @@ dumpProperty' w a n fmt sz vs ack i = do
(_,ds') <- runDecode dec ds $ dumpProp a n (_,ds') <- runDecode dec ds $ dumpProp a n
let fin = length (value ds') let fin = length (value ds')
len = length vs len = length vs
lost = if ack == 0 then "" else "and " ++ show ack ++ " lost bytes" lost = if ack == 0 then "" else " and " ++ show ack ++ " lost bytes"
unk = case () of unk = case () of
() | fin == len -> "undecodeable " () | fin == len -> "undecodeable "
| fin == 0 -> "." | fin == 0 -> "."
| otherwise -> "and remainder (" ++ show (len - fin) ++ '/':show len ++ ")" | otherwise -> " and remainder (" ++ show (len - fin) ++ '/':show len ++ ")"
(_,ds'') <- if fin == 0 (_,ds'') <- if fin == 0
then return (True,ds') then return (True,ds')
else runDecode dec' (withJoint' unk ds' ) $ dumpArray dump8 else runDecode dec' (withJoint' unk ds' ) $ dumpArray dump8
@ -349,7 +350,7 @@ dumpProperty' w a n fmt sz vs ack i = do
-- | A simplified version of 'dumpProperty\'', to format random values from -- | A simplified version of 'dumpProperty\'', to format random values from
-- events. -- events.
quickFormat :: (Storable i, Integral i) => [i] -> Decoder Bool -> X String quickFormat :: (HasCallStack, Storable i, Integral i) => [i] -> Decoder Bool -> X String
quickFormat v f = do quickFormat v f = do
let vl = length v let vl = length v
vs <- io $ vs <- io $
@ -382,7 +383,7 @@ bytes w = w `div` 8
-- | The top level property decoder, for a wide variety of standard ICCCM and -- | The top level property decoder, for a wide variety of standard ICCCM and
-- EWMH window properties. We pass part of the 'ReaderT' as arguments for -- EWMH window properties. We pass part of the 'ReaderT' as arguments for
-- pattern matching. -- pattern matching.
dumpProp :: Atom -> String -> Decoder Bool dumpProp :: HasCallStack => Atom -> String -> Decoder Bool
dumpProp _ "CLIPBOARD" = dumpSelection dumpProp _ "CLIPBOARD" = dumpSelection
dumpProp _ "_NET_SUPPORTED" = dumpArray dumpAtom dumpProp _ "_NET_SUPPORTED" = dumpArray dumpAtom
@ -426,10 +427,13 @@ dumpProp _ "_NET_WM_NAME" = dumpUTF
dumpProp _ "_NET_WM_VISIBLE_NAME" = dumpUTF dumpProp _ "_NET_WM_VISIBLE_NAME" = dumpUTF
dumpProp _ "_NET_WM_ICON_NAME" = dumpUTF dumpProp _ "_NET_WM_ICON_NAME" = dumpUTF
dumpProp _ "_NET_WM_VISIBLE_ICON_NAME" = dumpUTF dumpProp _ "_NET_WM_VISIBLE_ICON_NAME" = dumpUTF
dumpProp _ "_NET_WM_DESKTOP" = dumpExcept [(0xFFFFFFFF,"all")] -- @@@ the property is CARDINAL; the message is _NET_WM_DESKTOP of 5 dump32s
dump32 -- [desktop/all, source indication, 3 zeroes]
-- dumpProp _ "_NET_WM_DESKTOP" = dumpExcept [(0xFFFFFFFF,"all")]
-- dump32
dumpProp _ "_NET_WM_DESKTOP" = dumpSetDesktop
dumpProp _ "_NET_WM_WINDOW_TYPE" = dumpArray dumpAtom dumpProp _ "_NET_WM_WINDOW_TYPE" = dumpArray dumpAtom
dumpProp _ "_NET_WM_STATE" = dumpArray dumpAtom dumpProp _ "_NET_WM_STATE" = dumpNWState
dumpProp _ "_NET_WM_ALLOWED_ACTIONS" = dumpArray dumpAtom dumpProp _ "_NET_WM_ALLOWED_ACTIONS" = dumpArray dumpAtom
dumpProp _ "_NET_WM_STRUT" = dumpList [("left gap" ,dump32) dumpProp _ "_NET_WM_STRUT" = dumpList [("left gap" ,dump32)
,("right gap" ,dump32) ,("right gap" ,dump32)
@ -467,6 +471,12 @@ dumpProp _ "_NET_FRAME_EXTENTS" = dumpList [("left" ,dum
] ]
dumpProp _ "_NET_WM_SYNC_REQUEST_COUNTER" = dumpExcept [(0,"illegal value 0")] dumpProp _ "_NET_WM_SYNC_REQUEST_COUNTER" = dumpExcept [(0,"illegal value 0")]
dump64 dump64
dumpProp _ "_NET_WM_OPAQUE_REGION" = dumpArray $ dumpList [("x",dump32)
,("y",dump32)
,("w",dump32)
,("h",dump32)
]
dumpProp _ "_NET_WM_BYPASS_COMPOSITOR" = dumpEnum cpState
dumpProp _ "_NET_STARTUP_ID" = dumpUTF dumpProp _ "_NET_STARTUP_ID" = dumpUTF
dumpProp _ "WM_PROTOCOLS" = dumpArray dumpAtom dumpProp _ "WM_PROTOCOLS" = dumpArray dumpAtom
dumpProp _ "WM_COLORMAP_WINDOWS" = dumpArray dumpWindow dumpProp _ "WM_COLORMAP_WINDOWS" = dumpArray dumpWindow
@ -521,8 +531,8 @@ dumpProp a _ | a == wM_NAME = dumpString
] ]
) )
] ]
| a == wM_NORMAL_HINTS = (...) | a == wM_NORMAL_HINTS = dumpSizeHints
| a == wM_ZOOM_HINTS = (...) -- same as previous | a == wM_ZOOM_HINTS = dumpSizeHints
| a == rGB_DEFAULT_MAP = (...) -- XStandardColormap | a == rGB_DEFAULT_MAP = (...) -- XStandardColormap
| a == rGB_BEST_MAP = (...) -- " | a == rGB_BEST_MAP = (...) -- "
| a == rGB_RED_MAP = (...) -- " | a == rGB_RED_MAP = (...) -- "
@ -567,12 +577,12 @@ withIndent :: Int -> Decoder a -> Decoder a
withIndent w = local (\r -> r {indent = indent r + w}) withIndent w = local (\r -> r {indent = indent r + w})
-- dump an array of items. this dumps the entire property -- dump an array of items. this dumps the entire property
dumpArray :: Decoder Bool -> Decoder Bool dumpArray :: HasCallStack => Decoder Bool -> Decoder Bool
dumpArray item = do dumpArray item = do
withIndent 1 $ append "[" >> withJoint "" (dumpArray' item "") withIndent 1 $ append "[" >> withJoint "" (dumpArray' item "")
-- step through values as an array, ending on parse error or end of list -- step through values as an array, ending on parse error or end of list
dumpArray' :: Decoder Bool -> String -> Decoder Bool dumpArray' :: HasCallStack => Decoder Bool -> String -> Decoder Bool
dumpArray' item pfx = do dumpArray' item pfx = do
vs <- gets value vs <- gets value
if null vs if null vs
@ -582,12 +592,12 @@ dumpArray' item pfx = do
-- keep parsing until a parse step fails -- keep parsing until a parse step fails
-- @@@ which points out that all my uses of @whenX (return ...)@ are actually 'when', -- @@@ which points out that all my uses of @whenX (return ...)@ are actually 'when',
-- which suggests that 'whenX' is *also* the same function... yep. ISAGN -- which suggests that 'whenX' is *also* the same function... yep. ISAGN
whenD :: Monad m => m Bool -> m Bool -> m Bool whenD :: (HasCallStack, Monad m) => m Bool -> m Bool -> m Bool
whenD p f = p >>= \b -> if b then f else return False whenD p f = p >>= \b -> if b then f else return False
-- verify a decoder parameter, else call error reporter -- verify a decoder parameter, else call error reporter
-- once again, it's more general than I originally wrote -- once again, it's more general than I originally wrote
guardR :: (MonadReader r m, Eq v) guardR :: (HasCallStack, MonadReader r m, Eq v)
=> (r -> v) -- value selector => (r -> v) -- value selector
-> v -- expected value -> v -- expected value
-> (v -> v -> m a) -- error reporter -> (v -> v -> m a) -- error reporter
@ -598,43 +608,47 @@ guardR sel val err good = do
if v == val then good else err v val if v == val then good else err v val
-- this is kinda dumb -- this is kinda dumb
fi :: Bool -> a -> a -> a fi :: HasCallStack => Bool -> a -> a -> a
fi p n y = if p then y else n -- flip (if' p), if that existed fi p n y = if p then y else n -- flip (if' p), if that existed
-- verify we have the expected word size -- verify we have the expected word size
guardSize :: Int -> Decoder Bool -> Decoder Bool guardSize :: HasCallStack => Int -> Decoder Bool -> Decoder Bool
-- see XSync documentation for this insanity -- see XSync documentation for this insanity
guardSize 64 = guardR width 32 propSizeErr . guardSize' 8 propShortErr guardSize 64 = guardR width 32 propSizeErr . guardSize' 8 (propShortErr' 1)
guardSize w = guardR width w propSizeErr . guardSize' (bytes w) propShortErr guardSize w = guardR width w propSizeErr . guardSize' (bytes w) (propShortErr' 2)
guardSize' :: Int -> Decoder a -> Decoder a -> Decoder a guardSize' :: HasCallStack => Int -> Decoder a -> Decoder a -> Decoder a
guardSize' l n y = gets value >>= \vs -> fi (length vs >= l) n y guardSize' l n y = gets value >>= \vs -> fi (length vs >= bytes l) n y
-- @guardSize@ doesn't work with empty arrays
guardSize'' :: HasCallStack => Int -> Decoder a -> Decoder a -> Decoder a
guardSize'' l n y = gets value >>= \vs -> fi (null vs || length vs >= bytes l) n y
-- verify we have the expected property type -- verify we have the expected property type
guardType :: Atom -> Decoder Bool -> Decoder Bool guardType :: HasCallStack => Atom -> Decoder Bool -> Decoder Bool
guardType t = guardR pType t propTypeErr guardType t = guardR pType t propTypeErr
-- dump a structure as a named tuple -- dump a structure as a named tuple
dumpList :: [(String,Decoder Bool)] -> Decoder Bool dumpList :: HasCallStack => [(String,Decoder Bool)] -> Decoder Bool
dumpList proto = do dumpList proto = do
a <- asks pType a <- asks pType
dumpList'' (maxBound :: CULong) (map (\(s,d) -> (s,d,a)) proto) "(" dumpList'' (maxBound :: CULong) (map (\(s,d) -> (s,d,a)) proto) "("
-- same but elements have their own distinct types -- same but elements have their own distinct types
dumpList' :: [(String,Decoder Bool,Atom)] -> Decoder Bool dumpList' :: HasCallStack => [(String,Decoder Bool,Atom)] -> Decoder Bool
dumpList' proto = dumpList'' (maxBound :: CULong) proto "(" dumpList' proto = dumpList'' (maxBound :: CULong) proto "("
-- same but only dump elements identified by provided mask -- same but only dump elements identified by provided mask
dumpListByMask :: CULong -> [(String,Decoder Bool)] -> Decoder Bool dumpListByMask :: HasCallStack => CULong -> [(String,Decoder Bool)] -> Decoder Bool
dumpListByMask m p = do dumpListByMask m p = do
a <- asks pType a <- asks pType
dumpList'' m (map (\(s,d) -> (s,d,a)) p) "(" dumpList'' m (map (\(s,d) -> (s,d,a)) p) "("
-- and the previous two combined -- and the previous two combined
dumpListByMask' :: CULong -> [(String,Decoder Bool,Atom)] -> Decoder Bool dumpListByMask' :: HasCallStack => CULong -> [(String,Decoder Bool,Atom)] -> Decoder Bool
dumpListByMask' m p = dumpList'' m p "(" dumpListByMask' m p = dumpList'' m p "("
dumpList'' :: CULong -> [(String,Decoder Bool,Atom)] -> String -> Decoder Bool dumpList'' :: HasCallStack => CULong -> [(String,Decoder Bool,Atom)] -> String -> Decoder Bool
dumpList'' _ [] _ = append ")" >> return True dumpList'' _ [] _ = append ")" >> return True
dumpList'' 0 _ _ = append ")" >> return True dumpList'' 0 _ _ = append ")" >> return True
dumpList'' m ((l,p,t):ps) sep = do dumpList'' m ((l,p,t):ps) sep = do
@ -659,22 +673,20 @@ dumpList'' m ((l,p,t):ps) sep = do
-- do the getTextProperty dance, the hard way. -- do the getTextProperty dance, the hard way.
-- @@@ @COMPOUND_TEXT@ not supported yet. -- @@@ @COMPOUND_TEXT@ not supported yet.
dumpString :: Decoder Bool dumpString :: HasCallStack => Decoder Bool
dumpString = do dumpString = do
fmt <- asks pType fmt <- asks pType
[cOMPOUND_TEXT,uTF8_STRING] <- inX $ mapM getAtom ["COMPOUND_TEXT","UTF8_STRING"] [cOMPOUND_TEXT,uTF8_STRING] <- inX $ mapM getAtom ["COMPOUND_TEXT","UTF8_STRING"]
case () of case () of
() | fmt == cOMPOUND_TEXT -> guardSize 16 (...) () | fmt == cOMPOUND_TEXT -> guardSize'' 16 (propShortErr' 3) ( ... )
| fmt == sTRING -> guardSize 8 $ do | fmt == sTRING -> guardSize'' 8 (propShortErr' 4) $ do
vs <- gets value vs <- gets value
modify (\r -> r {value = []}) modify (\r -> r {value = []})
let ss = flip unfoldr (map twiddle vs) $ let ss = flip unfoldr (map twiddle vs) $
\s -> if null s \s -> if null s
then Nothing then Nothing
else let (w,s'') = break (== '\NUL') s else let (w,s'') = break (== '\NUL') s
s' = if null s'' s' = drop 1 s''
then s''
else tail s''
in Just (w,s') in Just (w,s')
case ss of case ss of
[s] -> append $ show s [s] -> append $ show s
@ -688,7 +700,7 @@ dumpString = do
failure . ("unrecognized string type " ++) failure . ("unrecognized string type " ++)
-- show who owns a selection -- show who owns a selection
dumpSelection :: Decoder Bool dumpSelection :: HasCallStack => Decoder Bool
dumpSelection = do dumpSelection = do
-- system selections contain a window ID; others are random -- system selections contain a window ID; others are random
-- note that the window ID will be the same as the owner, so -- note that the window ID will be the same as the owner, so
@ -702,14 +714,14 @@ dumpSelection = do
append $ "owned by " ++ w append $ "owned by " ++ w
-- for now, not querying Xkb -- for now, not querying Xkb
dumpXKlInds :: Decoder Bool dumpXKlInds :: HasCallStack => Decoder Bool
dumpXKlInds = guardType iNTEGER $ do dumpXKlInds = guardType iNTEGER $ do
n <- fmap fromIntegral <$> getInt' 32 n <- fmap fromIntegral <$> getInt' 32
case n of case n of
Nothing -> propShortErr Nothing -> propShortErr' 5
Just is -> append $ "indicators " ++ unwords (dumpInds is 1 1 []) Just is -> append $ "indicators " ++ unwords (dumpInds is 1 1 [])
where where
dumpInds :: Word32 -> Word32 -> Int -> [String] -> [String] dumpInds :: HasCallStack => Word32 -> Word32 -> Int -> [String] -> [String]
dumpInds n bt c bs | n == 0 && c == 1 = ["none"] dumpInds n bt c bs | n == 0 && c == 1 = ["none"]
| n == 0 = bs | n == 0 = bs
| n .&. bt /= 0 = dumpInds (n .&. complement bt) | n .&. bt /= 0 = dumpInds (n .&. complement bt)
@ -722,9 +734,20 @@ dumpXKlInds = guardType iNTEGER $ do
bs bs
-- decode an Atom -- decode an Atom
dumpAtom :: Decoder Bool
dumpAtom = dumpAtom :: HasCallStack => Decoder Bool
guardType aTOM $ do dumpAtom = dumpAtom'' aTOM
{-
dumpAtom' :: HasCallStack => String -> Decoder Bool
dumpAtom' t' = do
t <- inX $ getAtom t'
dumpAtom'' t
-}
dumpAtom'' :: HasCallStack => Atom -> Decoder Bool
dumpAtom'' t =
guardType t $ do
a <- getInt' 32 a <- getInt' 32
case a of case a of
Nothing -> return False Nothing -> return False
@ -732,15 +755,16 @@ dumpAtom =
an <- inX $ atomName $ fromIntegral a' an <- inX $ atomName $ fromIntegral a'
append an append an
dumpWindow :: Decoder Bool dumpWindow :: HasCallStack => Decoder Bool
dumpWindow = guardSize 32 $ guardType wINDOW $ do dumpWindow = guardSize 32 $ guardType wINDOW $ do
w <- getInt' 32 w <- getInt' 32
case w of case w of
Nothing -> return False Nothing -> return False
Just 0 -> append "none"
Just w' -> inX (debugWindow (fromIntegral w')) >>= append Just w' -> inX (debugWindow (fromIntegral w')) >>= append
-- a bit of a hack; as a Property it's a wINDOW, as a ClientMessage it's a list -- a bit of a hack; as a Property it's a wINDOW, as a ClientMessage it's a list
dumpActiveWindow :: Decoder Bool dumpActiveWindow :: HasCallStack => Decoder Bool
dumpActiveWindow = guardSize 32 $ do dumpActiveWindow = guardSize 32 $ do
t <- asks pType t <- asks pType
nAW <- inX $ getAtom "_NET_ACTIVE_WINDOW" nAW <- inX $ getAtom "_NET_ACTIVE_WINDOW"
@ -754,49 +778,87 @@ dumpActiveWindow = guardSize 32 $ do
t' <- inX $ atomName t t' <- inX $ atomName t
failure $ concat ["(bad type " failure $ concat ["(bad type "
,t' ,t'
,"; expected WINDOW or _NET_ACTIVE_WINDOW" ,"; expected WINDOW or _NET_ACTIVE_WINDOW)"
] ]
-- likewise but for _NET_WM_DESKTOP
dumpSetDesktop :: HasCallStack => Decoder Bool
dumpSetDesktop = guardSize 32 $ do
t <- asks pType
nWD <- inX $ getAtom "_NET_WM_DESKTOP"
case () of
() | t == cARDINAL -> dumpExcept [(0xFFFFFFFF,"all")]
dump32
| t == nWD -> dumpList' [("desktop",dumpExcept [(0xFFFFFFFF,"all")]
dump32 ,cARDINAL)
,("source" ,dumpEnum awSource ,cARDINAL)
]
_ -> do
t' <- inX $ atomName t
failure $ concat ["(bad type "
,t'
,"; expected CARDINAL or _NET_WM_DESKTOP)"
]
-- and again for _NET_WM_STATE
dumpNWState :: HasCallStack => Decoder Bool
dumpNWState = guardSize'' 32 propShortErr $ do
t <- asks pType
nWS <- inX $ getAtom "_NET_WM_STATE"
case () of
() | t == aTOM -> dumpArray dumpAtom
| t == nWS -> dumpList' [("action",dumpEnum nwAction,cARDINAL)
,("atom1" ,dumpAtom ,aTOM)
,("atom2" ,dumpAtom ,aTOM)
]
_ -> do
t' <- inX $ atomName t
failure $ concat ["(bad type "
,t'
,"; expected ATOM or _NET_WM_STATE)"
]
-- dump a generic CARDINAL value -- dump a generic CARDINAL value
dumpInt :: Int -> Decoder Bool dumpInt :: HasCallStack => Int -> Decoder Bool
dumpInt w = guardSize w $ guardType cARDINAL $ getInt w show dumpInt w = guardSize w $ guardType cARDINAL $ getInt w show
-- INTEGER is the signed version of CARDINAL -- INTEGER is the signed version of CARDINAL
dumpInteger :: Int -> Decoder Bool dumpInteger :: HasCallStack => Int -> Decoder Bool
dumpInteger w = guardSize w $ guardType iNTEGER $ getInt w (show . signed w) dumpInteger w = guardSize w $ guardType iNTEGER $ getInt w (show . signed w)
-- reinterpret an unsigned as a signed -- reinterpret an unsigned as a signed
signed :: Int -> Integer -> Integer signed :: HasCallStack => Int -> Integer -> Integer
signed w i = bit (w + 1) - i signed w i = bit (w + 1) - i
-- and wrappers to keep the parse list in bounds -- and wrappers to keep the parse list in bounds
dump64 :: Decoder Bool dump64 :: HasCallStack => Decoder Bool
dump64 = dumpInt 64 dump64 = dumpInt 64
dump32 :: Decoder Bool dump32 :: HasCallStack => Decoder Bool
dump32 = dumpInt 32 dump32 = dumpInt 32
{- not used in standard properties {- not used in standard properties
dump16 :: Decoder Bool dump16 :: HasCallStack => Decoder Bool
dump16 = dumpInt 16 dump16 = dumpInt 16
-} -}
dump8 :: Decoder Bool dump8 :: HasCallStack => Decoder Bool
dump8 = dumpInt 8 dump8 = dumpInt 8
-- I am assuming for the moment that this is a single string. -- I am assuming for the moment that this is a single string.
-- This might be false; consider the way the STRING properties -- This might be false; consider the way the STRING properties
-- handle lists. -- handle lists.
dumpUTF :: Decoder Bool dumpUTF :: HasCallStack => Decoder Bool
dumpUTF = do dumpUTF = do
uTF8_STRING <- inX $ getAtom "UTF8_STRING" uTF8_STRING <- inX $ getAtom "UTF8_STRING"
guardType uTF8_STRING $ guardSize 8 $ do guardType uTF8_STRING $ guardSize'' 8 propShortErr $ do
s <- gets value s <- gets value
modify (\r -> r {value = []}) modify (\r -> r {value = []})
append . show . decode . map fromIntegral $ s append . show . decode . map fromIntegral $ s
return True return True
-- dump an enumerated value using a translation table -- dump an enumerated value using a translation table
dumpEnum' :: [String] -> Atom -> Decoder Bool dumpEnum' :: HasCallStack => [String] -> Atom -> Decoder Bool
dumpEnum' ss fmt = guardType fmt $ dumpEnum' ss fmt = guardType fmt $
getInt 32 $ getInt 32 $
\r -> case () of \r -> case () of
@ -805,11 +867,12 @@ dumpEnum' ss fmt = guardType fmt $
| otherwise -> genericIndex ss r | otherwise -> genericIndex ss r
-- we do not, unlike @xev@, try to ascii-art pixmaps. -- we do not, unlike @xev@, try to ascii-art pixmaps.
dumpPixmap :: Decoder Bool dumpPixmap :: HasCallStack => Decoder Bool
dumpPixmap = guardType pIXMAP $ do dumpPixmap = guardType pIXMAP $ do
p' <- getInt' 32 p' <- getInt' 32
case p' of case p' of
Nothing -> return False Nothing -> return False
Just 0 -> append "none"
Just p -> do Just p -> do
append $ "pixmap " ++ showHex p "" append $ "pixmap " ++ showHex p ""
g' <- inX $ withDisplay $ \d -> io $ g' <- inX $ withDisplay $ \d -> io $
@ -833,46 +896,80 @@ dumpPixmap = guardType pIXMAP $ do
,")" ,")"
] ]
dumpOLAttrs :: Decoder Bool dumpOLAttrs :: HasCallStack => Decoder Bool
dumpOLAttrs = do dumpOLAttrs = do
pt <- inX $ getAtom "_OL_WIN_ATTR" pt <- inX $ getAtom "_OL_WIN_ATTR"
guardType pt $ do guardType pt $ do
msk <- getInt' 32 msk <- getInt' 32
case msk of case msk of
Nothing -> propShortErr Nothing -> propShortErr' 7
Just msk' -> dumpListByMask (fromIntegral msk') [("window type" ,dumpAtom ) Just msk' -> dumpListByMask (fromIntegral msk') [("window type" ,dumpAtom )
,("menu" ,dump32 ) -- @@@ unk ,("menu" ,dump32 ) -- @@@ unk
,("pushpin" ,dumpEnum bool) ,("pushpin" ,dumpEnum bool)
,("limited menu",dump32 ) -- @@@ unk ,("limited menu",dump32 ) -- @@@ unk
] ]
dumpMwmHints :: Decoder Bool dumpMwmHints :: HasCallStack => Decoder Bool
dumpMwmHints = do dumpMwmHints = do
ta <- asks property ta <- asks property
guardType ta $ do guardType ta $ do
msk <- getInt' 32 msk <- getInt' 32
case msk of case msk of
Nothing -> propShortErr Nothing -> propShortErr' 8
Just msk' -> dumpListByMask (fromIntegral msk') [("functions" ,dumpBits mwmFuncs ) Just msk' -> dumpListByMask' (fromIntegral msk') [("functions" ,dumpBits mwmFuncs ,cARDINAL)
,("decorations",dumpBits mwmDecos ) ,("decorations",dumpBits mwmDecos ,cARDINAL)
,("input mode" ,dumpEnum mwmInputMode) ,("input mode" ,dumpEnum mwmInputMode,cARDINAL) -- @@@ s/b iNTEGER?
,("status" ,dumpBits mwmState ) ,("status" ,dumpBits mwmState ,cARDINAL)
] ]
dumpMwmInfo :: Decoder Bool dumpMwmInfo :: HasCallStack => Decoder Bool
dumpMwmInfo = do dumpMwmInfo = do
ta <- asks property ta <- asks property
guardType ta $ dumpList' [("flags" ,dumpBits mwmHints,cARDINAL) guardType ta $ dumpList' [("flags" ,dumpBits mwmHints,cARDINAL)
,("window",dumpWindow ,wINDOW ) ,("window",dumpWindow ,wINDOW )
] ]
dumpSizeHints :: HasCallStack => Decoder Bool
dumpSizeHints = do
guardType wM_SIZE_HINTS $ do
-- flags, 4 unused CARD32s, fields as specified by flags
msk <- fmap fromIntegral <$> getInt' 32
eat (4 * 4) >> pure False
case msk of
Nothing -> propShortErr' 9
Just msk' -> dumpListByMask' msk' [("min size" ,dumpSize ,cARDINAL)
,("max size" ,dumpSize ,cARDINAL)
,("increment" ,dumpSize ,cARDINAL)
,("aspect ratio",dumpAspect,cARDINAL)
,("base size" ,dumpSize ,cARDINAL)
,("gravity" ,dumpGrav ,cARDINAL)
]
dumpSize :: HasCallStack => Decoder Bool
dumpSize = append "(" >> dump32 >> append "," >> dump32 >> append ")"
dumpAspect :: HasCallStack => Decoder Bool
dumpAspect = do
-- have to do this manually since it doesn't really fit
append "min = "
dump32
append "/"
dump32
append ", max = "
dump32
append "/"
dump32
dumpGrav :: HasCallStack => Decoder Bool
dumpGrav = dumpEnum wmGravity
-- the most common case -- the most common case
dumpEnum :: [String] -> Decoder Bool dumpEnum :: HasCallStack => [String] -> Decoder Bool
dumpEnum ss = dumpEnum' ss cARDINAL dumpEnum ss = dumpEnum' ss cARDINAL
-- implement exceptional cases atop a normal dumper -- implement exceptional cases atop a normal dumper
-- @@@ there's gotta be a better way -- @@@ there's gotta be a better way
dumpExcept :: [(Integer,String)] -> Decoder Bool -> Decoder Bool dumpExcept :: HasCallStack => [(Integer,String)] -> Decoder Bool -> Decoder Bool
dumpExcept xs item = do dumpExcept xs item = do
-- this horror brought to you by reparsing to get the right value for our use -- this horror brought to you by reparsing to get the right value for our use
sp <- get sp <- get
@ -887,7 +984,8 @@ dumpExcept xs item = do
-- and after all that, we can process the exception list -- and after all that, we can process the exception list
dumpExcept' xs that v dumpExcept' xs that v
dumpExcept' :: [(Integer,String)] dumpExcept' :: HasCallStack
=> [(Integer,String)]
-> DecodeState -> DecodeState
-> Integer -> Integer
-> Decoder Bool -> Decoder Bool
@ -897,7 +995,7 @@ dumpExcept' ((exc,str):xs) that val | exc == val = append str
-- use @ps@ to get process information. -- use @ps@ to get process information.
-- @@@@ assumes a POSIX @ps@, not a BSDish one. -- @@@@ assumes a POSIX @ps@, not a BSDish one.
dumpPid :: Decoder Bool dumpPid :: HasCallStack => Decoder Bool
dumpPid = guardType cARDINAL $ do dumpPid = guardType cARDINAL $ do
n <- getInt' 32 n <- getInt' 32
case n of case n of
@ -915,17 +1013,17 @@ dumpPid = guardType cARDINAL $ do
then "pid " ++ pid then "pid " ++ pid
else prc !! 1 else prc !! 1
dumpTime :: Decoder Bool dumpTime :: HasCallStack => Decoder Bool
dumpTime = append "server event # " >> dump32 dumpTime = append "server event # " >> dump32
dumpState :: Decoder Bool dumpState :: HasCallStack => Decoder Bool
dumpState = do dumpState = do
wM_STATE <- inX $ getAtom "WM_STATE" wM_STATE <- inX $ getAtom "WM_STATE"
guardType wM_STATE $ dumpList' [("state" ,dumpEnum wmState,cARDINAL) guardType wM_STATE $ dumpList' [("state" ,dumpEnum wmState,cARDINAL)
,("icon window",dumpWindow ,wINDOW ) ,("icon window",dumpWindow ,wINDOW )
] ]
dumpMotifDragReceiver :: Decoder Bool dumpMotifDragReceiver :: HasCallStack => Decoder Bool
dumpMotifDragReceiver = do dumpMotifDragReceiver = do
ta <- inX $ getAtom "_MOTIF_DRAG_RECEIVER_INFO" ta <- inX $ getAtom "_MOTIF_DRAG_RECEIVER_INFO"
guardType ta $ dumpList' [("endian" ,dumpMotifEndian,cARDINAL) guardType ta $ dumpList' [("endian" ,dumpMotifEndian,cARDINAL)
@ -933,11 +1031,11 @@ dumpMotifDragReceiver = do
,("style" ,dumpMDropStyle ,cARDINAL) -- @@@ dummy ,("style" ,dumpMDropStyle ,cARDINAL) -- @@@ dummy
] ]
dumpMDropStyle :: Decoder Bool dumpMDropStyle :: HasCallStack => Decoder Bool
dumpMDropStyle = do dumpMDropStyle = do
d <- getInt' 8 d <- getInt' 8
pad 1 $ case d of pad 1 $ case d of
Nothing -> propShortErr Nothing -> propShortErr' 9
Just ps | ps == 0 -> pad 12 $ append "none" Just ps | ps == 0 -> pad 12 $ append "none"
| ps == 1 -> pad 12 $ append "drop only" | ps == 1 -> pad 12 $ append "drop only"
| ps == 2 -> append "prefer preregister " >> dumpMDPrereg | ps == 2 -> append "prefer preregister " >> dumpMDPrereg
@ -947,7 +1045,7 @@ dumpMDropStyle = do
| ps == 6 -> pad 12 $ append "prefer receiver" | ps == 6 -> pad 12 $ append "prefer receiver"
| otherwise -> failure $ "unknown drop style " ++ show ps | otherwise -> failure $ "unknown drop style " ++ show ps
dumpMDPrereg :: Decoder Bool dumpMDPrereg :: HasCallStack => Decoder Bool
dumpMDPrereg = do dumpMDPrereg = do
-- this is a bit ugly; we pretend to be extending the above dumpList' -- this is a bit ugly; we pretend to be extending the above dumpList'
append "," append ","
@ -957,7 +1055,7 @@ dumpMDPrereg = do
append "drop sites = " append "drop sites = "
dsc' <- getInt' 16 dsc' <- getInt' 16
case dsc' of case dsc' of
Nothing -> propShortErr Nothing -> propShortErr' 10
Just dsc -> do Just dsc -> do
withIndent 13 $ append (show dsc) withIndent 13 $ append (show dsc)
pad 2 $ do pad 2 $ do
@ -969,7 +1067,7 @@ dumpMDPrereg = do
dumpMDBlocks :: Int -> Decoder Bool dumpMDBlocks :: Int -> Decoder Bool
dumpMDBlocks _ = propSimple "(drop site info)" -- @@@ maybe later if needed dumpMDBlocks _ = propSimple "(drop site info)" -- @@@ maybe later if needed
dumpMotifEndian :: Decoder Bool dumpMotifEndian :: HasCallStack => Decoder Bool
dumpMotifEndian = guardType cARDINAL $ guardSize 8 $ do dumpMotifEndian = guardType cARDINAL $ guardSize 8 $ do
c <- map twiddle <$> eat 1 c <- map twiddle <$> eat 1
case c of case c of
@ -977,14 +1075,14 @@ dumpMotifEndian = guardType cARDINAL $ guardSize 8 $ do
['B'] -> append "big" ['B'] -> append "big"
_ -> failure "bad endian flag" _ -> failure "bad endian flag"
pad :: Int -> Decoder Bool -> Decoder Bool pad :: HasCallStack => Int -> Decoder Bool -> Decoder Bool
pad n p = do pad n p = do
vs <- gets value vs <- gets value
if length vs < n if length vs < n
then propShortErr then propShortErr' 11
else modify (\r -> r {value = drop n vs}) >> p else modify (\r -> r {value = drop n vs}) >> p
dumpPercent :: Decoder Bool dumpPercent :: HasCallStack => Decoder Bool
dumpPercent = guardType cARDINAL $ do dumpPercent = guardType cARDINAL $ do
n <- getInt' 32 n <- getInt' 32
case n of case n of
@ -994,7 +1092,7 @@ dumpPercent = guardType cARDINAL $ do
pct :: Double pct :: Double
in append $ show (round pct :: Integer) ++ "%" in append $ show (round pct :: Integer) ++ "%"
dumpWmHints :: Decoder Bool dumpWmHints :: HasCallStack => Decoder Bool
dumpWmHints = dumpWmHints =
guardType wM_HINTS $ do guardType wM_HINTS $ do
msk <- getInt' 32 msk <- getInt' 32
@ -1011,7 +1109,7 @@ dumpWmHints =
,("window_group" ,dumpWindow ,wINDOW ) ,("window_group" ,dumpWindow ,wINDOW )
] ]
dumpBits :: [String] -> Decoder Bool dumpBits :: HasCallStack => [String] -> Decoder Bool
dumpBits bs = guardType cARDINAL $ do dumpBits bs = guardType cARDINAL $ do
n <- getInt' 32 n <- getInt' 32
case n of case n of
@ -1069,6 +1167,9 @@ awSource = ["unspecified"
,"pager/task list" ,"pager/task list"
] ]
cpState :: [String]
cpState = ["no preference","disable compositing","force compositing"]
{- eventually... {- eventually...
wmHintsFlags :: [String] wmHintsFlags :: [String]
wmHintsFlags = ["Input" wmHintsFlags = ["Input"
@ -1112,6 +1213,12 @@ nwmOrigin = nwmEnum Nothing ["TOPLEFT","TOPRIGHT","BOTTOMRIGHT","BOTTOMLEFT"]
wmState :: [String] wmState :: [String]
wmState = ["Withdrawn","Normal","Zoomed (obsolete)","Iconified","Inactive"] wmState = ["Withdrawn","Normal","Zoomed (obsolete)","Iconified","Inactive"]
nwAction :: [String]
nwAction = ["Clear", "Set", "Toggle"]
wmGravity :: [String]
wmGravity = ["forget/unmap","NW","N","NE","W","C","E","SW","S","SE","static"]
nwmEnum :: Maybe String nwmEnum :: Maybe String
-> [String] -> [String]
-> [String] -> [String]
@ -1121,7 +1228,7 @@ nwmEnum (Just prefix) vs = map (("_NET_WM_" ++ prefix ++ "_") ++) vs
-- and the lowest level coercions -- -- and the lowest level coercions --
-- parse and return an integral value -- parse and return an integral value
getInt' :: Int -> Decoder (Maybe Integer) getInt' :: HasCallStack => Int -> Decoder (Maybe Integer)
-- see XSync documentation for this insanity -- see XSync documentation for this insanity
getInt' 64 = guardR width 32 (\a e -> propSizeErr a e >> return Nothing) $ getInt' 64 = guardR width 32 (\a e -> propSizeErr a e >> return Nothing) $
guardSize' 8 (propShortErr >> return Nothing) $ do guardSize' 8 (propShortErr >> return Nothing) $ do
@ -1129,7 +1236,7 @@ getInt' 64 = guardR width 32 (\a e -> propSizeErr a e >> return Nothing) $
hi <- inhale 32 hi <- inhale 32
return $ Just $ lo + hi * (fromIntegral (maxBound :: Word32) + 1) return $ Just $ lo + hi * (fromIntegral (maxBound :: Word32) + 1)
getInt' w = guardR width w (\a e -> propSizeErr a e >> return Nothing) $ getInt' w = guardR width w (\a e -> propSizeErr a e >> return Nothing) $
guardSize' (bytes w) (propShortErr >> return Nothing) $ guardSize' (bytes w) (propShortErr' 13 >> return Nothing) $
Just <$> inhale w Just <$> inhale w
-- parse an integral value and feed it to a show-er of some kind -- parse an integral value and feed it to a show-er of some kind
@ -1171,8 +1278,8 @@ append :: String -> Decoder Bool
append = append' True append = append' True
-- and the same but for errors -- and the same but for errors
failure :: String -> Decoder Bool failure :: HasCallStack => String -> Decoder Bool
failure = append' False failure = append' False . (++ prettyCallStack callStack)
-- common appender -- common appender
append' :: Bool -> String -> Decoder Bool append' :: Bool -> String -> Decoder Bool
@ -1186,9 +1293,13 @@ propSimple :: String -> Decoder Bool
propSimple s = modify (\r -> r {value = []}) >> append s propSimple s = modify (\r -> r {value = []}) >> append s
-- report various errors -- report various errors
propShortErr :: Decoder Bool propShortErr :: HasCallStack => Decoder Bool
propShortErr = failure "(property ended prematurely)" propShortErr = failure "(property ended prematurely)"
-- debug version
propShortErr' :: HasCallStack => Int -> Decoder Bool
propShortErr' n = failure $ "(short prop " ++ show n ++ ")"
propSizeErr :: Int -> Int -> Decoder Bool propSizeErr :: Int -> Int -> Decoder Bool
propSizeErr e a = failure $ "(bad bit width " ++ propSizeErr e a = failure $ "(bad bit width " ++
show a ++ show a ++

View File

@ -51,9 +51,8 @@ import System.IO (hPutStrLn
-- the key; @mask@ is raw, and @clean@ is what @xmonad@ sees after -- the key; @mask@ is raw, and @clean@ is what @xmonad@ sees after
-- sanitizing it (removing @numberLockMask@, etc.) -- sanitizing it (removing @numberLockMask@, etc.)
-- --
-- For more detailed instructions on editing the logHook see: -- For more detailed instructions on editing the logHook see
-- -- <https://xmonad.org/TUTORIAL.html#make-xmonad-and-xmobar-talk-to-each-other the tutorial>.
-- "XMonad.Doc.Extending#The_log_hook_and_external_status_bars"
-- | Print key events to stderr for debugging -- | Print key events to stderr for debugging
debugKeyEvents :: Event -> X All debugKeyEvents :: Event -> X All

Some files were not shown because too many files have changed in this diff Show More