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

Problem with brightness, volume-pulseaudio and usb scripts. #434

Open
apoorv569 opened this issue Aug 12, 2020 · 12 comments
Open

Problem with brightness, volume-pulseaudio and usb scripts. #434

apoorv569 opened this issue Aug 12, 2020 · 12 comments

Comments

@apoorv569
Copy link

apoorv569 commented Aug 12, 2020

I'm using i3block with all the sample scripts that are provided here, the brightness script outputs as 41.025641%, is there a way to output it as an int like 41%?,for the volume-pulseaudio script, is there a way to just show volume percentage rather than the volume percentage and the sink, while still having the mouse click features to change output and mute. like it shows icon 10% [0:analog-stereo] and the usb script is not working when I try to run it in the shell by doing ./usb it gives me this error

❯ ./usb
Unknown device "/dev/└─/dev/sda": No such file or directory
Traceback (most recent call last):
  File "./usb", line 361, in <module>
    attributeMaps = getAttributeMaps(leaves)
  File "./usb", line 263, in getAttributeMaps
    return {path : makeAttributeMap(path) for path in paths}
  File "./usb", line 263, in <dictcomp>
    return {path : makeAttributeMap(path) for path in paths}
  File "./usb", line 252, in makeAttributeMap
    lines = check_output(
  File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.8/subprocess.py", line 512, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['udevadm', 'info', '--query=property', '--name=└─/dev/sda']' returned non-zero exit status 1.

I'm using this on a laptop, having so many blocks on the bar can fill up pretty fast on a small resolution like 1366x768.

@zsugabubus
Copy link

zsugabubus commented Aug 12, 2020

If you have an issue with the scripts and you even link the repository to them, why do not you report your issue there?


volume-pulseaudio script, is there a way to just show volume percentage rather than the volume percentage and the sink

According to README:

# i3blocks/config
[volume]
LONG_FORMAT=${VOL}%
SHORT_FORMAT=${VOL}%
# ...

the brightness script outputs as 41.025641%, is there a way to output it as an int like 41%?

usb script is not working

diff --git a/backlight/backlight b/backlight/backlight
index fe774ff..21415d2 100755
--- a/backlight/backlight
+++ b/backlight/backlight
@@ -38,4 +38,4 @@ esac


 BRIGHTNESS=$(xbacklight -get)
-echo "${BRIGHTNESS}%"
+printf '%.f%%\n' "$BRIGHTNESS"
diff --git a/usb/usb b/usb/usb
index f74f0e4..9df3161 100755
--- a/usb/usb
+++ b/usb/usb
@@ -95,17 +95,17 @@ def pangoEscape(text):
     return text.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")

 def getLeafDevicePaths():
-    lines = check_output(['lsblk', '-spndo', 'NAME'], universal_newlines=True)
+    lines = check_output(['lsblk', '-lspndo', 'NAME'], universal_newlines=True)
     lines = lines.split("\n")
     lines = filter(None, lines)
     return lines

 def getKernelName(path):
-    return check_output(['lsblk', '-ndso', 'KNAME', path],
+    return check_output(['lsblk', '-lndso', 'KNAME', path],
             universal_newlines=True).rstrip("\n")

 def getDeviceType(path):
-    return check_output(['lsblk', '-no', 'TYPE', path],
+    return check_output(['lsblk', '-lno', 'TYPE', path],
             universal_newlines=True).strip()

 def getFSType(path):

(Updated.)

@apoorv569
Copy link
Author

apoorv569 commented Aug 12, 2020

If you have an issue with the scripts and you even link the repository to them, why do not you report your issue there?

All the scripts I mentioned here are from this repository only, where I am reporting the issue right now.

According to README:

i3blocks/config
[volume]
LONG_FORMAT=${VOL}%
SHORT_FORMAT=${VOL}%

Yea, I have tried using the SHORT_FORMAT doesn't do anything.
Peek 2020-08-12 21-02

For the brightness script doing

-echo "${BRIGHTNESS}%"
+printf '%.f%%' "$BRIGHTNESS"

doesn't show the brightness block anymore. As you can see in the above GIF its showing before the audio, and after editing the script you can see in the below GIF its now showing.

For the USB, the script is working now, after adding what you said, but its not showing anything on the bar.
Peek 2020-08-12 21-20

I have my own scripts for Volume, brightness and usb that I made for, when I was using DWM, the brightness that I wrote is also for some reason showing float point output instead of int, It was working fine, I don't know what's wrong with it now, and the audio script that I wrote, just shows my volume, and doesn't have features like click to change source and all, as for the usb script that I wrote, it just shows a icon, when a usb is connected. I can use them I know, but the little extra functionality these scripts are providing I need those features.

@zsugabubus
Copy link

zsugabubus commented Aug 12, 2020

All the scripts I mentioned here are from this repository only, where I am reporting the issue right now.

We are at i3blocks. And the scripts reside under i3blocks-contib, no? I do not get it.

Yea, I have tried using the SHORT_FORMAT doesn't do anything.

Try LONG_FORMAT, too. That’s the primary.

They must be passed as environment variables to the script that only the latest i3blocks can do, so check i3blocks -V and make sure it’s >=1.5. After all, if it does not want to work, just modify the script directly, or use command=env LONG_FORMAT=$VOL% ....

For the brightness script doing […] doesn't show the brightness block anymore

(Just a silly sanity check but you have removed the “+” before that line, yup?)


Try running i3blocks >/dev/null from terminal. Maybe you got some syntax errors or anything else that could help debugging.

@apoorv569
Copy link
Author

apoorv569 commented Aug 12, 2020

We are at i3blocks. And the scripts reside under i3blocks-contib, no? I do not get it.

Yes, Sorry did not notice that.

Try LONG_FORMAT, too. That’s the primary.

OK, using the LONG_FORMAT works.

(Just a silly sanity check but you have removed the “+” before that line, yup?)

Yes I have removed the + before adding printf.

Try running i3blocks >/dev/null from terminal. Maybe you got some syntax errors or anything else that could help debugging.

Running i3blocks > /dev/null doesn't output anything.

Also I have noticed, the arch-update script is also not working. I have updates available, but it does not show up on the bar.

@zsugabubus
Copy link

For the brightness script doing […] doesn't show the brightness block anymore.

Aaarrggh! Needs trailing new-line.

printf '%.f%%\n' "$BRIGHTNESS"

Also I have noticed, the arch-update script is also not working.

That uses unmaintained yoaurt, guess you do not have installed that. If you do not need any fancy things I can share my own pacman block. (You can even put it into your i3blocks/config as a one-liner.)

@apoorv569
Copy link
Author

Yes, \n was missing, I didn't noticed it either 😛. It's working now.

That uses unmaintained yoaurt, guess you do not have installed that. If you do not need any fancy things I can share my own pacman block. (You can even put it into your i3blocks/config as a one-liner.)

Fancy things like?

@zsugabubus
Copy link

Fancy things like?

Dunno… clicking or such maybe… It just displays the number of updates and that’s it.

@apoorv569
Copy link
Author

Fancy things like?

Dunno… clicking or such maybe… It just displays the number of updates and that’s it.

It's fine I don't need clicking functionality. And what about the battery2 module, Is there a way to not show timeleft when not plugged in.

@zsugabubus
Copy link

Is there a way to not show timeleft when not plugged in.

What about deleting fulltext += timeleft line at the end?

@apoorv569
Copy link
Author

Is there a way to not show timeleft when not plugged in.

What about deleting fulltext += timeleft line at the end?

Yes, that did it, and for the memory module, can I just show the used ram, instead of used/total used%

And please do share you pacman update script. Does your script also shows updates for the AUR?

@zsugabubus
Copy link

diff --git a/memory/memory b/memory/memory
index 90eb2c6..470366c 100755
--- a/memory/memory
+++ b/memory/memory
@@ -52,10 +52,7 @@ END {
        }

        # full text
-       printf("%.1fG/%.1fG (%.f%%)\n", used, total, pct)
-
-       # short text
-       printf("%.f%%\n", pct)
+       printf("%.1fG\n", used)

        # color
        if (pct > 90) {

And please do share you pacman update script.

Link is already at the comment.

Does your script also shows updates for the AUR?

No. But depending on what you are using to manage such packages it is just a matter of a simple addition.

@apoorv569
Copy link
Author

apoorv569 commented Aug 12, 2020

diff --git a/memory/memory b/memory/memory
index 90eb2c6..470366c 100755
--- a/memory/memory
+++ b/memory/memory
@@ -52,10 +52,7 @@ END {
        }

        # full text
-       printf("%.1fG/%.1fG (%.f%%)\n", used, total, pct)
-
-       # short text
-       printf("%.f%%\n", pct)
+       printf("%.1fG\n", used)

        # color
        if (pct > 90) {

And please do share you pacman update script.

Link is already at the comment.

Does your script also shows updates for the AUR?

No. But depending on what you are using to manage such packages it is just a matter of a simple addition.

Thanks! memory module is good now, And I managed to fix the arch-update module, there were 3 instance of yaourt I replaced it withyay, its not adding the the number of AUR updates in the module, but its at least showing on the bar now. Bar looks much more manageable now.

2020-08-13_05-12

Only the USB module is not working now.

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