
我使用以下設定在.conkyrc
筆記型電腦螢幕 (LVDS) 上顯示頂部欄。
background yes
update_interval 60
total_run_times 0
# Show umlauts
override_utf8_locale yes
# Font settings
use_xft yes
xftfont Noto Sans:style=normal:size=10
xftalpha 1
# Run in own window
own_window yes
own_window_class conky
own_window_type desktop
# Semi-transparent background
# http://th0th.me/log/conky-and-semi-transparency/
own_window_transparent no
own_window_argb_visual yes
own_window_argb_value 140
# Don't show in window lists and on all desktops
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
own_window_colour bcbcbc
double_buffer yes
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color 000000
alignment tl
maximum_width 1265
minimum_size 1265
#gap_x 10
gap_y 3
no_buffers yes
uppercase no
cpu_avg_samples 2
它在我的螢幕頂部顯示如下:
現在,當插入外部顯示器時,我想將 conky bar 始終限制在我的內部 LVDS 螢幕上,而不是在兩個螢幕上顯示。
- xrandr 的輸出未連接外部顯示器
- xrandr 的輸出外部連接,LVDS 位於右側
- xrandr 的輸出外部連接且 LVDS 位於左側
是否可以告訴 conky 始終保持在 LVDS 上?
答案1
是的。您需要設定conky
顯示在最左/最右。詳細資訊將取決於筆記型電腦螢幕位於右側還是左側。例如,在我的設定中,我的筆記型電腦位於左側,VGA 螢幕位於右側(請注意+1600
VGA 條目中的 ):
$ xrandr | grep -w connected
VGA-0 connected primary 1440x900+1600+0 (normal left inverted right x axis y axis) 408mm x 255mm
DP-3 connected 1600x900+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
我希望我的conky
始終出現在筆記型電腦螢幕的右邊緣。因此,我這樣設定.conkyrc
:
gap_x 1365
gap_y 40
此gap_x
參數是距螢幕最左邊緣的像素數。因此,conky
無論我連接了多少個螢幕,我的總是出現在同一個位置。
如果筆記型電腦可以改變位置,那麼您將需要更複雜的東西。例如,您可以檢查是否有兩個螢幕,然後檢查筆記型電腦是在左側還是右側並進行.conkyrc
相應的編輯,然後啟動.conky
.就像是:
#!/usr/bin/env bash
## Get the number of screens
screens=$(xrandr | grep -cw connected);
## If there's only one screen
if [ "$screens" -eq 1 ]
then
## Set the gap_x to ten pixels from the left.
sed -i.bak 's/gap_x .*/gap_x 110/' ~/.conkyrc
## If there are more than one screens
else
## Get the offset of the laptop's screen
pos=$(xrandr | grep LVDS1 | cut -d ' ' -f 4 | cut -d+ -f 2)
## Is the laptop on the left?
if [ "$pos" -eq 0 ]
then
## Set the gap_x to ten pixels from the left.
sed -i.bak 's/gap_x .*/gap_x 10/' ~/.conkyrc
else
## Use the offset to set conky's position accordingly.
offset=$((pos+10));
sed -i.bak "s/gap_x .*/gap_x $offset/" ~/.conkyrc
fi
fi
killall -9 conky
conky &
如果您開始conky
使用該腳本,它應該根據您當前的設定正確定位它。這可能需要一些調整以適合您的特定情況,如果您需要幫助,請告訴我。
答案2
從版本 1.10 開始,您可以在 conky.config 中使用「xinerama_head = <nr>」來指定特定輸出。
當連接外部顯示器時,我必須使用它來強制 conky 到我的筆記型電腦面板上,因為我將其作為我的主顯示器,筆記型電腦位於左側。因此,儘管顯示器的 x 位置為 +1920,但 conky 在沒有 xinerama_head 選項的情況下顯示在顯示器上。