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

Menus #296

Open
sfs-pra opened this issue Dec 27, 2024 · 8 comments
Open

Menus #296

sfs-pra opened this issue Dec 27, 2024 · 8 comments

Comments

@sfs-pra
Copy link
Contributor

sfs-pra commented Dec 27, 2024

Set Menu1 = "1"
menuclear("menu_name")
menu ("menu_name") {
    item("item", Set Menu1 = "2")
  }
}

layout {
  label {
    value = $Menu1 
    action = menu "menu_name"
  }
}

How to make “1” change to “2” when you click on “item”

@LBCrion
Copy link
Owner

LBCrion commented Dec 30, 2024 via email

@sfs-pra
Copy link
Contributor Author

sfs-pra commented Dec 30, 2024

With the new functionality you can use expressions in menus, so:

sfwbar-git-r1725.4627ccb - It works
Trying to put it into practice :

Function("SfwbarInit") {
    PipeRead "sfwbar-hwmon.sh"

cat sfwbar-hwmon.sh

#!/bin/sh
echo 'set Hwmon = "'$(ls /sys/class/hwmon/ |tail -n1)'"'
echo '
  file("/sys/class/hwmon/" + $Hwmon + "/temp1_input") {
    CPUTemp = Grab()
  }
'
echo 'menu ("menu_name") {'
for i in `ls /sys/class/hwmon/` ;do
    echo 'item("'$i'", Eval "Hwmon", "'$i'")'
done
echo '}'

doesn't work

item("item save", Exec ("echo 1 > /tmp/sfwbar.ini"))
It's not working either.

value = Exec ("cat /sys/class/hwmon/hwmon" + $Menu1 +"/temp1_input")
It's not working either.
How do you make the “hwmon” selection?

@LBCrion
Copy link
Owner

LBCrion commented Dec 30, 2024 via email

@sfs-pra
Copy link
Contributor Author

sfs-pra commented Dec 30, 2024

Try PipeRead "sh /path/to/sfwbar-hwmon.sh"

No improvement

post the output of the script

set Hwmon = "hwmon2"

  file("/sys/class/hwmon/" + $Hwmon + "/temp1_input") {
    CPUTemp = Grab()
  }

menu ("menu_name") {
item("hwmon0", Eval "Hwmon", "hwmon0")
item("hwmon1", Eval "Hwmon", "hwmon1")
item("hwmon2", Eval "Hwmon", "hwmon2")
}

@LBCrion
Copy link
Owner

LBCrion commented Dec 30, 2024 via email

@sfs-pra
Copy link
Contributor Author

sfs-pra commented Dec 31, 2024

Then for now, the only option left is to use menu to configure sfwbar
item("item save", Exec ("sh -c 'echo 1 > /tmp/sfwbar.ini ; killall -1 sfwbar'")) - works

Function("SfwbarInit") {
    PipeRead "sfwbar-hwmon.sh"
echo '
  file("/sys/class/hwmon/'$(cat /tmp/sfwbar.ini)'/temp1_input") {
    CPUTemp = Grab()
  }
'

@LBCrion
Copy link
Owner

LBCrion commented Dec 31, 2024 via email

@sfs-pra
Copy link
Contributor Author

sfs-pra commented Dec 31, 2024

There is a very hacks way to do this without reloading the config:

Good idea, but it is better to define HwmonXtemp via PipeRead, because on different hardware the amount of Hwmon can be different.

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

2 participants