lahwaacz / sxlock

MIT License
41 stars 21 forks source link

do include the last element of the outputs array #18

Closed amkhlv closed 7 years ago

amkhlv commented 7 years ago

I think there was a bug; the program was exiting from the loop prematurely, discarding the last element of the array of display outputs. Please consider my proposed correction.

lahwaacz commented 7 years ago

C arrays are indexed starting with 0, so the last valid index of an array with N elements is N - 1. So we must terminate the loop when the index reaches N.

amkhlv commented 7 years ago

Yes, you are right. However, your code does not work on my machine. The output is: Warning: no primary output detected, trying VGA-0. Warning: no primary output detected, trying HDMI-0. sxlock: error: no connected output detected. (I have 2 video outputs; only the second one (HDMI) is connected). Apparently, for some reason noutput is set to 1 .
But, you are right, my proposed change is wrong. The question is, what to do?

lahwaacz commented 7 years ago

What is your system (video driver etc)? What does xrandr --listproviders show?

amkhlv commented 7 years ago

description: Desktop Computer product: Infoway SM-3330 vendor: Itautec S.A. version: Corp serial: 4002683100205 width: 64 bits capabilities: smbios-2.5 dmi-2.5 smp vsyscall32 configuration:
boot = normal chassis = desktop family = N/A

id:
core description: Motherboard product: SM 3330 vendor: Itautec S.A. physical id:
0 version: SM-3330 Padrao 01(Itautec_M) serial: Serial. slot: To Be Filled By O.E.M. id:
firmware description: BIOS vendor: Itautec SM3330 physical id:
0 version: 0112 date: 01/20/2011 size: 64KiB capacity: 960KiB capabilities: isa pci pnp apm upgrade shadowing escd cdboot bootselect socketedrom edd int13floppy1200 int13floppy720 int13floppy2880 int5printscreen int9keyboard int14serial int17printer int10video acpi usb ls120boot zipboot biosbootspecification

id:
cpu description: CPU product: AMD Phenom(tm) II X2 550 Processor vendor: Advanced Micro Devices [AMD] physical id:
4 bus info:
cpu@0 version: AMD Phenom(tm) II X2 550 Processor serial: To Be Filled By O.E.M. slot: CPU 1 size: 1900MHz capacity: 3100MHz width: 64 bits clock: 200MHz capabilities: x86-64 fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp 3dnowext 3dnow constant_tsc rep_good nopl nonstop_tsc extd_apicid eagerfpu pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt hw_pstate vmmcall npt lbrv svm_lock nrip_save cpufreq configuration:
cores = 2 enabledcores = 2

id:
display description: VGA compatible controller product: RS880 [Radeon HD 4250] vendor: Advanced Micro Devices, Inc. [AMD/ATI] physical id:
5 bus info:
pci@0000:01:05.0 version: 00 width: 32 bits clock: 33MHz capabilities: pm msi vga_controller bus_master cap_list rom configuration:
driver = radeon latency = 0 resources:
irq : 18 memory : f8000000-fbffffff ioport : b000(size=256) memory : fe6f0000-fe6fffff memory : fe500000-fe5fffff memory : c0000-dffff

lahwaacz commented 7 years ago

What is the video driver and its version? Which OS? What does xrandr --listproviders show?

amkhlv commented 7 years ago

Debian Stretch (i.e. still testing, but supposedly frozen),

VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] RS880 [Radeon HD 4250]

xserver-xorg-video-radeon 1:7.8.0-1+b1

https://wiki.freedesktop.org/xorg/RadeonFeature/

Providers: number : 1 Provider 0: id: 0x53 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 2 associated providers: 0 name:ATI Radeon HD 4250 @ pci:0000:01:05.0

amkhlv commented 7 years ago

~# modinfo radeon filename: /lib/modules/4.9.0-1-amd64/kernel/drivers/gpu/drm/radeon/radeon.ko license: GPL and additional rights description: ATI Radeon author: Gareth Hughes, Keith Whitwell, others.

amkhlv commented 7 years ago

Possibly important detail: the monitor input is actually DVI. And the second motherboard output is HDMI. (The first output is a usual VGA, unused.) So, I connect them by an HDMI-to-DVI cable.

lahwaacz commented 7 years ago

Hmm, it might be due to the HDMI-to-DVI cable. Does xrandr say that the HDMI output is connected or disconnected? sxlock should detect the same.

You might let sxlock know which output to use by configuring the HDMI output as primary with xrandr --output HDMI-0 --primary.

amkhlv commented 7 years ago

xrandr says:

  HDMI-0 connected 1440x900+0+0 (normal left inverted right x axis y axis) 410mm x 257mm
amkhlv commented 7 years ago

Yes, xrandr --output HDMI-0 --primary helps ! Problem solved. Please tell me, for completeness, where should I put that line xrandr --output HDMI-0 --primary , to make this permanent under reboot?

lahwaacz commented 7 years ago

For example in xinitrc or the configuration file of whatever window manager you have on your system.