Skip to content

Commit

Permalink
feat(config): add idle.unidle_on_focus
Browse files Browse the repository at this point in the history
  • Loading branch information
vyfor committed Dec 24, 2024
1 parent 6bd56b5 commit f4e8c93
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
3 changes: 2 additions & 1 deletion lua/cord/activity/manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,8 @@ function ActivityManager:on_focus_gained()
if not self.events_enabled then return end
self.is_focused = true
self.opts.is_focused = true
self:queue_update(true)

if self.config.idle.unidle_on_focus then self:queue_update(true) end
end

---Handle focus lost event
Expand Down
2 changes: 2 additions & 0 deletions lua/cord/util/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
---@field timeout? integer Idle timeout in milliseconds
---@field show_status? boolean Whether to show idle status
---@field ignore_focus? boolean Whether to show idle when editor is focused
---@field unidle_on_focus? boolean Whether to unidle the session when editor gains focus
---@field smart_idle? boolean Whether to enable smart idle feature
---@field details? string|fun(opts: CordOpts):string Details shown when idle
---@field state? string|fun(opts: CordOpts):string State shown when idle
Expand Down Expand Up @@ -112,6 +113,7 @@ M.values = {
timeout = 300000,
show_status = true,
ignore_focus = true,
unidle_on_focus = true,
smart_idle = true,
details = 'Idling',
state = nil,
Expand Down
23 changes: 12 additions & 11 deletions wiki/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,18 @@ require('cord').setup {

## 💤 Idle

| Option | Type | Default | Description |
| ------------------- | -------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| `idle.enabled` | `boolean` | `true` | Enable idle status detection |
| `idle.timeout` | `number` | `300000` | Milliseconds before marking the session as idle |
| `idle.show_status` | `boolean` | `true` | Show idle status in presence, or hide the presence if `false` |
| `idle.ignore_focus` | `boolean` | `true` | Show idle when Neovim is focused |
| `idle.smart_idle` | `boolean` | `true` | Enable [smart idle](#smart-idle) feature |
| `idle.details` | `string \| function(opts)` | `'Idling'` | Details shown when idle |
| `idle.state` | `string \| function(opts)` | `nil` | State shown when idle |
| `idle.tooltip` | `string \| function(opts)` | `'💤'` | Tooltip shown when hovering over idle icon |
| `idle.icon` | `string \| function(opts)` | [`default idle icon`](https://github.com/vyfor/icons/blob/master/icons/onyx/idle.png) | Custom icon URL or asset ID |
| Option | Type | Default | Description |
| ---------------------- | -------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| `idle.enabled` | `boolean` | `true` | Enable idle status detection |
| `idle.timeout` | `number` | `300000` | Milliseconds before marking the session as idle |
| `idle.show_status` | `boolean` | `true` | Show idle status in presence, or hide the presence if `false` |
| `idle.ignore_focus` | `boolean` | `true` | Show idle despite Neovim having focus |
| `idle.unidle_on_focus` | `boolean` | `true` | Unidle the session when Neovim gains focus |
| `idle.smart_idle` | `boolean` | `true` | Enable [smart idle](#smart-idle) feature |
| `idle.details` | `string \| function(opts)` | `'Idling'` | Details shown when idle |
| `idle.state` | `string \| function(opts)` | `nil` | State shown when idle |
| `idle.tooltip` | `string \| function(opts)` | `'💤'` | Tooltip shown when hovering over idle icon |
| `idle.icon` | `string \| function(opts)` | [`default idle icon`](https://github.com/vyfor/icons/blob/master/icons/onyx/idle.png) | Custom icon URL or asset ID |

## 📝 Text & Assets

Expand Down

0 comments on commit f4e8c93

Please sign in to comment.