About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
-
Koentje
- Level 7
- Posts: 1581
- Joined: Tue Jan 04, 2022 6:23 pm
- Location: Netherlands
Post
by Koentje »
I just solved it myself. Awk can't search for astrix, so i changes it with sed to
^
. Then awk print $1 and awk print $NF.
Code: Select all
xrandr | sed -n "/^$ports/,/^[^[:space:]]/p" | grep '*' | sed 's/*/^/g' | awk -F'^' '{print $1}' | awk '{print $NF}'
In a bash script
Code: Select all
#!/bin/bash
while read -r ports
do
freq=$(xrandr | sed -n "/^$ports/,/^[^[:space:]]/p" | grep '*' | sed 's/*/^/g' | awk -F'^' '{print $1}' | awk '{print $NF}')
reso=$(xrandr | sed -n "/^$ports/,/^[^[:space:]]/p" | awk 'sub("*"," "){print $1}')
echo -e "$ports\t$reso $freq"
done < <(xrandr | grep -w 'connected' | awk '{print $1}')
The script only searches for connected ports.
Output
Code: Select all
$ ./monitors.sh
DisplayPort-1 3440x1440 143.97
HDMI-1-1 1920x1080 60.00
Last edited by
Koentje on Wed Mar 20, 2024 2:32 pm, edited 1 time in total.
-
Koentje
- Level 7
- Posts: 1581
- Joined: Tue Jan 04, 2022 6:23 pm
- Location: Netherlands
Post
by Koentje »
1000 wrote: ⤴Wed Mar 20, 2024 2:27 pm
Koentje Can I see the entire xrandr output?
Code: Select all
Screen 0: minimum 320 x 200, current 4031 x 2520, maximum 16384 x 16384
DisplayPort-1 connected primary 3440x1440+0+1080 (normal left inverted right x axis y axis) 797mm x 334mm
3440x1440 59.97 + 143.97* 119.99 99.98
2560x1440 143.97 120.00 59.95
1920x1200 59.97
1920x1080 143.98 120.00 119.88 60.00 60.00 50.00 59.94
1600x1200 59.97
1680x1050 59.95
1280x1024 75.02 60.02
1440x900 59.89
1280x960 60.00
1280x800 59.81
1152x864 75.00
1280x720 60.00 50.00 59.94
1024x768 75.03 60.00
800x600 75.00 60.32
720x576 50.00
720x480 60.00 59.94
640x480 75.00 60.00 59.94
720x400 70.08
HDMI-A-3 disconnected (normal left inverted right x axis y axis)
HDMI-1-1 connected 1920x1080+2111+0 (normal left inverted right x axis y axis) 477mm x 268mm
1920x1080 60.00*+ 50.00 59.94
1680x1050 59.88
1600x900 60.00
1280x1024 60.02
1440x900 59.90
1280x960 60.00
1366x768 59.79
1280x800 59.91
1280x720 60.00 50.00 59.94
1024x768 60.00
800x600 60.32
720x576 50.00
720x480 60.00 59.94
640x480 60.00 59.94
HDMI-1-2 disconnected (normal left inverted right x axis y axis)
DP-1-1 disconnected (normal left inverted right x axis y axis)
HDMI-1-3 disconnected (normal left inverted right x axis y axis)
1920x1080 (0x60) 148.500MHz +HSync +VSync
h: width 1920 start 2008 end 2052 total 2200 skew 0 clock 67.50KHz
v: height 1080 start 1084 end 1089 total 1125 clock 60.00Hz
1920x1080 (0x61) 148.500MHz +HSync +VSync
h: width 1920 start 2448 end 2492 total 2640 skew 0 clock 56.25KHz
v: height 1080 start 1084 end 1089 total 1125 clock 50.00Hz
1920x1080 (0x62) 148.352MHz +HSync +VSync
h: width 1920 start 2008 end 2052 total 2200 skew 0 clock 67.43KHz
v: height 1080 start 1084 end 1089 total 1125 clock 59.94Hz
1280x1024 (0x66) 108.000MHz +HSync +VSync
h: width 1280 start 1328 end 1440 total 1688 skew 0 clock 63.98KHz
v: height 1024 start 1025 end 1028 total 1066 clock 60.02Hz
1280x960 (0x68) 108.000MHz +HSync +VSync
h: width 1280 start 1376 end 1488 total 1800 skew 0 clock 60.00KHz
v: height 960 start 961 end 964 total 1000 clock 60.00Hz
1280x720 (0x6b) 74.250MHz +HSync +VSync
h: width 1280 start 1390 end 1430 total 1650 skew 0 clock 45.00KHz
v: height 720 start 725 end 730 total 750 clock 60.00Hz
1280x720 (0x6c) 74.250MHz +HSync +VSync
h: width 1280 start 1720 end 1760 total 1980 skew 0 clock 37.50KHz
v: height 720 start 725 end 730 total 750 clock 50.00Hz
1280x720 (0x6d) 74.176MHz +HSync +VSync
h: width 1280 start 1390 end 1430 total 1650 skew 0 clock 44.96KHz
v: height 720 start 725 end 730 total 750 clock 59.94Hz
1024x768 (0x6f) 65.000MHz -HSync -VSync
h: width 1024 start 1048 end 1184 total 1344 skew 0 clock 48.36KHz
v: height 768 start 771 end 777 total 806 clock 60.00Hz
800x600 (0x71) 40.000MHz +HSync +VSync
h: width 800 start 840 end 968 total 1056 skew 0 clock 37.88KHz
v: height 600 start 601 end 605 total 628 clock 60.32Hz
720x576 (0x72) 27.000MHz -HSync -VSync
h: width 720 start 732 end 796 total 864 skew 0 clock 31.25KHz
v: height 576 start 581 end 586 total 625 clock 50.00Hz
720x480 (0x73) 27.027MHz -HSync -VSync
h: width 720 start 736 end 798 total 858 skew 0 clock 31.50KHz
v: height 480 start 489 end 495 total 525 clock 60.00Hz
720x480 (0x74) 27.000MHz -HSync -VSync
h: width 720 start 736 end 798 total 858 skew 0 clock 31.47KHz
v: height 480 start 489 end 495 total 525 clock 59.94Hz
640x480 (0x76) 25.200MHz -HSync -VSync
h: width 640 start 656 end 752 total 800 skew 0 clock 31.50KHz
v: height 480 start 490 end 492 total 525 clock 60.00Hz
640x480 (0x77) 25.175MHz -HSync -VSync
h: width 640 start 656 end 752 total 800 skew 0 clock 31.47KHz
v: height 480 start 490 end 492 total 525 clock 59.94Hz
-
1000
- Level 6
- Posts: 1040
- Joined: Wed Jul 29, 2020 2:14 am
Post
by 1000 »
So you got it from xrandr, thanks.
-
Coggy
- Level 5
- Posts: 642
- Joined: Thu Mar 31, 2022 10:34 am
Post
by Coggy »
xenopeek wrote: ⤴Wed Mar 20, 2024 1:55 pm
What does the + mean?
I
think it means it's xrandr's recommended setting. So it is nearly always the same as the * which indicates the current setting.
-
Logansfury
- Level 6
- Posts: 1237
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Post
by Logansfury »
Are some of youse big-brains making your own conky widgets based on my idea???
Holy crap!
<-- Cick for
sudo inxi --usb -Fxxxnmprz output, updated hourly!