[SOLVED] customizing the statusbar dwmblock (DWM - Tiling Window Manager)
Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
No worries...as long as you're learning, you'll keep getting better. You're missing a space after the detected" and before the ]]. That should get rid of that message. And after thinking about it for a bit, try this instead:
Code:
if [[ "$(dmesg -S | tail | grep "usb-storage")" =~ "USB Mass Storage device detected" ]]; then
icon=" ��️ "
else
icon=""
fi
printf "%s%s\\n" "$icon"
...which will check for the presence of the string in what you get. That way, you can modify this to do different things if you plug in a mouse or some other USB device.
yes this is working. but the script that i sent after adding the space it didn't give any error but also wont show anything when usb connected. so i copied yours. can you tell me what the ~ after = means.
An additional binary operator, =~, is available, with the same precedence as == and !=. When it is used, the string to the right of the operator is considered a POSIX extended regular expression and matched accordingly (as in regex(3)).
So that's the device you need to query with fuser.../dev/snd/pcmC1D0c, and incorporate that into your script.
ok so for microphone i did this
Code:
#!/bin/bash
if [[ "$(fuser /dev/snd/pcmC1D0c)" != "" ]]; then
icon=" "
else
icon=""
fi
printf "%s%s\\n" "$icon"
its working it doesn't show anything when mic not is use but when in use it shows icon but its also giving me this output when i run the script in terminal
fuser prints the name of device to stderr. So, add 2>/dev/null
Code:
if [[ -n "$(fuser /dev/snd/pmcC1D0c 2>/dev/null)" ]]; then
Yes, it contains the same text.
what is the -n for that you added in the beginning. and what does 2> mean? i guess /dev/null is like show nothing?
if you can point me to a man page or reference guide for this .
No worries...as long as you're learning, you'll keep getting better. You're missing a space after the detected" and before the ]]. That should get rid of that message. And after thinking about it for a bit, try this instead:
Code:
if [[ "$(dmesg -S | tail | grep "usb-storage")" =~ "USB Mass Storage device detected" ]]; then
icon=" ��️ "
else
icon=""
fi
printf "%s%s\\n" "$icon"
...which will check for the presence of the string in what you get. That way, you can modify this to do different things if you plug in a mouse or some other USB device.
all scripts are working now. but this usb script, when i plug a usb drive it shows icon as expected, but if plug another usb in different port,at the same time so i have now 2 usb's, the icon disappears.
No worries...as long as you're learning, you'll keep getting better. You're missing a space after the detected" and before the ]]. That should get rid of that message. And after thinking about it for a bit, try this instead:
Code:
if [[ "$(dmesg -S | tail | grep "usb-storage")" =~ "USB Mass Storage device detected" ]]; then
icon=" ��️ "
else
icon=""
fi
printf "%s%s\\n" "$icon"
...which will check for the presence of the string in what you get. That way, you can modify this to do different things if you plug in a mouse or some other USB device.
this script is not good enough. when i connect 1 usb it gives this
which doesn't have usb-storage to grep so the icon disappears even though i have 2 usb connected.
when i connect a usb portable 2.5" hdd it gives this ( i extended tail range to -n 15 )
Code:
[ 659.426376] usb 1-3: Product: USB 3.0 Device
[ 659.426377] usb 1-3: Manufacturer: USB 3.0 Device
[ 659.426379] usb 1-3: SerialNumber: 00000000B032
[ 659.433060] scsi host4: uas
[ 659.433839] scsi 4:0:0:0: Direct-Access WDC WD10 SPZX-00Z10T0 0117 PQ: 0 ANSI: 6
[ 659.435213] sd 4:0:0:0: Attached scsi generic sg4 type 0
[ 659.435840] sd 4:0:0:0: [sdd] 1953525168 512-byte logical blocks: (1.00 TB/932 GiB)
[ 659.435842] sd 4:0:0:0: [sdd] 4096-byte physical blocks
[ 659.436038] sd 4:0:0:0: [sdd] Write Protect is off
[ 659.436041] sd 4:0:0:0: [sdd] Mode Sense: 53 00 10 08
[ 659.436349] sd 4:0:0:0: [sdd] Disabling FUA
[ 659.436351] sd 4:0:0:0: [sdd] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 659.436476] sd 4:0:0:0: [sdd] Optimal transfer size 33553920 bytes not a multiple of physical block size (4096 bytes)
[ 659.578561] sdd: sdd1
[ 659.580012] sd 4:0:0:0: [sdd] Attached SCSI disk
usb hdd doesn't even have a usb-storage to grep.
also when 1 of the flash drive was connected and i rebooted the icon didn't show because the dmesg tail was about my wifi being connected and networkmanager.
any idea's for improving this script, as this is not reliable.
i serched the internet a little and found that i could use udev for detecting usb. but im not sure how to use use udev to get the info i need. but i did find this command
#!/bin/bash
if [[ "$(udevadm monitor --kernel --property --subsystem-match=usb | head -n 4 | tail -n 1 | awk '{print $2}')" == "add" ]]; then
icon=" "
#elif [[ "$(udevadm monitor --kernel --property --subsystem-match=usb | head -n 4 | tail -n 1 | awk '{print $2}')" =~ "unbind" ]]; then
icon=""
fi
printf "%s%s\\n" "$icon"
however when i run the script it waits for me to plug usb to show, and when i added it in my block list dwmblock did not show at all i had to remove it. i dont know how to use udev to extract the data.
Well, udevadm monitor will just sit there and wait for events until you kill it. It will never transfer control to your script, so the script will be stuck reading the output from udevadm monitor forever.
Besides, you're only interested in storage devices, right? So you don't want the script to fire each time you plug in a new USB mouse or some such.
I'd rather evaluate the output of udisksctl dump like I did in that thread. This should be enough:
Well, udevadm monitor will just sit there and wait for events until you kill it. It will never transfer control to your script, so the script will be stuck reading the output from udevadm monitor forever.
Besides, you're only interested in storage devices, right? So you don't want the script to fire each time you plug in a new USB mouse or some such.
I'd rather evaluate the output of udisksctl dump like I did in that thread. This should be enough:
Code:
udisksctl dump|grep 'HintAuto:\s*true'
for now i just want it for storage device.
this command
Code:
udisksctl dump|grep 'HintAuto:\s*true'
gives me
Code:
HintAuto: true
even when there is no usb is connected.
but the link you sent me for ubuntu forums i think i can use this
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.