From 37b952c56666d394d34ec9a09b8b509b9aba70b5 Mon Sep 17 00:00:00 2001
From: Daniel M <daniel.q.mueller@stud.h-da.de>
Date: Thu, 27 Jan 2022 17:49:50 +0100
Subject: [PATCH] Add jupyter + mdbook shortcuts

---
 roles/jupyter-lab/files/jupyter.desktop |  7 +++++++
 roles/jupyter-lab/tasks/main.yml        |  7 +++++++
 roles/local-mdbook/files/book.desktop   |  7 +++++++
 roles/local-mdbook/tasks/main.yml       | 11 ++++++++++-
 4 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100644 roles/jupyter-lab/files/jupyter.desktop
 create mode 100644 roles/local-mdbook/files/book.desktop

diff --git a/roles/jupyter-lab/files/jupyter.desktop b/roles/jupyter-lab/files/jupyter.desktop
new file mode 100644
index 0000000..ce2ec96
--- /dev/null
+++ b/roles/jupyter-lab/files/jupyter.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Type=Application
+Name=Jupyter
+Comment=Jupyter Notebook
+Exec=xdg-open http://127.0.0.1:8888
+Icon=help-contents
+Terminal=false
\ No newline at end of file
diff --git a/roles/jupyter-lab/tasks/main.yml b/roles/jupyter-lab/tasks/main.yml
index 671048f..a09b15d 100644
--- a/roles/jupyter-lab/tasks/main.yml
+++ b/roles/jupyter-lab/tasks/main.yml
@@ -40,3 +40,10 @@
     state: started
     daemon_reload: true
   when: jupyter_service and jupyter_start
+
+- name: Copy desktop entry to desktop
+  become: true
+  become_user: "{{ target_user }}"
+  copy:
+    src: files/jupyter.desktop
+    dest: "/home/{{ target_user }}/Desktop/jupyter.desktop"
\ No newline at end of file
diff --git a/roles/local-mdbook/files/book.desktop b/roles/local-mdbook/files/book.desktop
new file mode 100644
index 0000000..c087d9a
--- /dev/null
+++ b/roles/local-mdbook/files/book.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Type=Application
+Name=Book
+Comment=mdBook Documentation of the AI at the Edge project
+Exec=xdg-open /home/pi/Documentation/public/index.html
+Icon=help-contents
+Terminal=false
\ No newline at end of file
diff --git a/roles/local-mdbook/tasks/main.yml b/roles/local-mdbook/tasks/main.yml
index 8f3c1cf..5ef1f7f 100644
--- a/roles/local-mdbook/tasks/main.yml
+++ b/roles/local-mdbook/tasks/main.yml
@@ -9,7 +9,16 @@
     state: directory
 
 - name: Download and extract mdbook artifacts
+  become: true
+  become_user: "{{ target_user }}"
   unarchive:
     src: "https://code.fbi.h-da.de/pse-ai-at-the-edge/ai-at-the-edge/-/jobs/artifacts/main/download?job=pages"
     dest: "/home/{{ target_user }}/Documentation"
-    remote_src: true
\ No newline at end of file
+    remote_src: true
+
+- name: Copy desktop entry to desktop
+  become: true
+  become_user: "{{ target_user }}"
+  template:
+    src: files/book.desktop
+    dest: "/home/{{ target_user }}/Desktop/book.desktop"
-- 
GitLab