LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 06-12-2020, 08:07 AM   #31
apoorv569
Member
 
Registered: Jun 2020
Distribution: Arch Linux
Posts: 61

Original Poster
Rep: Reputation: 0

Quote:
Originally Posted by shruggy View Post
Ah, I don't have a DVD drive or card reader, so didn't think about other kinds of devices beyond USB that may have HintAuto set to true.

Well, the awk script enumerates partitions on all removable storage devices. I believe in your case it could be a bit simplified. How about
Code:
udisksctl dump|awk -F':\n' -vRS= '/[ \t]*HintAuto:[ \t]*true/&&/\.Filesystem:/{print "found"}'
yep its working fine now. thank you

Code:
   #!/bin/bash
  
   if [[ "$(udisksctl dump|awk -F':\n' -vRS= '/[ \t]*HintAuto:[ \t]*true/&&/\.Filesystem:/{print "found"}')" != "" ]]; then
           icon="  "
   else
           icon=""
   fi
  
   printf "%s%s\\n" "$icon"
one more thing my DWM build tends to freeze my laptop randomly like im here typing this sentence and suddenly my laptop is frozen or im just browing the internet and scrolling and it freezes it has happened 3 4 times now i had to hard reboot by long pressing power button. any ideas why? or way to debug this issue?

also i want to enable tap to touch and natural scrolling for my touchpad right now i can do this with
for tap to click
Code:
xinput set-prop 11 300 1
and for natural scrolling
Code:
xinput set-prop 11 308 1
so i just put it in my `autostart.sh` or is there a better way to do it?

Last edited by apoorv569; 06-12-2020 at 08:11 AM.
 
Old 06-12-2020, 08:20 AM   #32
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,677

Rep: Reputation: Disabled
Probably better to start two new threads as these problems have nothing to do with customizing the DWM statusbar. Nor with each other.
 
Old 06-12-2020, 08:54 AM   #33
apoorv569
Member
 
Registered: Jun 2020
Distribution: Arch Linux
Posts: 61

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by shruggy View Post
Probably better to start two new threads as these problems have nothing to do with customizing the DWM statusbar. Nor with each other.
no problem. thank you so much for helping. you rock!
 
Old 06-12-2020, 09:05 AM   #34
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,712

Rep: Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972
Quote:
Originally Posted by apoorv569 View Post
no problem. thank you so much for helping. you rock!
And thank you for showing your efforts and learning; far too often people don't, and it is much appreciated. You'll continue to do well.
 
Old 06-12-2020, 11:03 AM   #35
apoorv569
Member
 
Registered: Jun 2020
Distribution: Arch Linux
Posts: 61

Original Poster
Rep: Reputation: 0
Unhappy

Quote:
Originally Posted by TB0ne View Post
And thank you for showing your efforts and learning; far too often people don't, and it is much appreciated. You'll continue to do well.
the bluetooth script is working fine. and i was making button actions, this is middle click action, but its not working.
Code:
2) notify-send "Device Connected" "$(if [[ "$(bluetoothctl info)" != "Missing device address argument" ]]; then 
                                                  echo= "$(bluetoothctl info | grep "Name" | awk '{print $2}')"
else
                                                  echo= "No Device Connected" )" ;;
doesn't show anything, i only want it to shows "Device Connected - (name of the device)" when a device is a connected else it shows "No Device Connected", but click action doesn't seems to work it doesn't even show a blank notification. left and right click works.

this is the full script
Code:
#!/bin/bash
  
  case $BLOCK_BUTTON in
          1) setsid -f blueman-manager ;;
          2) notify-send "Device Connected" "$(if [[ "$(bluetoothctl info)" != "Missing device address argument" ]]; then 
                                                  echo= "$(bluetoothctl info | grep "Name" | awk '{print $2}')"
else
                                                  echo= "No Device Connected" )" ;;
          3) notify-send "Bluetooth" "\- Show Bluetooth Status.
  - Click to open Bluetooth Manager.
  - Middle click to show Connected Devices." ;;
  
  esac
  
    if [[ "$(bluetoothctl info)" != "Missing device address argument" ]]; then
      icon="  "
    else
      icon="  "
    fi
  
  printf "%s%s\\n" "$icon"

Last edited by apoorv569; 06-12-2020 at 11:05 AM.
 
Old 06-13-2020, 08:40 AM   #36
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,677

Rep: Reputation: Disabled
Code:
2) notify-send "Device Connected" "$(if [[ "$(bluetoothctl info)" != "Missing device address argument" ]]; then 
                                                  echo= "$(bluetoothctl info | grep "Name" | awk '{print $2}')"
else
                                                  echo= "No Device Connected"; fi)" ;;
  1. Remove = after echo. echo= ... means "assign an empty string to the variable echo and put it into environment for the command that follows".
  2. fi is missing.

https://www.shellcheck.net would catch such errors.

Actually, I'd rather write it like this:
Code:
2) notify-send "Device Connected" $(bluetoothctl info|grep -q 'Missing device address argument' &&
                                          echo 'No Device Connected' ||
                                          bluetoothctl info|awk '/Name/{print $2}')

Last edited by shruggy; 06-13-2020 at 08:53 AM.
 
Old 06-13-2020, 01:38 PM   #37
apoorv569
Member
 
Registered: Jun 2020
Distribution: Arch Linux
Posts: 61

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by shruggy View Post
Code:
2) notify-send "Device Connected" "$(if [[ "$(bluetoothctl info)" != "Missing device address argument" ]]; then 
                                                  echo= "$(bluetoothctl info | grep "Name" | awk '{print $2}')"
else
                                                  echo= "No Device Connected"; fi)" ;;
  1. Remove = after echo. echo= ... means "assign an empty string to the variable echo and put it into environment for the command that follows".
  2. fi is missing.

https://www.shellcheck.net would catch such errors.

Actually, I'd rather write it like this:
Code:
2) notify-send "Device Connected" $(bluetoothctl info|grep -q 'Missing device address argument' &&
                                          echo 'No Device Connected' ||
                                          bluetoothctl info|awk '/Name/{print $2}')
yes, i actually learned about logical operators yesterday.

i was writing another script yesterday for internet that shows me a wifi icon if its connected and/or ethernet icon if its connected.

Code:
if [[ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" == "up" || "$(cat /sys/class/net/e*/operstate 2>/dev/null)" == "up" ]];     then
          icon=" 📶 "
  else
          icon=" 🌐 "
  fi
  
  printf "%s%s\n" "$icon"
the script works, but it always show the wifi icon even if i have ethernet connected. and i also want to show " ❎ " this icon when nothing connected. but couldn't figure out how.
 
Old 06-14-2020, 12:04 AM   #38
apoorv569
Member
 
Registered: Jun 2020
Distribution: Arch Linux
Posts: 61

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by apoorv569 View Post
yes, i actually learned about logical operators yesterday.

i was writing another script yesterday for internet that shows me a wifi icon if its connected and/or ethernet icon if its connected.

Code:
if [[ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" == "up" || "$(cat /sys/class/net/e*/operstate 2>/dev/null)" == "up" ]];     then
          icon=" �� "
  else
          icon=" �� "
  fi
  
  printf "%s%s\n" "$icon"
the script works, but it always show the wifi icon even if i have ethernet connected. and i also want to show " ❎ " this icon when nothing connected. but couldn't figure out how.

ok so i edited the script but its not working now. i tried the link you sent `shellcheck` its says no errors, but when i execute in terminal it fails.

Code:
"$(cat /sys/class/net/w*/operstate 2>/dev/null)" == "up" && echo ' �� ' || "$(cat /sys/class/net/e*/operstate 2>/dev/null)" == "up" && echo ' �� ' || echo ' ❎ '

Last edited by apoorv569; 06-14-2020 at 12:05 AM.
 
Old 06-14-2020, 07:41 AM   #39
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,677

Rep: Reputation: Disabled
It's difficult to get it right with && and || operators when there are more than two choices.
Code:
if grep -qw up /sys/class/net/w*/operstate
then icon=' 📶 '
elif grep -qw up /sys/class/net/e*/operstate
then icon=' 🌐 '
else icon=' ❎ '
fi
 
Old 06-14-2020, 09:58 AM   #40
apoorv569
Member
 
Registered: Jun 2020
Distribution: Arch Linux
Posts: 61

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by shruggy View Post
It's difficult to get it right with && and || operators when there are more than two choices.
Code:
if grep -qw up /sys/class/net/w*/operstate
then icon=' 📶 '
elif grep -qw up /sys/class/net/e*/operstate
then icon=' 🌐 '
else icon=' ❎ '
fi
yes its working, i used if and elif before but didn't work, i guess there were some error i made.

i made another script for weather
Code:
weather="$(curl 'https://wttr.in/Paris,France?format=%t')"
  
   printf "%s%s\\n" "$weather"
i dont live in paris its just a test.
it shows output in terminal, but its not showing in the statusbar.
 
Old 06-14-2020, 10:44 AM   #41
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,677

Rep: Reputation: Disabled
It may have nothing to do with your script, but rather with wttr.in. Here is what I currently get:
Quote:
Sorry, we are running out of queries to the weather service at the moment.
Update. Now, it works again.

Quote:
Originally Posted by apoorv569 View Post
Code:
printf "%s%s\\n" "$weather"
I guess just printf "%s\n" "$weather" would be enough. You are quoting the variable $weather anyway, so even if its value includes a space, it will be counted as just one parameter to printf.

Last edited by shruggy; 06-14-2020 at 10:52 AM.
 
Old 06-14-2020, 11:17 AM   #42
apoorv569
Member
 
Registered: Jun 2020
Distribution: Arch Linux
Posts: 61

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by shruggy View Post
It may have nothing to do with your script, but rather with wttr.in. Here is what I currently get:

Update. Now, it works again.


I guess just printf "%s\n" "$weather" would be enough. You are quoting the variable $weather anyway, so even if its value includes a space, it will be counted as just one parameter to printf.
its working, actually the update interval in blocks.h was 18000(5 hrs), i changed it to 1 its showing now. i guess it was not updating because of long interval.
 
Old 06-17-2020, 07:51 AM   #43
apoorv569
Member
 
Registered: Jun 2020
Distribution: Arch Linux
Posts: 61

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by shruggy View Post
It may have nothing to do with your script, but rather with wttr.in. Here is what I currently get:

Update. Now, it works again.


I guess just printf "%s\n" "$weather" would be enough. You are quoting the variable $weather anyway, so even if its value includes a space, it will be counted as just one parameter to printf.
i edited my weather script as it was continuously using the internet and updating/downloading, so i did this
Code:
#!/bin/bash

 weather="${XDG_DATA_HOME:-$HOME/.cache/}weather"

 getweather="$(curl -sf 'https://wttr.in/Paris,France?format=%t' > "$weather" || exit 1 ;)"

 showweather() { printf "%s" "$weather" ;}

 case $BLOCK_BUTTON in
                 1) setsid -f "$TERMINAL" -e less -Srf "$weatherreport" ;;
                 2) getweather && showweather ;;
                 3) notify-send "�� Weather module" "\- Left click for full forecast.
                 - Middle click to update forecast." ;;
                 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
         esac

 #printf "%s" "$weather"

 [ "$(stat -c %y "$weather" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
                 getweather

 showweather
but its now showing me the weather, instead its showing me the path of the file "/home/apoorv/.cache/weather%"
 
Old 06-17-2020, 09:16 AM   #44
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,677

Rep: Reputation: Disabled
Replace printf with cat:
Code:
showweather() { cat "$weather" ;}
 
Old 06-17-2020, 09:22 AM   #45
apoorv569
Member
 
Registered: Jun 2020
Distribution: Arch Linux
Posts: 61

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by shruggy View Post
Replace printf with cat:
Code:
showweather() { cat "$weather" ;}
oops, such a silly mistake sorry
 
  


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
LXer: dwm: A Minimalist Tiling Window Manager For Linux LXer Syndicated Linux News 0 04-03-2018 02:52 PM
LXer: Top 4 reasons I use dwm for my Linux window manager LXer Syndicated Linux News 0 07-19-2017 04:40 AM
dwm window manager: conky eats 100%CPU when it has its own window (window_type normal) ondoho Linux - Software 0 10-11-2016 08:49 PM
Get window size with tiling window manager in SDL Snark1994 Programming 1 02-24-2013 08:46 PM
Config-file for DWM window manager on Debian. tirka Linux - Newbie 1 06-25-2011 06:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 06:57 PM.

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