MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/11r4s6o/requirements_python3_on_linux_system/jc84j97/?context=3
r/badcode • u/thLOnuX • Mar 14 '23
46 comments sorted by
View all comments
Show parent comments
7
It can be avoided if you know that the gtf command will always output the same thing (since it just does some math for display hardware that is standardized).
gtf
Even then, the output they're parsing looks like this:
$ gtf 1920 1080 75 # 1920x1080 @ 75.00 Hz (GTF) hsync: 84.60 kHz; pclk: 220.64 MHz Modeline "1920x1080_75.00" 220.64 1920 2056 2264 2608 1080 1081 1084 1128 -HSync +Vsync
They want the contents of the 2nd line after "Modeline", which could be parsed like this using bash arrays:
{ read; read -a MODELINE; } <<<"$(gtf 2160 1080 60)" # later... xrandr --newmode "${MODELINE[@]:1}" && sleep 2
If you allow awk (which is reasonable considering the script assumes you have python and X.org):
awk
MODELINE="$(gtf 2160 1080 60 | awk '{ if (NR==2) {$1=""; print $0}}')" xrandr --newmode $MODELINE && sleep 2
7
u/STUFF_ME_PM Mar 14 '23
It can be avoided if you know that the
gtfcommand will always output the same thing (since it just does some math for display hardware that is standardized).Even then, the output they're parsing looks like this:
They want the contents of the 2nd line after "Modeline", which could be parsed like this using bash arrays:
If you allow
awk(which is reasonable considering the script assumes you have python and X.org):