Steeph's Web Site

Menu

Entries tagged 'cat:Linux' (Page 3)

Setting Screen Brightness To Any Value With A Three-Step Keyboard Shortcut (Linux)

Initially out of necessity because the brightness keys of my new laptop didn't work out of the box (the driver was aded to my distro not a month later, which should have been acceptable, but I didn't know that at first), I was looking for a way to set the backlight brighness of my laptop's internal screen easily, without typing a command in a shell. What I ended up using I like even better than the usual + and - keys.

I'm using i3wm and dmenu. The way I set screen brightness is

  • 1) I enter the shortcut (mod+B in my case)
  • 2) I enter a number and
  • 3) I hit Enter.
  • It's simple to implement. Just put this line in the i3 config file:

    
    bindsym $mod+b exec \
      thatbright=$(echo "1000\n2000\n3000\n4000\n5000\n6000\n7000\n100\n10" \
      | dmenu -p "How bright though?") && echo $thatbright \
      > /sys/class/backlight/*/brightness
    

    You can put it into one line (without the \s inbetween) if you want.

    You could easily change that to a two-step or single shortcut if you like. I like the three-step version because it allows me to choose from one of seven brightness modes easily but also lets me enter a value below or between those pre-sets without taking up more than one key.

    Code Explanation

    First, the variable thatbright is set to the number that dmenu outputs, which can be one of the numbers that are echoed to the pipe (selected with arrow keys or completed when typed in dmenu) or another number that is entered into dmenu. If that was suggessful, the value is written to /sys/class/backlight/*/brightness. If you have multiple backlights in /sys/class and you only want to set one or if your shell doesn't support wild cards in paths, you can change the * to whatever applies to your system, e.g. intel_backlight.

    Scripts/Commands to set the screen brightness

    The simplest script that sets the screen brightness in Linux is probably the one-liner from above: echo $1 > /sys/class/backlight/*/brightness. This sets the raw numerical value. You need to know what a sensible range of numbers is and what the maximal accepted value is (look at '/sys/class/backlight/[YOUR_BACKLIGHT]/max_brightness'). But there are more elaborate scripts, like bbacklight by Giuseppe Eletto with which you set the brightness with a percentage value.

    SBWG 0.8.10

    So, I'm still making slow process with SBWG. I had more fun with it when I was out and implementing new features. But I find it important to finish version 1.0.0 with the currently defined set of festures and goals, which include finishing documentation, testing and code hardening, which are less fun for me.

    I've always treated the third level of the version number (x.x.thisone) as a means to declare a new version done when I feel like having achived something. So today I declare version 0.8.10 as done. There really isn't much left to do to meet my milestones for v0.9.0. And from there on it will only be testing and possibly a little bit of code improvements to get to my set goals for v1.0.0.

    I'm looking forward to this not only because I'll like the feeling of having achived a goal, but also it will mean that I'll be free again to introduce new features. I still have more ideas than necessary about what to do with SBWG.

    But right now I'm enjoing the fact that I'm able to make myself believe that it's okay to move on as slowly as I want and let my colloquial executive dysfunction do its think without impacting my feeling of self-worth oo much.

    SBWG 0.8.9

    Lately I'm making only slow progress with SBWG. I'm determined to make this something that I'm comfortable with sharing as 1.0.0 online. Something that works and could arguably be called a somewhat finished peace of software. That doesn't mean that the todo list won't be huge at the point I change the version number to 1.0.0. But it should be in a relatively good state for what I've decided it will encompass at version 1.0.0. "Relatively" because it's still also a learning project and I would write many things differently if I started over, which means I'll have to rewrite them at some point to be satisfied with SBWG.

    So, the goal and roadmap is set for v0.9.0 and v1.0.0 and a large part of what is still to be done is documentation and other things I don't enjoy doing as much as starting to implement new features. I'm holding back on working on things that are not on that roadmap so that I don't introduce new bugs and the need of further testing. First I want to improve what SBWG can already do.

    That means that there won't be many interesting changes in the coming weeks (or maybe even months). Today I've decided to call what I've currently got version 0.8.9 and publish it on the project page.

    SBWG update - version 1.0 takes shape slowly

    I rarely wrote updates on SBWG before now. I just worked on it whenever I had time and felt like it. And that was quite often. But this is my website where I want to feel fine with pretending that what I'm posting is of any real interest to anybody. So I may post more updates on what I did to approach my goals for SBWG 1.0 from now on. It is rare for me that I invest so much time in a single project. And since I'm starting this blog at the same time and want to fill it with a lot of content, it is time to combine the two.

    Some things that I did and changed but didn't report on so far: The header format of entry and page source files has been changed completely (simplified), the generated HTML became more complete, the idea of a sourced settings file came (first to me, then reality), new tag types have been formed, the sorting of blog entries is much more mature now, many more customisation possibilities cropped up and I developed an overall vision of what SBWG will become.

    The code grew so much over the time. But it was mostly for very good reasons. I'm feeling overall quite content with how clean the code became and how many contingencies I took into account. It's probably still not "professional" code. But it is a new level of professionalism for me and my Bash scripts. Should I ever come close to getting through all the tiny, small, irrelevant, important, stupid, huge, new and old to-dos, it would probably be quite presentable. So many small features have been added that I hadn't thought of when I startet to write SBWG. Multi-author blogs are supported now, tags can be substituted for icons, a basic RSS feed works, ...

    SBWG - Topic Tagpage Sorting

    The way tagpages of topic (top:) tags are displayed is pretty much complete and the way I intended it to look when I first thought of splitting blog entry tags into two tag types. Basically, categories (cat: tags) are like classic tags in blogs: a way to add keywords to entries and list all entries that are tagged with that keyword. Topic tags on the other hand are meant to tag entries that talk about a certain topic about which a visitor might want to read up regardless of when individual entries on the topic have been posted. A topic tapage represents an index on a topic. It lists all the entries that are relevant to the topic in a structured way. You could write a book, one chapter per blog entry and have it simultaniously presented as a weblog (with category tags) and as a orderly indexed book in which visitors up a certain chapter. I still have to make up my mind on how I want to structure my own blog entries. But the fuctionality in the software is there. I will very likely also add another feature that enables structuring entries and pages into custom menues. So the options for web site builders will be grand with this weird took.