mirror of
https://github.com/roles-ansible/ansible_role_sway.git
synced 2024-08-16 13:49:49 +02:00
Merge pull request #1 from roles-ansible/kkup
Change Key bindings and create custom/ping widget
This commit is contained in:
commit
66376ecbff
9 changed files with 81 additions and 2 deletions
|
@ -27,6 +27,7 @@ sway__waybar_modules_right:
|
||||||
- "custom/weather"
|
- "custom/weather"
|
||||||
- "pulseaudio"
|
- "pulseaudio"
|
||||||
- "network"
|
- "network"
|
||||||
|
- "custom/ping"
|
||||||
- "cpu"
|
- "cpu"
|
||||||
- "memory"
|
- "memory"
|
||||||
- "disk"
|
- "disk"
|
||||||
|
@ -90,7 +91,7 @@ sway__keybindings:
|
||||||
exec: --no-startup-id light -A 6
|
exec: --no-startup-id light -A 6
|
||||||
- keybinding:
|
- keybinding:
|
||||||
name: display settings
|
name: display settings
|
||||||
key: XF86WakeUp
|
key: $mod+Shift+F7
|
||||||
exec: wdisplays
|
exec: wdisplays
|
||||||
|
|
||||||
sway__keybindings_extra: []
|
sway__keybindings_extra: []
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
mode: '0640'
|
mode: '0640'
|
||||||
owner: "{{ swayusr.user }}"
|
owner: "{{ swayusr.user }}"
|
||||||
group: "{{ swayusr.user }}"
|
group: "{{ swayusr.user }}"
|
||||||
|
backup: true
|
||||||
loop: "{{ sway__user_list | flatten(1) }}"
|
loop: "{{ sway__user_list | flatten(1) }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ swayusr.home }}/.swaylock/config"
|
label: "{{ swayusr.home }}/.swaylock/config"
|
||||||
|
@ -68,6 +69,7 @@
|
||||||
mode: '0640'
|
mode: '0640'
|
||||||
owner: "{{ swayusr.user }}"
|
owner: "{{ swayusr.user }}"
|
||||||
group: "{{ swayusr.user }}"
|
group: "{{ swayusr.user }}"
|
||||||
|
backup: true
|
||||||
loop: "{{ sway__user_list | flatten(1) }}"
|
loop: "{{ sway__user_list | flatten(1) }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ swayusr.home }}/.config/sway/config"
|
label: "{{ swayusr.home }}/.config/sway/config"
|
||||||
|
|
|
@ -23,3 +23,4 @@
|
||||||
mode: '0640'
|
mode: '0640'
|
||||||
owner: "{{ swayusr.user }}"
|
owner: "{{ swayusr.user }}"
|
||||||
group: "{{ swayusr.user }}"
|
group: "{{ swayusr.user }}"
|
||||||
|
backup: true
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
- 'swayimg'
|
- 'swayimg'
|
||||||
- 'wdisplays'
|
- 'wdisplays'
|
||||||
- 'cmatrix'
|
- 'cmatrix'
|
||||||
|
- 'pavucontrol'
|
||||||
|
|
||||||
- name: Ensure font-awesome is installed
|
- name: Ensure font-awesome is installed
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
|
|
|
@ -25,6 +25,17 @@
|
||||||
mode: '0750'
|
mode: '0750'
|
||||||
owner: "{{ swayusr.user }}"
|
owner: "{{ swayusr.user }}"
|
||||||
group: "{{ swayusr.user }}"
|
group: "{{ swayusr.user }}"
|
||||||
|
backup: true
|
||||||
|
|
||||||
|
- name: Deploy ping script
|
||||||
|
become: true
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: 'templates/ping.py.j2'
|
||||||
|
dest: "{{ swayusr.home }}/.config/waybar/ping.py"
|
||||||
|
mode: '0750'
|
||||||
|
owner: "{{ swayusr.user }}"
|
||||||
|
group: "{{ swayusr.user }}"
|
||||||
|
backup: true
|
||||||
|
|
||||||
- name: Deploy waybar stylesheet
|
- name: Deploy waybar stylesheet
|
||||||
become: true
|
become: true
|
||||||
|
@ -34,6 +45,7 @@
|
||||||
mode: '0640'
|
mode: '0640'
|
||||||
owner: "{{ swayusr.user }}"
|
owner: "{{ swayusr.user }}"
|
||||||
group: "{{ swayusr.user }}"
|
group: "{{ swayusr.user }}"
|
||||||
|
backup: true
|
||||||
|
|
||||||
- name: Deploy waybar config
|
- name: Deploy waybar config
|
||||||
become: true
|
become: true
|
||||||
|
@ -43,3 +55,4 @@
|
||||||
mode: '0640'
|
mode: '0640'
|
||||||
owner: "{{ swayusr.user }}"
|
owner: "{{ swayusr.user }}"
|
||||||
group: "{{ swayusr.user }}"
|
group: "{{ swayusr.user }}"
|
||||||
|
backup: true
|
||||||
|
|
43
templates/ping.py.j2
Normal file
43
templates/ping.py.j2
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
"""
|
||||||
|
ping waybar widget
|
||||||
|
{{ ansible_managed }}
|
||||||
|
"""
|
||||||
|
import subprocess
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def check_internet():
|
||||||
|
"""
|
||||||
|
Try to ping a host in the internet,
|
||||||
|
then return true or false
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
subprocess.check_call(['ping', '-c', '2', 'c3woc.de'],
|
||||||
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
return True
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""
|
||||||
|
parsing internet status and create output
|
||||||
|
"""
|
||||||
|
internet_status = check_internet()
|
||||||
|
if internet_status:
|
||||||
|
status = {
|
||||||
|
"text": "Online",
|
||||||
|
"tooltip": "Internet connection is active",
|
||||||
|
"class": "pingonline"
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
status = {
|
||||||
|
"text": "Offline",
|
||||||
|
"tooltip": "No internet connection",
|
||||||
|
"class": "pingoffline"
|
||||||
|
}
|
||||||
|
print(json.dumps(status))
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
|
@ -280,3 +280,15 @@ label:focus {
|
||||||
#scratchpad.empty {
|
#scratchpad.empty {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pingonline {
|
||||||
|
color: white;
|
||||||
|
background-color: #2980b9;
|
||||||
|
padding: 0px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pingoffline {
|
||||||
|
color: white;
|
||||||
|
background-color: #f53c3c;
|
||||||
|
padding: 0px 8px;
|
||||||
|
}
|
||||||
|
|
|
@ -166,6 +166,12 @@
|
||||||
"format": "",
|
"format": "",
|
||||||
"on-click": "wlogout",
|
"on-click": "wlogout",
|
||||||
"tooltip": false
|
"tooltip": false
|
||||||
|
},
|
||||||
|
"custom/ping": {
|
||||||
|
"format": "{}",
|
||||||
|
"exec": "{{ swayusr.home }}/.config/waybar/ping.py",
|
||||||
|
"interval": 60,
|
||||||
|
"return-type": "json"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
---
|
---
|
||||||
playbook_version_number: 10 # should be int
|
playbook_version_number: 11 # should be int
|
||||||
playbook_version_path: 'role-roles-ansible.sway.version'
|
playbook_version_path: 'role-roles-ansible.sway.version'
|
||||||
|
|
Loading…
Reference in a new issue