Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom module update interval #101

Closed
lucky7xz opened this issue Dec 22, 2023 · 6 comments
Closed

Custom module update interval #101

lucky7xz opened this issue Dec 22, 2023 · 6 comments

Comments

@lucky7xz
Copy link

Hi. The .sh module below works fine, except that I cannot figure out how to have it update itself.

show_mem() {
local index=$1

local icon="$(get_tmux_option "@catppuccin_test_icon" "")"
local color="$(get_tmux_option "@catppuccin_test_color" "$thm_blue")"
var=$(free --giga | awk '/^Mem:/ {print $3 "/" $7 "/" $2 "GB"}')
local text="$(get_tmux_option "@catppuccin_test_text" $var)"

local module=$( build_status_module "$index" "$icon" "$color" "$text" )

echo "$module"
}

image

I also have the battery module which is updated frequently. My guess is that custom modules work a little different in this regard. I appreciate your time. Thank you.

@peterkracik
Copy link
Contributor

is there a way to refresh it when the window changes?
I created a module to show the current branch, but it shows the same value for all windows

@89iuv
Copy link
Collaborator

89iuv commented Jan 17, 2024

Currently you can not set a specific refresh interval per module.

The interval is set globally using:

set -g status-interval 1

Where "1" means 1 second.

@lucky7xz
Copy link
Author

lucky7xz commented Jan 20, 2024

@89iuv

Currently you can not set a specific refresh interval per module.

The interval is set globally using:

-g status-interval was set to 2. The problem is the the variable apparently.

local text="$(get_tmux_option "@catppuccin_test_text" "#(date +%s)")" works fine - updated every two seconds.

I am now trying to figure out how to pass the command directly into local text. Thank you.

@peterkracik You could maybe try to re-source the conf when you switch windows via key-bindings. There's like a 0.3-0.5 delay when re-sourcing on my machine. Could you share it if you make it work? :)

@Myzel394
Copy link

I am now trying to figure out how to pass the command directly into local text. Thank you.

@lucky7xz did you find a solution? I'm facing the same issue

@qadzek
Copy link
Contributor

qadzek commented Feb 23, 2024

I am now trying to figure out how to pass the command directly into local text. Thank you.

When building my own module, I also often encountered the issue of a "stale" value: the module wouldn't update automatically.

I would recommend to create a small companion script to take care of the var=$(free --giga | awk '/^Mem:/ {print $3 "/" $7 "/" $2 "GB"}') part. In the expert section of this guide you can find out more.

@sgoudham
Copy link
Contributor

sgoudham commented Mar 6, 2024

Closing as original question seems to have been answered.

@sgoudham sgoudham closed this as completed Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants