Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
"io"
"log"
"net/http"
"time"
)
import os
import re
if __name__ == "__main__":
top = '/tmp/shared'
ren = '/tmp/shared2'
for dp, dn, fns in os.walk(top, topdown=False):
for fn in fns:
porig = os.path.join(dp, fn)
if "/." in porig:
continue
@vigliag
vigliag / prevent_suspension_on_samba_activity.py
Created November 11, 2018 09:16
This script simulates user activity, preventing automated suspension, if any file is begin accessed through samba server. Works on Plasma 5.
#!/bin/env python3
# This script simulates user activity, preventing automated suspension, if any file is begin accessed through samba server.
# works on Plasma 5, and, AFAIK, not Gnome
# based on https://bbs.archlinux.org/viewtopic.php?pid=1797228#p1797228
#
# Uses smbstatus (which requires root permissions) to find if samba is locking some file or directory.
# Do not run with sudo (wouldn't be able to connect to the SessionBus), instead
# add smbstatus to the sudoers file, to allow running it without password, for example:
# username ALL = (ALL) NOPASSWD: /usr/bin/smbstatus
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <errno.h>
#include <limits.h>
#include <string.h>
extern int errno;