-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.yml
65 lines (56 loc) · 1.68 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
- name: install packages needed to take a screenshot
package:
name:
- konsole
- imagemagick
- neofetch
- procps # for process management
- xorg-server-xvfb
- xorg-font-util
- xorg-xdpyinfo
- ttf-hack # the terminal font I use
state: present
update_cache: true
become: true
- name: copy over a custom neofetch config for the screenshot
copy:
src: config.conf
dest: "{{ ansible_env.HOME }}/.config/neofetch/"
mode: 0644
- name: check for existing xvfb server
command: xdpyinfo -display :{{ display_server }}
register: xserver_running
failed_when: xserver_running.rc > 1 # 1 will be returned when a display server is not found
changed_when: false
- name: start xvfb server
shell: "Xvfb :{{ display_server }} -screen 0 640x480x24 &"
when: '"unable to open display" in xserver_running.stderr'
changed_when: false
- name: start terminal
shell: konsole --hide-menubar --hide-tabbar --noclose --fullscreen -e neofetch &
environment:
DISPLAY: :{{ display_server }}
changed_when: false
- name: get a temporary filename for the screenshot
tempfile:
state: file
suffix: ".png"
register: screenshot_file
changed_when: false
- name: take a screenshot
shell: import -trim -window root {{ screenshot_file.path }}
environment:
DISPLAY: :{{ display_server }}
- name: crop the screenshot
shell: mogrify -crop 620x250+0+0 {{ screenshot_file.path }}
- name: copy screenshot to local machine
fetch:
src: "{{ screenshot_file.path }}"
dest: screenshot.png
flat: true
validate_checksum: no
changed_when: false
- name: terminate xvfb server
command: pkill Xvfb
changed_when: false