常にLVDS画面にのみconkyを表示

常にLVDS画面にのみconkyを表示

.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

私の画面の上部には次のように表示されます。

ここに画像の説明を入力してください。

ここで、外部モニターが接続されている場合は、両方の画面に表示されず、常に内部LVDS画面に表示されるようにconky barを制限したいと思います。

conkyに常にLVDSを維持するように指示できますか?

ベストアンサー1

はい。ディスプレイを一番左/一番右に設定する必要がありますconky。詳細は、ノートパソコンの画面が右側か左側かによって異なります。たとえば、私の設定では、私のラップトップは左側にあり、VGA画面は右側にあります(+1600VGAエントリを参照)。

$ 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いくら多くの画面を接続しても、私の画面は常に同じ場所に表示されます。


ノートブックの位置が変わる可能性がある場合は、より洗練されたデバイスが必要になります。たとえば、2つの画面があることを確認し、ノートブックが左右にあることを確認し、.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スクリプトの使用を開始したら、現在の設定に従ってスクリプトを正しく配置する必要があります。特定の状況に合わせて若干の調整が必要な場合があります。助けが必要な場合はお知らせください。

おすすめ記事