LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-05-2020, 12:09 PM   #1
charbelsako
LQ Newbie
 
Registered: Nov 2020
Posts: 14

Rep: Reputation: Disabled
dwmblocks script error


I recently got dwmblocks and wrote 2 scripts for volume and brightness but I can't see the values in the status bar.

Here are the scripts
volume:
-------
Code:
<script type="bash">
#! /bin/bash
echo "hello"
exit

case $BLOCK_BUTTON in
	1) pactl set-sink-mute 0 toggle
esac

vol=$(pactl list sinks | grep '^[[:space:]]Volume:' | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,')
printf "%s%%" "$vol"
</script>
brightness:
-----------
Code:
<script type="bash">
#! /bin/bash

brightness=$(xbacklight -get)

printf "%i%%" "$brightness"
</script>

the files work by themselves but don't show up in dwmblocks. I have also added the files' location to the PATH variable

Finally here's my blocks.h file
blocks.h:
---------
Code:
//Modify this file to change what commands output to your statusbar, and recompile using the make command.
static const Block blocks[] = {
	/*Icon*/	/*Command*/		/*Update Interval*/	/*Update Signal*/
	{"Mem:", "free -h | awk '/^Mem/ { print $3"/"$2 }' | sed s/i//g",	30,		0},

	{"", "date '+%a %b %d %I:%M%p'",					5,		0},
	{"VOL:", "volume", 							1,  		0},
	{"Brightness: ", "brightness", 						5, 		0}
};

//sets delimeter between status commands. NULL character ('\0') means no delimeter.
static char delim[] = " | ";
static unsigned int delimLen = 5;
I also would like to know what values should I set for updateinterval and updatesignal as there is no documentation for them

If you want more info I do have an image of my status bar. Just tell me where i can upload it?

Last edited by charbelsako; 11-06-2020 at 12:29 AM. Reason: Adding more questions
 
Old 11-05-2020, 04:38 PM   #2
individual
Member
 
Registered: Jul 2018
Posts: 315
Blog Entries: 1

Rep: Reputation: 233Reputation: 233Reputation: 233
Have you tried hard-coding the path to those files, e.g., /home/user/bin/volume? It looks like update interval is calculated as seconds. So your mem command be called every 30 seconds. The signal option looks like it accepts a standard UNIX signal to determine when to call the command. Type man 7 signal in your terminal to see all the signals.

Last edited by individual; 11-05-2020 at 04:39 PM. Reason: Wording
 
Old 11-05-2020, 10:27 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
1.please use code blocks https://www.linuxquestions.org/quest...do=bbcode#code

2.
Code:
volume:
-------
#! /bin/bash
echo "hello"
exit
So script exits (almost) immediately
 
Old 11-06-2020, 12:32 AM   #4
charbelsako
LQ Newbie
 
Registered: Nov 2020
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by individual View Post
Have you tried hard-coding the path to those files, e.g., /home/user/bin/volume? It looks like update interval is calculated as seconds. So your mem command be called every 30 seconds. The signal option looks like it accepts a standard UNIX signal to determine when to call the command. Type man 7 signal in your terminal to see all the signals.
This works
 
Old 11-06-2020, 12:38 AM   #5
charbelsako
LQ Newbie
 
Registered: Nov 2020
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by individual View Post
Have you tried hard-coding the path to those files, e.g., /home/user/bin/volume? It looks like update interval is calculated as seconds. So your mem command be called every 30 seconds. The signal option looks like it accepts a standard UNIX signal to determine when to call the command. Type man 7 signal in your terminal to see all the signals.
How would I make It update immediately after I press the button?
 
Old 11-06-2020, 01:06 AM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by charbelsako View Post
How would I make It update immediately after I press the button?
A button on your dwm bar?
By coding the wanted behavior in C.
Probably goes beyond editing the .h file.
 
Old 11-06-2020, 11:13 AM   #7
charbelsako
LQ Newbie
 
Registered: Nov 2020
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
A button on your dwm bar?
By coding the wanted behavior in C.
Probably goes beyond editing the .h file.
I mean how would I make it update after I press the raise volume button on my keyboard. Right now it updates every second
 
Old 11-06-2020, 02:30 PM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
What's the "Update Signal" registered in blocks.h?
You send that signal to the blocks application, probably with the 'kill' command. 'man kill'.
Once you got that working, bind it to a hotkey (which involves editing dwm's own .h file if memory serves).
 
Old 11-10-2020, 06:40 AM   #9
charbelsako
LQ Newbie
 
Registered: Nov 2020
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
What's the "Update Signal" registered in blocks.h?
You send that signal to the blocks application, probably with the 'kill' command. 'man kill'.
Once you got that working, bind it to a hotkey (which involves editing dwm's own .h file if memory serves).
It works

Last edited by charbelsako; 11-10-2020 at 02:03 PM.
 
Old 11-10-2020, 02:07 PM   #10
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by charbelsako View Post
It works
Mark SOLVED please
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Sed script within bash script produces unexpecte EOF error Kgeil Linux - Newbie 8 05-16-2019 12:41 AM
bash script read error and awk ouptut error whited Programming 4 10-16-2007 07:05 PM
i get an error message running php script inside a cgi script. repolona Linux - Software 0 02-22-2007 09:10 PM
error when tying to run python script(bash error?) shanenin Programming 5 01-10-2006 10:01 AM
linux 9 and java script error - premature end of script header sibil Linux - Newbie 0 01-06-2004 04:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration