내 날씨 표시기아마도 우분투 데스크탑을 위한 최고의 날씨 위젯일 것입니다.
그러나 수동으로 수행해야 합니다.데스크탑 위젯 위치 변경(예: 오른쪽 상단 정렬)외부 모니터가 연결될 때마다노트북으로.
외부 모니터용으로 my-weather-indicator(예: 2개의 "슈퍼클럭") 데스크탑 위젯의 위치를 자동으로 변경하는 시작 스크립트는 어떻습니까? 아니면 다른 (아마도 더 나은) 솔루션이 있습니까?
답변1
다음은 샘플 시작 스크립트입니다.
다음 명령 대신 파일 Exec=
줄 에 입력할 수 있습니다 .~/.config/autostart/my-weather-indicator.desktop
/opt/extras.ubuntu.com/my-weather-indicator/bin/my-weather-indicator
#!/bin/bash
while true
do
MONITORS="$(xrandr | grep -v "eDP1 " | grep -c " connected ")"
if [[ "$MONITORS" -eq 0 ]] # no external monitor, LCD panel only
then
MONINTX="$(xrandr | grep "eDP1 connected " | sed -e 's/^eDP1 connected primary //g' -e 's/x.*$//g')"
MONINTV="$(expr $MONINTX - 316)"
MONINT1="$(grep -c "\"wp1-x\": $MONINTV" "/home/$USER/.config/my-weather-indicator/my-weather-indicator.conf")"
if [[ "$MONINT1" -eq 0 ]] # widget1 not configured for LCD panel
then
sed -i "s/\"wp1\-x\"\: [0-9]*/\"wp1\-x\"\: $MONINTV/" "/home/$USER/.config/my-weather-indicator/my-weather-indicator.conf"
echo "REFRESH" > "/tmp/my-weather-indicator_mon-int"
fi
MONINT2="$(grep -c "\"wp2-x\": $MONINTV" "/home/$USER/.config/my-weather-indicator/my-weather-indicator.conf")"
if [[ "$MONINT2" -eq 0 ]] # widget2 not configured for LCD panel
then
sed -i "s/\"wp2\-x\"\: [0-9]*/\"wp2\-x\"\: $MONINTV/" "/home/$USER/.config/my-weather-indicator/my-weather-indicator.conf"
echo "REFRESH" > "/tmp/my-weather-indicator_mon-int"
fi
if [ -f "/tmp/my-weather-indicator_mon-int" ] # marker file
then
if [ -s "/tmp/my-weather-indicator_mon-int" ] # content
then
PID="$(ps -e -o pid,cmd | grep "/usr/bin/python3 /opt/extras.ubuntu.com/my-weather-indicator/bin/my-weather-indicator" | egrep -v grep | awk '{print$1}')"
if [[ "$PID" -eq 0 ]] # not running, start
then
rm "/tmp/my-weather-indicator_mon-int"
"/opt/extras.ubuntu.com/my-weather-indicator/bin/my-weather-indicator" &
else
kill -9 "$PID" # running, re-start
rm "/tmp/my-weather-indicator_mon-int"
"/opt/extras.ubuntu.com/my-weather-indicator/bin/my-weather-indicator" &
fi
fi
fi
else # external monitor connected
MONEXTX="$(xrandr | grep " connected " | grep -v "eDP1" | sed -e 's/^e*[A-Z]*[A-Z][A-Z][0-9] connected primary //g' -e 's/x.*$//g')"
MONEXTV="$(expr $MONEXTX - 316)"
MONEXT1="$(grep -c "\"wp1-x\": $MONEXTV" "/home/$USER/.config/my-weather-indicator/my-weather-indicator.conf")"
if [[ "$MONEXT1" -eq 0 ]] # widget1 not configured for external monitor
then
sed -i "s/\"wp1\-x\"\: [0-9]*/\"wp1\-x\"\: $MONEXTV/" "/home/$USER/.config/my-weather-indicator/my-weather-indicator.conf"
echo "REFRESH" > "/tmp/my-weather-indicator_mon-ext"
fi
MONEXT2="$(grep -c "\"wp2-x\": $MONEXTV" "/home/$USER/.config/my-weather-indicator/my-weather-indicator.conf")"
if [[ "$MONEXT2" -eq 0 ]] # widget2 not configured for external monitor
then
sed -i "s/\"wp2\-x\"\: [0-9]*/\"wp2\-x\"\: $MONEXTV/" "/home/$USER/.config/my-weather-indicator/my-weather-indicator.conf"
echo "REFRESH" > "/tmp/my-weather-indicator_mon-ext"
fi
if [ -f "/tmp/my-weather-indicator_mon-ext" ] # marker file
then
if [ -s "/tmp/my-weather-indicator_mon-ext" ] # content
then
PID="$(ps -e -o pid,cmd | grep "/usr/bin/python3 /opt/extras.ubuntu.com/my-weather-indicator/bin/my-weather-indicator" | egrep -v grep | awk '{print$1}')"
if [[ "$PID" -eq 0 ]] # not running, start
then
rm "/tmp/my-weather-indicator_mon-ext"
"/opt/extras.ubuntu.com/my-weather-indicator/bin/my-weather-indicator" &
else
kill -9 "$PID" # running, re-start
rm "/tmp/my-weather-indicator_mon-ext"
"/opt/extras.ubuntu.com/my-weather-indicator/bin/my-weather-indicator" &
fi
fi
fi
fi
PID="$(ps -e -o pid,cmd | grep "/usr/bin/python3 /opt/extras.ubuntu.com/my-weather-indicator/bin/my-weather-indicator" | egrep -v grep | awk '{print$1}')"
if [[ "$PID" -eq 0 ]] # not running, start
then
"/opt/extras.ubuntu.com/my-weather-indicator/bin/my-weather-indicator" &
fi
sleep 12
done
주의:이 스크립트는 DELL Latitude 노트북에서만 테스트되었습니다.2개의 데스크탑 위젯을 사용하여슈퍼클럭주제, 추가 미세 조정이 필요할 수 있으며 명령의 터미널 출력을 확인하여 여기에 사용된 변수가 다른 시스템에서도 작동하는지 확인하는 것이 좋습니다.xrandr