1

I use the following settings in my .conkyrc to display a top bar on my laptop screen (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

It is displayed as follows at the top of my screen:

enter image description here

Now when plugging in an external monitor, I want to restrict the conky bar always to just my internal LVDS screen instead of displaying it across both screens.

Is it possible to tell conky to always stay on LVDS?

  • What windows manager are you running? In some, you can add window-specific rules to restrict a certain window to one output. – psimon Jun 25 '14 at 14:16
  • I am using Openbox. However, as far as I know I only can set rules for Openbox's internal workspaces but not screens, correct? – orschiro Jun 25 '14 at 14:31
  • Take a look at this thread on Arch Forums. – psimon Jun 25 '14 at 14:32
  • 1
    How are your screens set up? Is the laptop's on the left or right? Is that stable? – terdon Jun 25 '14 at 14:42
  • Good point. The laptop's is not stable but can sometimes be either on the left or right. – orschiro Jun 25 '14 at 14:44
1

Yes. You need to set conky to display at the far left/right. The details will depend on whether the laptop screen is on the right or the left hand side. For example, in my setup, I have my laptop on the left and a VGA screen on the right (note the +1600 in the VGA's entry):

$ 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

I want my conky to always appear on the right edge of my laptop's screen. I have therefore set up my .conkyrc like so:

gap_x 1365
gap_y 40

The gap_x parameter is the number of pixels from the left-most edge of your screen(s). Therefore, my conky always appears at the same place, irrespective of how many screens I have attached.


If the laptop can change position, you'll need something more sophisticated. For example, you could check whether there are two screens and then check if the laptop is on the left or right and edit your .conkyrc accordingly, then launch .conky. Something like:

#!/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 &

If you start your conky using that script, it should position it correctly depending on your current setup. This may need some tweaking to fit your specific case, let me know if you need help with it.

  • Can negative numbers be used in case we want it on the right side? – psimon Jun 25 '14 at 14:42
  • 1
    @psimon I don't think so, no. Just use $WidthOfScreen+X – terdon Jun 25 '14 at 14:43
  • Thanks @terdon! Is it possible to make your solution more flexible in that it works with my laptop being either on the left or right? I use my laptop sometimes on the right, sometimes on the left. – orschiro Jun 25 '14 at 14:47
  • 1
    @orschiro see updated answer. – terdon Jun 25 '14 at 15:31
  • @terdon Thanks! xrandr | grep LVDS | cut -d ' ' -f 3 | cut -d+ -f 3 reports 0. cat .conkyrc | grep gap_x reports gap_x 10. However, conky is still only shown on the external screen on the left. – orschiro Jun 25 '14 at 16:07
0

Since version 1.10 you can use "xinerama_head = <nr>" in your conky.config to specify a specific output.

I had to use this to force conky onto my laptop panel when an external monitor is attached, as I make it my main monitor with my laptop on the left. So although the monitor has an x position of +1920, conky shows up on it without the xinerama_head option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.