diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2015-05-02 09:53:00 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2015-05-02 09:53:00 +0200 |
commit | 5682ab44e3ecca0a18404885bcfbf97b8762a89b (patch) | |
tree | 10ca46f93134fb36640b49353e9c578ef24ba8a5 /mga-bg-res/mga-bg-res.xinit | |
parent | 3e6f62173f00b6f60050c07485948bfbbb4b59ba (diff) | |
download | theme-5682ab44e3ecca0a18404885bcfbf97b8762a89b.tar theme-5682ab44e3ecca0a18404885bcfbf97b8762a89b.tar.gz theme-5682ab44e3ecca0a18404885bcfbf97b8762a89b.tar.bz2 theme-5682ab44e3ecca0a18404885bcfbf97b8762a89b.tar.xz theme-5682ab44e3ecca0a18404885bcfbf97b8762a89b.zip |
Make mga-bg-res a systemd service that uses monitor-probe
Now runs as a systemd service with root privileges, therefore the mga-bg-res C binary is no longer needed.
Uses monitor-probe to find the optimal resolution when X is not yet started, and handles cases where monitor-probe fails by defaulting to 4:3 aspect ratio.
Diffstat (limited to 'mga-bg-res/mga-bg-res.xinit')
-rwxr-xr-x | mga-bg-res/mga-bg-res.xinit | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/mga-bg-res/mga-bg-res.xinit b/mga-bg-res/mga-bg-res.xinit deleted file mode 100755 index 42d79da..0000000 --- a/mga-bg-res/mga-bg-res.xinit +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -# 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" -if [ "$(readlink $bgpath/default.jpg)" != "$bgpath/Mageia-Default-$res.jpg" ]; then - # 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)) - - found=false - declare -A refRatios=( ["1250"]="1280x1024" ["1333"]="1600x1200" ["1600"]="1920x1200" - ["1667"]="1280x768" ["1707"]="1024x600" ["1778"]="1920x1080" ) - for key in "${!refRatios[@]}"; do - if [ $(($ratio % $key)) -lt 25 -o $(($key % $ratio)) -lt 25 ]; then - res=${refRatios[$key]} - ratio=$key - found=true - break - fi - done - - if ! $found; then - echo "mga-bg-res: 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 - echo "mga-bg-res: Changing the background symlink to point to Mageia-Default-$res.jpg (aspect ratio ${ratio:0:1}.${ratio:1:3})" - /usr/bin/mga-bg-res $res - else - echo "mga-bg-res: Nothing to do, the background symlink is already correct." - fi -else - echo "mga-bg-res: Nothing to do, the background symlink is already correct." -fi |