AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1194187
Accepted
Kingle
Kingle
Asked: 2019-12-06 21:38:50 +0800 CST2019-12-06 21:38:50 +0800 CST 2019-12-06 21:38:50 +0800 CST

双显示器壁纸的 HydraPaper 替代品?

  • 772

我一直在寻找一种拥有双壁纸的方法。到目前为止,唯一出现的是 HydraPaper。问题是我还需要安装 Flatpak。我已经在使用apt和snap包,所以我不想单独为壁纸安装另一个包管理器。是否有 HydraPaper 的替代品?

wallpaper 18.04
  • 1 1 个回答
  • 1475 Views

1 个回答

  • Voted
  1. Best Answer
    pmcb
    2019-12-18T05:05:22+08:002019-12-18T05:05:22+08:00

    这可能是您正在寻找的。

    我使用“bash”、“convert”和“gsettings”来完成。它适用于我的 2 个屏幕。

    概述:

    • 得到两个高度相同的图像
    • 图片的新宽度=屏幕宽度*图片原始高度/屏幕高度
    • 将图像拉伸到新宽度
    • 加入现在适合 2 个屏幕全宽的 2 个图像

    我正在运行 Ubuntu 18.04。随意破解您的内心

    #! /bin/bash
    #! /bin/bash -vx
    
    # input:
    # new_background.sh -reset - to reset background to the previous picture
    # new_background.sh -set - to set a new background
    
    lastImage=$HOME/.new_background_last_image.txt
    DIR="/usr/share/backgrounds"
    joinImage=$HOME/.new_background_last_image.jpg
    # choose 2 images from dir
    number=$(ls -1 $DIR | wc -l | awk '{print $1}')
    mapfile -t screenSize < <( xrandr | grep  -e "^DP" | awk ' { print $0 }'  )
    if [ ${#screenSize[@]} != 2 ]
    then
    echo there don\'t appear to be 2 screens - jobs ends
    exit
    fi
    
    tot=0
    prevH=0
    prevW=0
    prevFile=""
    found=0
    SET=-1
    case "$1" in
    -reset ) SET=0
    ;;
    -set ) SET=1
    ;;
    esac 
    
    if [ "$SET" -eq -1 ]
    then
    echo enter either -set or -reset
    exit
    fi
    
    # reset previous picture
    if [ "$SET" -eq 0 ]
    then
    URI=$(cat $lastImage)
    gsettings set org.gnome.desktop.background picture-options 'zoom'
    gsettings set org.gnome.desktop.background picture-uri "${URI}"
    exit
    fi
    
    # find 2 pictures
    while [ $tot -lt $number ]
    do
    # go throguh files at random until 2 have the same height
      randomN=$[ ( $RANDOM % $number ) ]
      fileName=$(ls -1 $DIR/*  | grep -e jpg -e png | awk 'NR=='$randomN' {print $0}')
      if [ x$prevFile == x$fileName ]
      then
        continue
      fi
      if [ x"" == x$fileName ]
      then
        continue
      fi
      if [ x$prevFile != x$fileName ] && [ x"" != x$fileName ]
      then
        ww=$(convert $fileName -print "Size: %wx%h\n" /dev/null | awk '{ print $2}')
        w=$(echo $ww | awk -F x ' {print $1 }')
        h=$(echo $ww | awk -F x ' {print $2 }') 
        if [ $h -eq $prevH ]
        then
          found=1
          break
        fi
      fi
      prevW=$w
      prevH=$h
      prevFile=$fileName
      tot=$[$tot+1]
    done
    
    if [ $found -eq 0 ]
    then
      echo no files found   # may be solved by running the program again
      exit
    fi
    
    # new width = width of screen * original height of image / height of screen
    #           =      1920                 2160(e.g.)           1080
    
    pref=$(expr $(mktemp -u) :  ".*\.\(.*\)")
    outputFile=(${pref}_1 ${pref}_2)
    
    files=( $fileName $prevFile )
    widths=( $w $prevW)
    heights=( $h $prevH)
    
    # do each file
    reverse=0      # if the second screen is the first in the screenSize list reverse=1
    for I in 0 1;
    do
    # size of screen I
    mapfile -t tt < <(echo ${screenSize[$I]}   |  grep -E -o  '[0-9]+x[0-9]+\+[0-9]+\+[0-9]+'  | sed s'/[x+]/ /g' | awk ' { print $1,"\n", $2, "\n", $3, "\n", $4 } ')
    
    # this is the start position of the screen 
    # if not 0 and I=0 then it is the 2nd screen and reverse images when joining
    offset=${tt[2]}
    if [ $I == 0 ] && [ $offset != 0 ]
    then
    reverse=1
    fi
    let "newWidth = ${heights[$I]}*${tt[0]}/${tt[1]}" 
    convert -resize ${newWidth}x${heights[$I]}! ${files[$I]} ${outputFile[$I]}
    done
    
    # join the files
    if [ $reverse == 0 ]
    then
    convert +append ${outputFile[0]} ${outputFile[1]} $joinImage
    else
    convert +append ${outputFile[1]} ${outputFile[0]} $joinImage
    fi
    
    URI=$(gsettings get org.gnome.desktop.background picture-uri)
    # save the previous file name
    echo $URI > $lastImage
    uri=file:"//$joinImage"
    gsettings set org.gnome.desktop.background picture-options 'spanned'
    gsettings set org.gnome.desktop.background picture-uri "${uri}"
    rm ${outputFile[0]} ${outputFile[1]}
    # end-of-file
    
    • 1

相关问题

  • 如何从通知中删除图标或更改壁纸的任何替代方法

  • 寻找多显示器壁纸切换器

  • 根据桌面显示的时间更改壁纸[关闭]

  • 如何创建桌面墙纸幻灯片?

  • 如何提交壁纸以考虑包含在 Ubuntu 中?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve