Coder Social home page Coder Social logo

3 Monitor Support? about brightness HOT 39 CLOSED

lordamit avatar lordamit commented on September 28, 2024
3 Monitor Support?

from brightness.

Comments (39)

xSeekTruthx avatar xSeekTruthx commented on September 28, 2024

I tried modifying, but it just runs in the background for a little, and then quits out..... Please let me know what you think? I hope this is ok with you that I tried this. @LordAmit Thank you

`#! /usr/bin/python

-- coding:utf-8 --

import wx
import subprocess
from os import system

class BrightnessController(wx.Frame):

def debug_true(self):
    return False

def detect_display_devices(self):
    """Detects available displays"""
    connected_devs = []

    xrandr_output = subprocess.check_output('xrandr -q', shell=True)

    lines = xrandr_output.split('\n')
    for line in lines:
        words = line.split(' ')
        for word in words:
            if word == 'connected':
                connected_devs.append(words[0])
    return connected_devs

def __init__(self, parent, title):
    super(BrightnessController, self).__init__(parent, title=title,
                                               size=(325, 150))
    self.SetMinSize((325, 150))
    self.SetMaxSize((325, 150))
    self.detected_devices = self.detect_display_devices()
    self.no_of_detected_device = len(self.detected_devices)

    if self.no_of_detected_device == 1 or self.no_of_detected_device == 2 or self.no_of_detected_device == 3:
        if self.debug_true():
            print 'Found one'
        self.primary_name = self.detected_devices[0]
    else:
        self.primary_name = 'Not found'
    if self.no_of_detected_device == 2 or self.no_of_detected_device == 3:
        if self.debug_true():
            print 'Found two'
        self.secondary_name = self.detected_devices[1]
    else:
        self.secondary_name = 'Not found'
 if self.no_of_detected_device == 3:
        if self.debug_true():
            print 'Found three'
        self.third_name = self.detected_devices[2]
    else:
        self.third_name = 'Not found'

    self.array_value = 0.00
    self.cmds_primary_display = []
    self.cmds_secondary_display = []
self.cmds_third_display = []

    for i in xrange(0, 101):
        cmd_primary_display = "xrandr --output \
            %s --brightness %s" % (self.primary_name, self.array_value)
        cmd_secondary_display="xrandr --output \
            %s --brightness %s" % (self.secondary_name, self.array_value)
        cmd_third_display="xrandr --output \
            %s --brightness %s" % (self.third_name, self.array_value)
        self.cmds_primary_display.append(cmd_primary_display)
        self.cmds_secondary_display.append(cmd_secondary_display)
    self.cmds_third_display.append(cmd_third_display)
        self.array_value += 0.01

    self.InitUI()
    self.Center()
    self.Show()

def InitUI(self):

    panel = wx.Panel(self)
    self.vbox = wx.BoxSizer(wx.VERTICAL)
    st4 = wx.StaticText(panel, label='', style=wx.ALIGN_CENTRE, size=(0, 20))
    self.vbox.Add(st4, flag=wx.Bottom, border=0)
    menubar = wx.MenuBar()
    help = wx.Menu()
    help.Append(100, '&About')
    self.Bind(wx.EVT_MENU, self.OnAboutBox, id=100)
    menubar.Append(help, '&Help')
    self.SetMenuBar(menubar)

    hbox1 = wx.BoxSizer(wx.HORIZONTAL)
    if self.no_of_detected_device == 1 or self.no_of_detected_device == 2 or self.no_of_detected_device == 3:
        st1 = wx.StaticText(panel, label='   Primary')
        hbox1.Add(st1, flag=wx.RIGHT | wx.TOP, border=3)
        slider1 = wx.Slider(panel,
                        value=100,
                        minValue=1,
                        maxValue=100,
                        size=(200, -1),
                        style=wx.SL_HORIZONTAL)

        hbox1.Add(slider1, flag=wx.LEFT,
              border=25)
        self.primary_status = wx.StaticText(panel, label='100')
        slider1.Bind(wx.EVT_SCROLL, self.primary_scroll)
        hbox1.Add(self.primary_status, flag=wx.TOP | wx.LEFT, border=3)
    else:
        st1 = wx.StaticText(panel, label='   Primary   Not Found')
        hbox1.Add(st1, flag=wx.RIGHT | wx.TOP, border=3)

    self.vbox.Add(hbox1)

    self.hbox2 = wx.BoxSizer(wx.HORIZONTAL)

    if self.no_of_detected_device == 2 or self.no_of_detected_device == 3:
        st2 = wx.StaticText(panel, label='   Secondary')
        self.hbox2.Add(st2, flag=wx.RIGHT | wx.TOP, border=3)
        slider2 = wx.Slider(panel,
                        value=100,
                        minValue=1,
                        maxValue=100,
                        size=(200, -1),
                        style=wx.SL_HORIZONTAL)
        self.hbox2.Add(slider2, flag=wx.LEFT,
              border=7)
        self.secondary_status = wx.StaticText(panel, label='100')
        self.hbox2.Add(self.secondary_status, flag=wx.TOP | wx.LEFT, border=3)

        slider2.Bind(wx.EVT_SCROLL, self.secondary_scroll)
    else:
        st2 = wx.StaticText(panel, label='   Secondary   Not found')
        self.hbox2.Add(st2, flag=wx.RIGHT | wx.TOP, border=3)

    self.vbox.Add(self.hbox2)

self.hbox3 = wx.BoxSizer(wx.HORIZONTAL)

    if self.no_of_detected_device == 3:
        st3 = wx.StaticText(panel, label='   Third')
        self.hbox3.Add(st3, flag=wx.RIGHT | wx.TOP, border=3)
        slider3 = wx.Slider(panel,
                        value=100,
                        minValue=1,
                        maxValue=100,
                        size=(200, -1),
                        style=wx.SL_HORIZONTAL)
        self.hbox3.Add(slider3, flag=wx.LEFT,
              border=7)
        self.third_status = wx.StaticText(panel, label='100')
        self.hbox3.Add(self.third_status, flag=wx.TOP | wx.LEFT, border=3)

        slider3.Bind(wx.EVT_SCROLL, self.third_scroll)
    else:
        st3 = wx.StaticText(panel, label='   Third   Not found')
        self.hbox3.Add(st3, flag=wx.RIGHT | wx.TOP, border=3)
    self.vbox.Add(self.hbox3)

    panel.SetSizer(self.vbox)

def primary_scroll(self, event):
    """Controls the brightness of primary monitor"""
    obj = event.GetEventObject()
    val = obj.GetValue()
    self.primary_status.SetLabel(str(val))

    system(self.cmds_primary_display[val])

def secondary_scroll(self, event):
    """Controls the brightness of secondary monitor"""
    obj = event.GetEventObject()
    val = obj.GetValue()
    self.secondary_status.SetLabel(str(val))

    system(self.cmds_secondary_display[val])

def OnAboutBox(self, event):
    
def third_scroll(self, event):
    """Controls the brightness of third monitor"""
    obj = event.GetEventObject()
    val = obj.GetValue()
    self.third_status.SetLabel(str(val))

    system(self.cmds_third_display[val])

def OnAboutBox(self, event):

    description = """CHANGED TO 3 MONITOR Brightness Controller allows you to control Brightness of your Primary and Secondary Display in Linux. It is a software based dimmer.

It allows you to control the brightness of your monitor to a better extent. For example, laptop's monitor brightness can be controlled using hardware keys at discrete values, such as 20%, 40%, 60%, ... 100%. Brightness Controller allows you to change the brightness to a better degree of control, ranging from 1% to 100%! It should be mentioned that it changes the present brightness value set via hardware control of your monitor. For example, if you set your Monitor's brightness to 50% using hardware buttons, then that will be the 100% value in Brightness controller.

Want to show appreciation for what we have done? Tell your friends about it.

Have troubles? Report an issue.
"""

    licence = """Brightness Controller is free software: you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Brightness Controller is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details. You should have
received a copy of the GNU General Public License along with Brightness Controller;
if not, see http://www.gnu.org/licenses/gpl.html or write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA"""

    info = wx.AboutDialogInfo()

    info.SetName('Brightness Controller')
    info.SetVersion('1.2.2')
    info.SetDescription(description)
    info.SetCopyright('(C) 2013 - 2016 Amit Seal Ami')
    info.SetWebSite('http://lordamit.github.io/Brightness/')
    info.SetLicence(licence)
    info.AddDeveloper('Amit Seal Ami <[email protected]>')
    info.AddDocWriter('Amit Seal Ami <[email protected]>')
    info.AddDocWriter('Zlatan Vasović <[email protected]>')
    info.AddDocWriter('Archisman Panigrahi <[email protected]>')
    info.AddArtist('Archisman Panigrahi <[email protected]>')

    wx.AboutBox(info)

if name == 'main':
app = wx.App()
BrightnessController(None, title='Brightness Controller')
app.MainLoop()`

from brightness.

archisman-panigrahi avatar archisman-panigrahi commented on September 28, 2024

You may try the HTML Version. https://www.dropbox.com/s/3rb1i0ost7n5qnu/brightness-controller_0.1_all.deb?dl=0

It lags a little, but works.

from brightness.

xSeekTruthx avatar xSeekTruthx commented on September 28, 2024

from brightness.

archisman-panigrahi avatar archisman-panigrahi commented on September 28, 2024

Set Monitor type DVI-D or HDMI, Monitor No. 0, and set value of brightness. Did that work?

from brightness.

LordAmit avatar LordAmit commented on September 28, 2024

Hi @xSeekTruthx , thank you for your feedback! Really appreciate it.

We moved on to the python-pyside based development approach for Brightness Controller because maintaining it through python-wxWidgets is comparatively harder. Since adding support for extra monitors is a highly demanded request - I will work on it for fixing for the python-PySide version (the beta you can see now).

There are a few things we would love to know from you:

  • The version of your python (type python -V in terminal)
  • The OS you are using

Oh, and trying to modify the code is absolutely fine. In fact, I encourage you to do so.
Who knows, you might end up being one of the developers of this project!! 😄

Can you please edit your comment, and use the code (you use it like this by using tilda symbols right below the Esc button: `code here` ) tags for the code segment? Otherwise, pasting them in plain-text version mixes up the indentations and becomes a bit confusing. I really want to take a look at what you changed 😄

from brightness.

xSeekTruthx avatar xSeekTruthx commented on September 28, 2024

@apandada1 You mean on the HTML version? If so, then no, it didn't work.

...I tried to edit previous comment with the code, and it still didn't put it in all code format.
Just realized I was replying in email so it changed it. I did the code in bracket thing originally... it still did it that way... I will try again.

Python - 2.7.6
Ubuntu - 14.04 LTS

from brightness.

LordAmit avatar LordAmit commented on September 28, 2024

@xSeekTruthx , can you please download the latest version and let us know if it works for you? 😄 We made an experimental release which will allow you to select any number of devices available.

from brightness.

xSeekTruthx avatar xSeekTruthx commented on September 28, 2024

Just tested out. It works on Ubuntu 14.04 LTS.
However...
I would Much rather use the old version with 1 additional monitor. The ease and simplicity of having 1 window with 3 sliders would be ideal.

The reason for this is because I can ALT + TAB to the app, then hit the tab key until focus is on the slider I want, without even physically seeing the app. The dual monitor function on 1.2.2 works great! I just need one more monitor. (no drop down selectors, no need for RGB) I change brightness frequently.

What sets your app apart from all the other brightness apps out there was it's simplicity and utilization of xrandr

from brightness.

LordAmit avatar LordAmit commented on September 28, 2024

Ah. Understandable. Simplicity is indeed the best attraction of this software.

Although even if I offer a simpler version of Brightness Controller with just Brightness options, it will still require drop down selectors, since there is no way to know in advance about how many monitors a user may have. We certainly didn't think that there will be people using 3-4 monitors when we started this humble project!

In future, the Brightness Controller v2 will be offering Brightness only sliders as the default view, with the current v2 view with colors as the advanced view.

@xSeekTruthx , thank you for your feedback and helping us make this better. We are really grateful. 😄

from brightness.

xSeekTruthx avatar xSeekTruthx commented on September 28, 2024

@LordAmit If possible, could you look over the code I submitted and tell me why it doesn't work for 3 monitors?

from brightness.

LordAmit avatar LordAmit commented on September 28, 2024

Of course, please rename the file you changed to .txt extension and upload it here.

from brightness.

xSeekTruthx avatar xSeekTruthx commented on September 28, 2024

Thank you. brightness-controller3.txt

from brightness.

LordAmit avatar LordAmit commented on September 28, 2024

here we go:

brightness-controller3.txt

Let me know what happens after you download, rename it with .py extension and then run it.

I focused on fixing the bugs first, but since I do not have a third monitor - I could not test it out.

from brightness.

xSeekTruthx avatar xSeekTruthx commented on September 28, 2024

Eureka! Works great! Thank you!
So what did I need to do? Just add that back slash?
if self.no_of_detected_device == 1 or \ self.no_of_detected_device == 2 or self.no_of_detected_device == 3:

Lastly, the position of the 3rd slider is not in line with the previous two, how could I fix that?

  • Scratch that. I see it now.

image

Thanks again!

from brightness.

xSeekTruthx avatar xSeekTruthx commented on September 28, 2024

Later I'm going to make it usable on up to 4 monitors, and then upload it back to you, in-case anyone else wants to use it.

from brightness.

LordAmit avatar LordAmit commented on September 28, 2024

😄 Do not forget to star this, and do not forget to spread words about it to your friends and family and everyone else! I am glad to help you out.

The backslash is used to indicate that the next line is actually part of the previous line. Otherwise, it will throw an error. In python, it is good practice to be within 80 characters per line.

About your code - there were some errors related to indentation. You see, function/condition and many other types of scopes are determined by the indentation in python. Probably you didn't know that and broke the code. I simply fixed those parts and modified it here and there and voila!

Credit goes to you for making my job easier by implementing the third monitor part. You did great 👏

Also, when you fix the position - send the code here so that I can merge it with the v1 code.

Looking forward to your contribution @xSeekTruthx 😄
I would love to have you as one of the contributors of this small, humble project.

from brightness.

xSeekTruthx avatar xSeekTruthx commented on September 28, 2024

@LordAmit Excellent! Thanks for the information and credit :). As you can tell. I've never done this before. I'm not a coder, just someone who looks for patterns and try's to repeat them.

It should work perfectly with a 4, and just say not found for those that don't use a 4th. So let me make that change today. Then I'll kick it back to you to fix my python errors :)

from brightness.

xSeekTruthx avatar xSeekTruthx commented on September 28, 2024

@LordAmit I've been using gedit to change the code. Made changes and didn't work, then I went back and tracked down my tabs and spacing. Fixed it! So here is the final code, on 4 monitors with fixed GUI.

brightness-controller4c.txt

Did some calculations/estimation for 4th slider position.
Made GUI a little shorter.

Cheers!

from brightness.

LordAmit avatar LordAmit commented on September 28, 2024

😄 I have checked it and it seems okay. This will be integrated with the v1 later.

you can try dedicated editors like VSCode to change python codes. You can get better if you are interested in it.

from brightness.

xSeekTruthx avatar xSeekTruthx commented on September 28, 2024

@LordAmit Thanks bud! I'm downloading it now. Because I made the 4 monitor change, can or do you add me to the credit of your app?

from brightness.

LordAmit avatar LordAmit commented on September 28, 2024

I will in the version 1.
BTW, if you want to be a contributor of version 2 and onwards - please start learning python+pyGTK3+Glade. Will help us a lot! 😄

from brightness.

xSeekTruthx avatar xSeekTruthx commented on September 28, 2024

@LordAmit Thank you, I will try to do what I can :) Do you need my email? or do you already have it? Can I send you a private message with my info?

from brightness.

LordAmit avatar LordAmit commented on September 28, 2024

I do not have your email address, and I don't think there is any way to send private messages in Github.

Please email me your information to amitsealami (at the rate ) gmail (D.O.T. ) com

from brightness.

xSeekTruthx avatar xSeekTruthx commented on September 28, 2024

from brightness.

archisman-panigrahi avatar archisman-panigrahi commented on September 28, 2024

from brightness.

LordAmit avatar LordAmit commented on September 28, 2024

@xSeekTruthx , please make another issue with the information 😄 We will be releasing the software after I take a look at this bug, so please bear with me, @apandada1 🐒

from brightness.

LordAmit avatar LordAmit commented on September 28, 2024

@xSeekTruthx , if you can - please pull the branch of v1, edit it with your monitor 4 support version, and then push it back so that I can get a pull request. if I merge it with v1 branch, your name will be visible as a contributor. 😄
This might help.
https://help.github.com/articles/creating-a-pull-request/

@apandada1 , I have not sent any pull request before, since I am the one always merging them. Can you please help him send his first pull request?

from brightness.

xSeekTruthx avatar xSeekTruthx commented on September 28, 2024

I tried twice. First I tried creating pull request, but that looked weird so I closed it. Then I just clicked on the brightness-controller inside v1 and edited, which created a fork, then I could propose pull request.

Hope that was correct.

from brightness.

LordAmit avatar LordAmit commented on September 28, 2024

yup, that worked. In your first attempt, you almost sent the pull request to merge the 4 monitor support to the v2.0 repo! 🦊

from brightness.

xSeekTruthx avatar xSeekTruthx commented on September 28, 2024

Interesting :). So do you change the version number? I didn't know if I should do that?

from brightness.

LordAmit avatar LordAmit commented on September 28, 2024

Nah, it was not a major change.

from brightness.

xSeekTruthx avatar xSeekTruthx commented on September 28, 2024

@LordAmit Then how would people with 4 monitors know there is an upgrade available? I want to tell people about it, but would like to let them know it's version 1.2.3 or 1.3 something like that, that shows a difference.

from brightness.

LordAmit avatar LordAmit commented on September 28, 2024

Sure, go ahead and make it v1.2.3 then. I will accept! 😄

from brightness.

xSeekTruthx avatar xSeekTruthx commented on September 28, 2024

@LordAmit ok thanks!

from brightness.

archisman-panigrahi avatar archisman-panigrahi commented on September 28, 2024

@xSeekTruthx This is how to send the pull request if you still have any problem.
pull

from brightness.

archisman-panigrahi avatar archisman-panigrahi commented on September 28, 2024

Should I upload this v1.2.3 to the PPA or wait a few days for finalising v2?

from brightness.

LordAmit avatar LordAmit commented on September 28, 2024

hmm, maybe we should offer a different ppa for v2? Libreoffice does something similar for its different versions.

from brightness.

archisman-panigrahi avatar archisman-panigrahi commented on September 28, 2024

We will upload v2 to the same PPA so that the huge number of people (this question has 11000 views) using it will be able to upgrade. Otherwise, they will never know there is a v2.

We can keep a revert back to previous version link. They will have to use a debian package or use v1 source.

from brightness.

LordAmit avatar LordAmit commented on September 28, 2024

In that case, we should offer previous versions in a different PPA and use the original PPA for providing the latest stable version. Should be helpful for the users! 😄

from brightness.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.