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

[Req] Command to query the current temperature value #3

Open
kRHYME7 opened this issue Oct 10, 2024 · 7 comments
Open

[Req] Command to query the current temperature value #3

kRHYME7 opened this issue Oct 10, 2024 · 7 comments

Comments

@kRHYME7
Copy link

kRHYME7 commented Oct 10, 2024

Helps to make some tools around this. Like a UI with values displayed. Also, easier to index current temperature.

👍🏽 Much better is to have a CLI for this tool to increase, decrease the temp.

🐒

@vaxerski
Copy link
Member

what

@kRHYME7
Copy link
Author

kRHYME7 commented Oct 10, 2024

Helps to make some tools around this. Like a UI with values displayed. Also, easier to index current temperature.

Command to query the current temperature value so we can store it as a state. By that, we can use it to output it to, e.g. waybar.

@kRHYME7 kRHYME7 changed the title [Req] Query current temp [Req] Command to query the current temperature value Oct 10, 2024
@vaxerski
Copy link
Member

but it's just whatever you configured hyprsunset to? why not keep track of it yourself?

@kRHYME7
Copy link
Author

kRHYME7 commented Oct 11, 2024

Yes, that would be an option. If one creates a script for it, they could write it to a file or a FIFO upon committing the temperature with hyprsunset -t 5000 > $file. In my opinion, it's not really optimal and would need some additional logic to be robust.

Sorry for my ignorance, but aren't there options to query the temperature value of the current running daemon? The approach mentioned might lose track of the temperature. It's not a big deal, but this would be more optimal—hopefully without overcomplicating the logic of hyprsunset. If that’s the case, I’ll just consider the option above.

I have another concern: to avoid multiple instances of hyprsunset, is the best way to do it by using killall hyprsunset and then setting the temperature? Something like this: killall hyprsunset; hyprsunset -t $temp?

This will be helpful in creating a knob/slider GUI.

@vaxerski
Copy link
Member

yes. hyprsunse for now has no ipc

@htho1
Copy link

htho1 commented Nov 4, 2024

Can you not just make hyprsunset -t echo the current value? This is how I expected it to behave, and it makes the most sense in my opinion.

@ysxninja
Copy link

Yes, that would be an option. If one creates a script for it, they could write it to a file or a FIFO upon committing the temperature with hyprsunset -t 5000 > $file. In my opinion, it's not really optimal and would need some additional logic to be robust.

Sorry for my ignorance, but aren't there options to query the temperature value of the current running daemon? The approach mentioned might lose track of the temperature. It's not a big deal, but this would be more optimal—hopefully without overcomplicating the logic of hyprsunset. If that’s the case, I’ll just consider the option above.

I have another concern: to avoid multiple instances of hyprsunset, is the best way to do it by using killall hyprsunset and then setting the temperature? Something like this: killall hyprsunset; hyprsunset -t $temp?

This will be helpful in creating a knob/slider GUI.

Heres a quick workaround for waybar,

bluelighttoggle.sh

#!/bin/sh

# Check if hyprsunset is running using pgrep
pid=$(pgrep -x hyprsunset)

if [ -z "$pid" ]; then
  # If not running, start hyprsunset with the specified temperature
  hyprsunset -t 5700 &
  echo "hyprsunset started with temperature 5700"
else
  # If running, kill hyprsunset
  kill "$pid"
  echo "hyprsunset stopped"
fi

bluelightinfo.sh

#!/bin/sh

# Check if hyprsunset is running
pid=$(pgrep -x hyprsunset)

# Set temperature based on whether hyprsunset is running or not
if [ -z "$pid" ]; then
  # If hyprsunset is not running, default temperature is 6500K
  temperature=6500
else
  # If hyprsunset is running, temperature is 5700K
  temperature=5700
fi

# Format the output for Waybar with line breaks
formatted_output="Temperature: $temperature"

# Check if the temperature is greater than or equal to 6500K
if [ "$temperature" -ge 6500 ]; then
  # Output as JSON for Waybar, escaping newlines
  echo "{\"text\": \"\", \"tooltip\": \"$formatted_output\"}"
else
  # Otherwise, output a different icon for lower temperature
  echo "{\"text\": \"󰽥\", \"tooltip\": \"$formatted_output\"}"
fi

Waybar

  "custom/hyprsunset-temperature": {
    "format": " {} ",
    "exec": "$HOME/.local/bin/bluelightinfo.sh",
    "tooltip": true,
    "interval": 1,
    "return-type": "json",
    "on-click": "$HOME/.local/bin/bluelighttoggle.sh"
  },

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

4 participants