Skip to content

use python -c to round instead of printf #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions helpers/server
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ server_get_display() {
server_get_dpi() {
# Calculate diagonal
diagonal() {
printf '%.0f' $(bc <<< "scale=2; sqrt($1^2+$2^2)")
bc <<< "scale=2; sqrt($h_width^2+$h_height^2)" | python -c "print(round(float(input())))"

}

## Find display resolution
Expand All @@ -25,10 +26,10 @@ server_get_dpi() {
local h_pheight=$(echo "$h_psize" | cut -d' ' -f2)
local h_pdiag=$(bc <<< "scale=0; $(diagonal $h_pwidth $h_pheight)/25.4")
local h_dpi=$(bc <<< "scale=2; $h_diag/$h_pdiag" | xargs printf '%.0f')

unset -f diagonal
echo $h_dpi
}
}

# Return the server ip
server_get_ip() {
Expand Down