diff options
-rw-r--r-- | mga-bg-res/NEWS | 4 | ||||
-rw-r--r-- | mga-bg-res/VERSION | 2 | ||||
-rwxr-xr-x | mga-bg-res/mga-bg-res.xinit | 25 |
3 files changed, 29 insertions, 2 deletions
diff --git a/mga-bg-res/NEWS b/mga-bg-res/NEWS index 11f14fa..bf66006 100644 --- a/mga-bg-res/NEWS +++ b/mga-bg-res/NEWS @@ -1,3 +1,7 @@ +Version 0.3 (2015-02-13): +- Add support for any screen resolution that fits an aspect ratio + provided in mageia-theme (Akien) + Version 0.2 (2015-02-08): - Bugfix: Do not ship binary instead of the source (AL13N) diff --git a/mga-bg-res/VERSION b/mga-bg-res/VERSION index 3b04cfb..be58634 100644 --- a/mga-bg-res/VERSION +++ b/mga-bg-res/VERSION @@ -1 +1 @@ -0.2 +0.3 diff --git a/mga-bg-res/mga-bg-res.xinit b/mga-bg-res/mga-bg-res.xinit index d3dd2dd..3366c8d 100755 --- a/mga-bg-res/mga-bg-res.xinit +++ b/mga-bg-res/mga-bg-res.xinit @@ -1,3 +1,26 @@ #!/bin/sh -/usr/bin/mga-bg-res $( xrandr | awk '/\sconnected/{i=split(substr($0,0,index($0,"+")-1),a);if($0~/\sprimary\s/){if(p==""){p=a[i]}}else{if(d==""){d=a[i]}}}END{if(p==""){print d}else{print p}}' ) +# Find currently used resolution +res=$( xrandr | awk '/\sconnected/{i=split(substr($0,0,index($0,"+")-1),a);if($0~/\sprimary\s/){if(p==""){p=a[i]}}else{if(d==""){d=a[i]}}}END{if(p==""){print d}else{print p}}' ) + +bgpath="/usr/share/mga/backgrounds" +# Check if this is a supported resolution, if not, find the background with the same aspect ratio +if [ ! -e "$bgpath/Mageia-Default-$res.jpg" ]; then + width=$(echo $res | cut -f1 -d"x") + height=$(echo $res | cut -f2 -d"x") + # Bash only does integer arithmetic, we multiply everything by 1000 to workaround this + ratio=$((1000*$width/$height)) + + declare -A refRatios=( ["1250"]="1280x1024" ["1333"]="2560x1920" ["1600"]="1920x1200" + ["1667"]="800x480" ["1707"]="1024x600" ["1778"]="1920x1080" ) + if test "${refRatios[$ratio]+defined}" ; then + res=${refRatios[$ratio]} + else + echo "Your aspect ratio does not seem to be supported, keeping default background resolution." + exit 1 + fi +fi + +if [ $(readlink "$bgpath/default.jpg") != "$bgpath/Mageia-Default-$res.jpg" ]; then + /usr/bin/mga-bg-res $res +fi |