Skip to content

Commit

Permalink
Merge pull request #10 from roles-ansible/dev
Browse files Browse the repository at this point in the history
adding multiuser support, updating some values
  • Loading branch information
DO1JLR authored Aug 1, 2023
2 parents b47b7e2 + b1d4540 commit abf9460
Show file tree
Hide file tree
Showing 21 changed files with 586 additions and 221 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/ansible-centos-centos7.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/ansible-centos-centos8.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/ansible-centos-centos9.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/ansible-centos-latest.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/ansible-fedora-31.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/ansible-fedora-32.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/ansible-fedora-33.yml

This file was deleted.

14 changes: 6 additions & 8 deletions .github/workflows/ansible-linting-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,22 @@
name: Ansible Lint check

# yamllint disable-line rule:truthy
on:
push:
branches: '*'
pull_request:
branches: '*'
on: [push, pull_request]

jobs:
build:

name: Ansible Lint
runs-on: ubuntu-latest

steps:
- name: 'Checkout git repo'
- name: 'checkout git repo'
uses: actions/checkout@v3
with:
lfs: true
submodules: false
fetch-depth: 0

- name: 'Lint Ansible Playbook'
uses: ansible/ansible-lint-action@v6
with:
targets: "."
path: "."
47 changes: 31 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,35 @@ Install and deploy a basic configuration of [I3 Window Manager](https://i3wm.org
Optionally configure your resolution, which applications will be bound to which screen and what will be included in the autostart.<br/>
If you want to use wayland instead of xorg, think about using [sway](https://swaywm.org/) as window manager. The corresponding ansible is located on [github.com/roles-ansible/role-sway](https://github.com/roles-ansible/role-sway.git).

[![MIT License](https://raw.githubusercontent.com/chaos-bodensee/role-i3wm/master/.github/license.svg?sanitize=true)](https://github.com/chaos-bodensee/role-i3wm/blob/master/LICENSE)
[![MIT License](https://raw.githubusercontent.com/chaos-bodensee/role-i3wm/master/.github/galaxy.svg?sanitize=true)](https://galaxy.ansible.com/do1jlr/i3wm)

### Get it directly from Ansible Galaxy
```bash
$ ansible-galaxy install do1jlr.i3wm
$ ansible-galaxy install l3d.i3wm
```

Role Variables
--------------

For a good overview about possible variables, please have a look into ``defaults/main.yml``.

Example Playbook
----------------

Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:

## Example Usage
```yaml
- name: install i3wm on localhost
hosts: localhost
vars_files:
- vars/main.yml
roles:
- {role: do1jlr.i3wm, tags[i3,i3wm]}
- name: install i3wm on localhost
hosts: localhost
vars_files:
- vars/main.yml
roles:
- {role: l3d.i3wm, tags[i3, i3wm]}
```
*`vars/main.yml`*

```yaml
# User List for i3wm config
i3wm_user_list:
- user: "alice"
home: "/home/alice"
- user: "bob"
home: "/home/bob"
# background image
i3_desktop_background: "~/Bilder/wallpaper.jpg"
Expand Down Expand Up @@ -82,6 +82,21 @@ Including an example of how to use your role (for instance, with variables passe
workspace: 7
on_startup: true
# lock your screen after 3 hours
# lock your screen after 90 min
enable_lock_after_time: true
files/rofi/dracula_dark.rasi
# enable multiple i3blocks options
i3_i3blocks_options:
weather: true
audio_volume: true
wifisignal: true
ipaddress: true
clock: true
battery: true
ddate: true
# choose rofi theme
i3_rofi_config_file: 'files/rofi/dracula_dark.rasi'
```
30 changes: 23 additions & 7 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ i3_keybindings_extra: []
# key: $mod+Shift+F10
# exec: --no-startup-id touch /tmp/example.txt

i3_monitors: [] # see: xrandr
i3_monitors: []
# see: xrandr
# - monitor:
# id: 1
# output: "VGA-1"
Expand All @@ -27,30 +28,45 @@ i3_run_on_startup: []
# - foo
# - bar

# which user are we?
i3wm_user: "{{ ansible_user_id }}"
# deploy config to these users:
i3wm_user_list:
- user: "{{ ansible_user_id }}"
home: "{{ ansible_env.HOME | default('/home/{{ ansible_user_id }}') }}"

## set default font size
i3_font_size: 9
i3_font_size: 11
i3_focus_follows_mouse: true

# set i3lock options
i3lock_options: "i3lock --image=/home/{{ i3wm_user }}/.config/lockscreen.png --color 000000"
i3lock_options: "i3lock --image={{ i3wm_usr.home }}/.config/lockscreen.png --color 000000"

# use fancy background
i3_desktop_background: "/home/{{ i3wm_user }}/.config/background.png"
i3_desktop_background: "{{ i3wm_usr.home }}/.config/background.png"

# i3blocks options
i3_i3blocks_options:
weather: true
audio_volume: true
wifisignal: true
ipaddress: true
clock: true
battery: true
ddate: true

i3_rofi_config_file: 'files/rofi/dracula_dark.rasi'

i3_terminal: "terminator"

# install additional packages
i3_packages_extra:
- ranger
- fonts-fork-awesome

i3wm_copy_wallpapers: true

disable_screensaver: true
enable_lock_after_time: false
lock_after_time: '200' # minutes to wait until your screen is locked
lock_after_time: '90' # minutes to wait until your screen is locked

# version check for this role?
submodules_versioncheck: true
84 changes: 84 additions & 0 deletions files/i3blocks/battery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env python3
"""
battery for i3blocks
"""

import subprocess
import sys

def get_battery_info():
status = subprocess.check_output(['acpi'], universal_newlines=True)

if not status:
# -> keine Batterie gefunden
text_output = "<span color='red'><span font='FontAwesome'>\uf00d \uf240</span></span>"
battery_percent = 100
else:
# -> auswertung der batteriedaten
batteries = status.strip().split("\n")
state_batteries = []
battery_percent_batteries = []

for battery in batteries:
if battery:
state_batteries.append(battery.split(": ")[1].split(", ")[0])
commasplitstatus = battery.split(", ")
battery_percent_batteries.append(int(commasplitstatus[1].rstrip("%\n")))

state = state_batteries[0]
battery_percent = int(sum(battery_percent_batteries) / len(battery_percent_batteries))

# stands for charging
fa_lightning = "<span color='yellow'><span font='FontAwesome'>\uf0e7</span></span>"

# stands for plugged in
fa_plug = "<span font='FontAwesome'>\uf1e6</span>"

text_output = ""
battery_remaining_time = ""

if state == "Discharging":
battery_time = batteries[0].split()[-2]
battery_remaining_time = f" ({battery_time})"
elif state == "Full":
text_output = fa_plug + " "
elif state == "Unknown":
text_output = "<span font='FontAwesome'>\uf128</span> "
else:
text_output = fa_lightning + " " + fa_plug + " "

def get_color(percent):
"""
-> color based on battery state
"""
color_mapping = {
16: "#FFFFFF",
24: "#FF3300",
32: "#FF6600",
40: "#FF9900",
50: "#FFCC00",
60: "#FFFF00",
70: "#FFFF33",
80: "#FFFF66"
}

for threshold, color_code in color_mapping.items():
if percent < threshold:
return color_code

return "#FFFFFF"

battery_form_string = '<span color="{}">{}%</span>'
text_output += battery_form_string.format(get_color(battery_percent), battery_percent)
text_output += battery_remaining_time

return text_output

if __name__ == "__main__":
text_output = get_battery_info()
print(text_output)
print(text_output)

if "battery_percent" in locals() and battery_percent < 16:
sys.exit(33)

Loading

0 comments on commit abf9460

Please sign in to comment.